Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add surgery clear-elements command #408

Closed
wants to merge 4 commits into from
Closed

Add surgery clear-elements command #408

wants to merge 4 commits into from

Conversation

ahrtr
Copy link
Member

@ahrtr ahrtr commented Feb 16, 2023

This PR is on top of #407. It can be used to fix the corrupted db file in #402.

Steps to fix the db file are as below.

$ ./bbolt surgery clear-elements ./local-kv.db  new1.db 29 5 6

$ ./bbolt surgery clear-elements  ./new1.db ./new2.db 29 7 8

$ ./bbolt surgery clear-elements  ./new2.db ./new3.db 29 9 10

new3.db is the final db file,

$ ./bbolt check ./new3.db 
OK

Note we still need to investigate the root cause of the corruption.

Points:
1. There are lots of duplicated definitions between bolt and
   guts_cli, which is definitely not good.
2. The implementation in guts_cli also has issue, please
   refer to #391.
   This refactoring can fix the issue.

Signed-off-by: Benjamin Wang <wachao@vmware.com>
Signed-off-by: Benjamin Wang <wachao@vmware.com>
@ahrtr
Copy link
Member Author

ahrtr commented Feb 16, 2023

Still need to add a couple of unit test cases

@shippomx
Copy link

Still need to add a couple of unit test cases

This PR is on top of #407. It can be used to fix the corrupted db file in #402.

Steps to fix the db file are as below.

$ ./bbolt surgery clear-elements ./local-kv.db  new1.db 29 5 6

$ ./bbolt surgery clear-elements  ./new1.db ./new2.db 29 7 8

$ ./bbolt surgery clear-elements  ./new2.db ./new3.db 29 9 10

new3.db is the final db file,

$ ./bbolt check ./new3.db 
OK

Note we still need to investigate the root cause of the corruption.

This PR is on top of #407. It can be used to fix the corrupted db file in #402.

Steps to fix the db file are as below.

$ ./bbolt surgery clear-elements ./local-kv.db  new1.db 29 5 6

$ ./bbolt surgery clear-elements  ./new1.db ./new2.db 29 7 8

$ ./bbolt surgery clear-elements  ./new2.db ./new3.db 29 9 10

new3.db is the final db file,

$ ./bbolt check ./new3.db 
OK

Note we still need to investigate the root cause of the corruption.

Thanks, It works for me.

Signed-off-by: Benjamin Wang <wachao@vmware.com>
Signed-off-by: Benjamin Wang <wachao@vmware.com>
@ptabor
Copy link
Contributor

ptabor commented Mar 2, 2023

I know it's not how bbolt used to be doing the syntax, but maybe starting with new commands and bbolt 1.4,
we should be using more readable (cobra style) syntax, like:

./bbolt surgery clear-page-elements ./local-kv.db --output ./local-kv.db.new --pageId 57 --from-key=5 --to-key=6

WDYT ?

@ahrtr
Copy link
Member Author

ahrtr commented Mar 2, 2023

Makes sense to me. I have been thinking to refactor the CMD using cobra. I am thinking to finish the refactoring firstly. WDYT? @ptabor @tjungblu

@ptabor
Copy link
Contributor

ptabor commented Mar 9, 2023

Makes sense to me. I have been thinking to refactor the CMD using cobra. I am thinking to finish the refactoring firstly. WDYT? @ptabor @tjungblu

Seems good to me. I don't think we need an upfront refactoring... we can start from introducing the cobra to the new commands.

@ahrtr
Copy link
Member Author

ahrtr commented Mar 10, 2023

I don't think we need an upfront refactoring

Sounds good to me. I will try to add the new command using cobra. And refactoring other commands in separate PRs later.

@ahrtr
Copy link
Member Author

ahrtr commented Mar 10, 2023

This PR will be superseded by #417

@ahrtr ahrtr closed this Mar 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants