From 3340933a01945fb517775a0e0f079a701d04f094 Mon Sep 17 00:00:00 2001 From: Manish R Jain Date: Wed, 13 Jun 2018 16:21:36 -0700 Subject: [PATCH] Bug fixes related to txn nil callbacks and badgerMove key. --- iterator.go | 4 +++- transaction.go | 2 +- value.go | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/iterator.go b/iterator.go index 51a0a242b..7fa1068fe 100644 --- a/iterator.go +++ b/iterator.go @@ -167,7 +167,9 @@ func (item *Item) yieldItemValue() ([]byte, func(), error) { // The value pointer is pointing to a deleted value log. Look for the // move key and read that instead. runCallback(cb) - key = append(badgerMove, y.KeyWithTs(item.Key(), item.Version())...) + // Do not put badgerMove on the left in append. It seems to cause some sort of manipulation. + key = append([]byte{}, badgerMove...) + key = append(key, y.KeyWithTs(item.Key(), item.Version())...) // Note that we can't set item.key to move key, because that would // change the key user sees before and after this call. Also, this move // logic is internal logic and should not impact the external behavior diff --git a/transaction.go b/transaction.go index de5f479c8..b56d3b9ff 100644 --- a/transaction.go +++ b/transaction.go @@ -411,7 +411,7 @@ func (txn *Txn) runCallbacks() { for _, cb := range txn.callbacks { cb() } - txn.callbacks = nil + txn.callbacks = txn.callbacks[:0] } // Discard discards a created transaction. This method is very important and must be called. Commit diff --git a/value.go b/value.go index cad584a6b..d6b9e5635 100644 --- a/value.go +++ b/value.go @@ -387,7 +387,8 @@ func (vlog *valueLog) rewrite(f *logFile, tr trace.Trace) error { if bytes.HasPrefix(e.Key, badgerMove) { ne.Key = append([]byte{}, e.Key...) } else { - ne.Key = append(badgerMove, e.Key...) + ne.Key = append([]byte{}, badgerMove...) + ne.Key = append(ne.Key, e.Key...) } ne.Value = append([]byte{}, e.Value...)