From c1cf94c7877ee11ed6ec5baae178691d3b10ace1 Mon Sep 17 00:00:00 2001 From: Maysam Yabandeh Date: Wed, 1 Nov 2017 08:41:47 -0700 Subject: [PATCH] WritePrepared Txn: sort indexes before batch collapse Summary: The collapse of duplicate keys in write batch needs to sort the indexes of duplicate keys since it only checks the index in the batch with the head of the list of duplicate keys. Closes https://github.com/facebook/rocksdb/pull/3093 Differential Revision: D6186800 Pulled By: maysamyabandeh fbshipit-source-id: abc9ae8c2f1840445a5584f925cf86ecc6f37154 --- utilities/write_batch_with_index/write_batch_with_index.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/utilities/write_batch_with_index/write_batch_with_index.cc b/utilities/write_batch_with_index/write_batch_with_index.cc index 133419aa3..f009f1dab 100644 --- a/utilities/write_batch_with_index/write_batch_with_index.cc +++ b/utilities/write_batch_with_index/write_batch_with_index.cc @@ -583,6 +583,7 @@ void WriteBatchWithIndex::Rep::AddNewEntry(uint32_t column_family_id) { if (rep->obsolete_offsets.size() == 0) { return false; } + std::sort(rep->obsolete_offsets.begin(), rep->obsolete_offsets.end()); WriteBatch& write_batch = rep->write_batch; assert(write_batch.Count() != 0); size_t offset = WriteBatchInternal::GetFirstOffset(&write_batch); @@ -953,6 +954,7 @@ Status WriteBatchWithIndex::RollbackToSavePoint() { if (s.ok()) { s = rep->ReBuildIndex(); + rep->obsolete_offsets.clear(); } return s;