-
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 discard stats moved by GC bug #929
Conversation
The discard stats are stored like normal keys in badger, which means if the size of value of discard stats key is greater the value threshold it will be stored in the value log. When value log GC happens, we insert the same key in badger with a !badger!move prefix which points to the new value log file. So when searching for the value of a key, if the value points to a value log file which doesn't exist, we search for the same key with !badger!move prefix. The above logic was missing from the populateDiscardStats function. The earlier implementation would never search for the key with !badger!move prefix. It would return error on first attempt to find the key. This commit ensures we search for key with prefix badger move if the value for the existing key pointed to a value log file that no longer exist.
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 2 of 2 files at r1.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @ashish-goswami, @jarifibrahim, and @Sch00lb0y)
value.go, line 1431 at r1 (raw file):
func (vlog *valueLog) populateDiscardStats() error { key := y.KeyWithTs(lfDiscardStatsKey, math.MaxUint64) newKey := make([]byte, len(key))
Don't need newKey
value.go, line 1449 at r1 (raw file):
// Entry stored in LSM tree. if vs.Meta&bitValuePointer == 0 { val = make([]byte, len(vs.Value))
val = y.SafeCopy(vs.Value)
value.go, line 1454 at r1 (raw file):
} // Read entry from value log. result, cb, err := vlog.Read(vp, new(y.Slice))
Just confirm that you can defer run callback without checking error.
value.go, line 1456 at r1 (raw file):
result, cb, err := vlog.Read(vp, new(y.Slice)) defer runCallback(cb) val = make([]byte, len(result))
val = y.SafeCopy(result)
value.go, line 1472 at r1 (raw file):
// Prepend existing key with badger move and search for the key. n := copy(newKey, badgerMove) copy(newKey[n:], key)
key = append(badgerMove, key...)
?
value.go, line 1479 at r1 (raw file):
} if err := json.Unmarshal(val, &statsMap); err != nil { return errors.Wrapf(err, "failed to unmarshal discard stats")
Just log it. And continue the logic.
Will this PR be cherry-picked on top of 1.6 and released as v1.6.1? Currently without this change, v1.6.0 has an unrepairable issue. |
@campoy How should we release this fix? |
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: all files reviewed, 6 unresolved discussions (waiting on @ashish-goswami, @manishrjain, and @Sch00lb0y)
value.go, line 1431 at r1 (raw file):
Previously, manishrjain (Manish R Jain) wrote…
Don't need newKey
Done.
value.go, line 1449 at r1 (raw file):
Previously, manishrjain (Manish R Jain) wrote…
val = y.SafeCopy(vs.Value)
Done.
value.go, line 1454 at r1 (raw file):
Previously, manishrjain (Manish R Jain) wrote…
Just confirm that you can defer run callback without checking error.
The callback is nothing but a lockfile.Lock.Unlock()
function. Even in case of error, we should unlock the file. The call should be called before we handle the error.
value.go, line 1456 at r1 (raw file):
Previously, manishrjain (Manish R Jain) wrote…
val = y.SafeCopy(result)
Done.
value.go, line 1472 at r1 (raw file):
Previously, manishrjain (Manish R Jain) wrote…
key = append(badgerMove, key...)
?
Done.
value.go, line 1479 at r1 (raw file):
Previously, manishrjain (Manish R Jain) wrote…
Just log it. And continue the logic.
This change is in #936 . I'll update this branch once #936 is merged.
* Fix discard stats moved by GC bug The discard stats are stored like normal keys in badger, which means if the size of the value of discard stats key is greater the value threshold it will be stored in the value log. When value log GC happens, we insert the same key in badger with a !badger!move prefix which points to the new value log file. So when searching for the value of a key, if the value points to a value log file which doesn't exist, we search for the same key with !badger!move prefix. The above logic was missing from the populateDiscardStats function. The earlier implementation would never search for the key with !badger!move prefix. It would return error on the first attempt to find the key. This commit ensures we search for a key with prefix badger move if the value for the existing key pointed to a value log file that no longer exists.
Fix discard stats moved by GC bug (dgraph-io#929)
The discard stats are stored like normal keys in badger, which means if the size of the value of discard stats key is greater the value threshold it will be stored in the value log. When value log GC happens, we insert the same key in badger with a !badger!move prefix which points to the new value log file. So when searching for the value of a key, if the value points to a value log file which doesn't exist, we search for the same key with !badger!move prefix. The above logic was missing from the populateDiscardStats function. The earlier implementation would never search for the key with !badger!move prefix. It would return error on the first attempt to find the key. This commit ensures we search for a key with prefix badger move if the value for the existing key pointed to a value log file that no longer exists.
The discard stats are stored like normal keys in badger, which means if the size of the value of discard stats key is greater the value threshold it will be stored in the value log. When value log GC happens, we insert the same key in badger with a !badger!move prefix which points to the new value log file. So when searching for the value of a key, if the value points to a value log file which doesn't exist, we search for the same key with !badger!move prefix. The above logic was missing from the populateDiscardStats function. The earlier implementation would never search for the key with !badger!move prefix. It would return error on the first attempt to find the key. This commit ensures we search for a key with prefix badger move if the value for the existing key pointed to a value log file that no longer exists.
The discard stats are stored like normal keys in badger, which means if the size of the value of discard stats key is greater the value threshold it will be stored in the value log. When value log GC happens, we insert the same key in badger with a !badger!move prefix which points to the new value log file. So when searching for the value of a key, if the value points to a value log file that doesn't exist, we search for the same key with !badger!move prefix. The above logic was missing from the populateDiscardStats function. The earlier implementation would never search for the key with !badger!move prefix. It would return error on the first attempt to find the key. This commit ensures we search for a key with prefix badger move if the value for the existing key pointed to a value log file that no longer exists.
This vendors in Badger v1.6.0 with dgraph-io/badger#929 cherry-picked into it (dgraph-io/badger#1098) to avoid any breaking changes to the data format.
This vendors in Badger v1.6.0 with dgraph-io/badger#929 cherry-picked into it (dgraph-io/badger#1098) to avoid any breaking changes to the data format. Vendor in Badger to fix a bug that prevents Alpha from starting up successfully. This happens in v1.0.16 and v1.0.17. Error while creating badger KV posting store error: Unable to find log file. Please retry The release/v1.0 branch uses the vendor directory for dependencies. Badger was pulled in with the following command: govendor fetch github.com/dgraph-io/badger/...@efb9d9d15d7f7baa656e04933058f006c33a8d0f
This vendors in Badger v1.6.0 with dgraph-io/badger#929 cherry-picked into it (dgraph-io/badger#1098) to avoid any breaking changes to the data format. Vendor in Badger to fix a bug that prevents Alpha from starting up successfully. This happens in v1.0.16 and v1.0.17. Error while creating badger KV posting store error: Unable to find log file. Please retry The release/v1.0 branch uses the vendor directory for dependencies. Badger was pulled in with the following command: govendor fetch github.com/dgraph-io/badger/...@efb9d9d15d7f7baa656e04933058f006c33a8d0f
- For the details, see dgraph-io/badger#929
- The actual package is the forked version from the Badger release/1.6 branch to avoid a build failure resulting from the modification of the Badger repository like branch removing. - For the details, see dgraph-io/badger#929
* Fix discard stats moved by GC bug The discard stats are stored like normal keys in badger, which means if the size of the value of discard stats key is greater the value threshold it will be stored in the value log. When value log GC happens, we insert the same key in badger with a !badger!move prefix which points to the new value log file. So when searching for the value of a key, if the value points to a value log file which doesn't exist, we search for the same key with !badger!move prefix. The above logic was missing from the populateDiscardStats function. The earlier implementation would never search for the key with !badger!move prefix. It would return error on the first attempt to find the key. This commit ensures we search for a key with prefix badger move if the value for the existing key pointed to a value log file that no longer exists. (cherry picked from commit 50c90ed)
The discard stats are stored like normal keys in badger, which means if
the size of the value of discard stats key is greater the value threshold it
will be stored in the value log. When value log GC happens, we insert
the same key in badger with a !badger!move prefix which points to the
new value log file. So when searching for the value of a key, if the value
points to a value log file which doesn't exist, we search for the same
key with
!badger!move
prefix.The above logic was missing from the populateDiscardStats function. The
earlier implementation would never search for the key with
!badger!move
prefix. It would return error on the first attempt to find the key. This
commit ensures we search for a key with prefix badger move if the value
for the existing key pointed to a value log file that no longer exists.
Fixes - #926
This change is