-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fix(cleanup): Avoid truncating in value.Open on error #1465
Conversation
The vlog.Open() function can return an error denoting that the open was unsuccessful but we have `db.cleanup` which will be called to stop all the running go routines in case badger couldn't start. The db.cleanup function calls vlog.Close() which will truncate the maxFid vlog file based on the vlog.writableLogOffset. The vlog.writableLogOffset was not being updated in case open failed. As a result of this, we will end up truncating the vlog file to lenght 0 if open fails. This PR fixes this by setting writableLogOffset to endOffset of the replay so that we don't truncate the entire file.
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.
Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @ashish-goswami and @manishrjain)
value.go, line 1088 at r1 (raw file):
// TODO(ibrahim): Do we really want this? The DB might not open if we end // up in this situation. y.AssertTruef(endOffset < uint32(sz), "endoffset: %d should be more than sz:%d", endOffset, sz)
I am not sure if we should keep this. An error here would be unrecoverable (unless we manually truncate the file to the given offset which means we create a hole in the file).
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.
Reviewed 1 of 2 files at r2, 1 of 1 files at r3.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @manishrjain)
* Fix(cleanup): Avoid truncating in value.Open on error The vlog.Open() function can return an error denoting that the open was unsuccessful but we have `db.cleanup` which will be called to stop all the running go routines in case badger couldn't start. The db.cleanup function calls vlog.Close() which will truncate the maxFid vlog file based on the vlog.writableLogOffset. The vlog.writableLogOffset was not being updated in case open failed. As a result of this, we will end up truncating the vlog file to lenght 0 if open fails. This PR fixes this by using vlog.stopDiscardStatFlush() instead of vlog.close. (cherry picked from commit ed3b219)
The vlog.Open() function can return an error denoting that the open was unsuccessful but we have `db.cleanup` which will be called to stop all the running goroutines in case badger couldn't start. The db.cleanup function calls vlog.Close() which will truncate the maxFid vlog file based on the vlog.writableLogOffset. The vlog.writableLogOffset was not being updated in case open failed. As a result of this, we will end up truncating the vlog file to length 0 if open fails. This PR fixes this by using vlog.stopDiscardStatFlush() instead of vlog.close. (cherry picked from commit ed3b219)
* Fix(cleanup): Avoid truncating in value.Open on error The vlog.Open() function can return an error denoting that the open was unsuccessful but we have `db.cleanup` which will be called to stop all the running go routines in case badger couldn't start. The db.cleanup function calls vlog.Close() which will truncate the maxFid vlog file based on the vlog.writableLogOffset. The vlog.writableLogOffset was not being updated in case open failed. As a result of this, we will end up truncating the vlog file to lenght 0 if open fails. This PR fixes this by using vlog.stopDiscardStatFlush() instead of vlog.close.
The vlog.Open() function can return an error denoting that the open was
unsuccessful but we have
db.cleanup
which will be called to stop allthe running goroutines in case badger couldn't start. The db.cleanup
function calls vlog.Close() which will truncate the maxFid vlog file
based on the vlog.writableLogOffset. The vlog.writableLogOffset was not
being updated in case open failed. As a result of this, we will end up
truncating the vlog file to length 0 if open fails.
This PR fixes this by using
vlog.stopDiscardStatFlush()
instead ofvlog.close
.This change is