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
This commit is contained in:
Maysam Yabandeh 2017-11-01 08:41:47 -07:00 committed by Facebook Github Bot
parent f6082d1944
commit c1cf94c787

View File

@ -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;