mirror of https://gitee.com/bigwinds/arangodb
Bug fix 3.4/rocksdb truncate asan (#8525)
This commit is contained in:
parent
abd09e2e2c
commit
89a7591d00
|
@ -607,21 +607,27 @@ Result RocksDBCollection::truncate(transaction::Methods* trx, OperationOptions&
|
||||||
uint64_t const prvICC = state->options().intermediateCommitCount;
|
uint64_t const prvICC = state->options().intermediateCommitCount;
|
||||||
state->options().intermediateCommitCount = std::min<uint64_t>(prvICC, 10000);
|
state->options().intermediateCommitCount = std::min<uint64_t>(prvICC, 10000);
|
||||||
|
|
||||||
std::unique_ptr<rocksdb::Iterator> iter =
|
|
||||||
mthds->NewIterator(ro, documentBounds.columnFamily());
|
|
||||||
iter->Seek(documentBounds.start());
|
|
||||||
|
|
||||||
uint64_t found = 0;
|
uint64_t found = 0;
|
||||||
while (iter->Valid() && cmp->Compare(iter->key(), end) < 0) {
|
VPackBuilder docBuffer;
|
||||||
|
auto iter = mthds->NewIterator(ro, documentBounds.columnFamily());
|
||||||
|
for (iter->Seek(documentBounds.start());
|
||||||
|
iter->Valid() && cmp->Compare(iter->key(), end) < 0;
|
||||||
|
iter->Next()) {
|
||||||
|
|
||||||
++found;
|
++found;
|
||||||
TRI_ASSERT(_objectId == RocksDBKey::objectId(iter->key()));
|
TRI_ASSERT(_objectId == RocksDBKey::objectId(iter->key()));
|
||||||
VPackSlice doc = VPackSlice(iter->value().data());
|
VPackSlice document(iter->value().data());
|
||||||
TRI_ASSERT(doc.isObject());
|
TRI_ASSERT(document.isObject());
|
||||||
|
|
||||||
|
// tmp may contain a pointer into rocksdb::WriteBuffer::_rep. This is
|
||||||
|
// a 'std::string' which might be realloc'ed on any Put/Delete operation
|
||||||
|
docBuffer.clear();
|
||||||
|
docBuffer.add(document);
|
||||||
|
|
||||||
// To print the WAL we need key and RID
|
// To print the WAL we need key and RID
|
||||||
VPackSlice key;
|
VPackSlice key;
|
||||||
TRI_voc_rid_t rid = 0;
|
TRI_voc_rid_t rid = 0;
|
||||||
transaction::helpers::extractKeyAndRevFromDocument(doc, key, rid);
|
transaction::helpers::extractKeyAndRevFromDocument(document, key, rid);
|
||||||
TRI_ASSERT(key.isString());
|
TRI_ASSERT(key.isString());
|
||||||
TRI_ASSERT(rid != 0);
|
TRI_ASSERT(rid != 0);
|
||||||
|
|
||||||
|
@ -632,14 +638,13 @@ Result RocksDBCollection::truncate(transaction::Methods* trx, OperationOptions&
|
||||||
TRI_VOC_DOCUMENT_OPERATION_REMOVE);
|
TRI_VOC_DOCUMENT_OPERATION_REMOVE);
|
||||||
|
|
||||||
LocalDocumentId const docId = RocksDBKey::documentId(iter->key());
|
LocalDocumentId const docId = RocksDBKey::documentId(iter->key());
|
||||||
auto res = removeDocument(trx, docId, doc, options);
|
auto res = removeDocument(trx, docId, docBuffer.slice(), options);
|
||||||
|
|
||||||
if (res.fail()) { // Failed to remove document in truncate.
|
if (res.fail()) { // Failed to remove document in truncate.
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasPerformedIntermediateCommit = false;
|
bool hasPerformedIntermediateCommit = false;
|
||||||
|
|
||||||
res = state->addOperation(_logicalCollection.id(), docId.id(), TRI_VOC_DOCUMENT_OPERATION_REMOVE,
|
res = state->addOperation(_logicalCollection.id(), docId.id(), TRI_VOC_DOCUMENT_OPERATION_REMOVE,
|
||||||
hasPerformedIntermediateCommit);
|
hasPerformedIntermediateCommit);
|
||||||
|
|
||||||
|
@ -649,7 +654,6 @@ Result RocksDBCollection::truncate(transaction::Methods* trx, OperationOptions&
|
||||||
guard.finish(hasPerformedIntermediateCommit);
|
guard.finish(hasPerformedIntermediateCommit);
|
||||||
|
|
||||||
trackWaitForSync(trx, options);
|
trackWaitForSync(trx, options);
|
||||||
iter->Next();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset to previous value after truncate is finished
|
// reset to previous value after truncate is finished
|
||||||
|
|
Loading…
Reference in New Issue