-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
etcdctl: fix snapshot status accidentally modified the db file #8815
Conversation
cfc2703
to
29ec881
Compare
29ec881
to
4a2c9f7
Compare
lgtm. @zrss i am curious about how did you find this out? |
@@ -409,7 +409,7 @@ func dbStatus(p string) dbstatus { | |||
|
|||
ds := dbstatus{} | |||
|
|||
db, err := bolt.Open(p, 0400, nil) | |||
db, err := bolt.Open(p, 0400, &bolt.Options{NoFreelistSync: true}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ReadOnly: true
4a2c9f7
to
c20151f
Compare
@xiang90 er, i just wanna to check the count of keys in db file through |
@heyitsanthony fix |
@gyuho no need to backport this to 3.2. we never enabled nosyncfreelist in 3.2. |
@@ -409,7 +409,7 @@ func dbStatus(p string) dbstatus { | |||
|
|||
ds := dbstatus{} | |||
|
|||
db, err := bolt.Open(p, 0400, nil) | |||
db, err := bolt.Open(p, 0400, &bolt.Options{ReadOnly: true}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we still need the nofsync option. also the file is already opened as readonly (0400), it is strange that we write it somehow...
can you also add an e2e test for the case that you described to prevent any potential regression?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh. i looked at the open code in boltdb, it does not try to interpret the fileperm bit anyway...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only ReadOnly is OK; bbolt will detect if there's a free list or not, which is why it was rebuilding the free list here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
er, i will add a e2e test for the integrity verification with ReadOnly Option soon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems there is no test case for etcdctl ... should i add a new test file for snapshot_command or somewhere else ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xiang90 PTAL
c20151f
to
1010611
Compare
1010611
to
0ce02ab
Compare
LGTM |
etcdctl: snapshot status open bbolt with ReadOnly as true
this can avoid writing the freelist to the db file