8000 Bug fix/eom fixes (#4693) · ashang/arangodb@9d42be0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9d42be0

Browse files
authored
Bug fix/eom fixes (arangodb#4693)
1 parent 423ce33 commit 9d42be0

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

arangod/RocksDBEngine/RocksDBCollection.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,28 @@
7272

7373
using namespace arangodb;
7474

75+
// helper class that optionally disables indexing inside the
76+
// RocksDB transaction if possible, and that will turn indexing
77+
// back on later in its dtor
78+
// this is just a performance optimization for small transactions
79+
struct IndexingDisabler {
80+
IndexingDisabler(RocksDBMethods* mthd, bool disableIndexing)
81+
: mthd(mthd), disableIndexing(disableIndexing) {
82+
if (disableIndexing) {
83+
mthd->DisableIndexing();
84+
}
85+
}
86+
87+
~IndexingDisabler() {
88+
if (disableIndexing) {
89+
mthd->EnableIndexing();
90+
}
91+
}
92+
93+
RocksDBMethods* mthd;
94+
bool const disableIndexing;
95+
};
96+
7597
RocksDBCollection::RocksDBCollection(LogicalCollection* collection,
7698
VPackSlice const& info)
7799
: PhysicalCollection(collection, info),
@@ -886,6 +908,9 @@ Result RocksDBCollection::insert(arangodb::transaction::Methods* trx,
886908
state->prepareOperation(_logicalCollection->cid(), revisionId,
887909
TRI_VOC_DOCUMENT_OPERATION_INSERT);
888910

911+
// disable indexing in this transaction if we are allowed to
912+
IndexingDisabler disabler(mthds, !hasGeoIndex() && trx->isSingleOperationTransaction());
913+
889914
res = insertDocument(trx, documentId, newSlice, options);
890915

891916
if (res.ok()) {
@@ -1441,6 +1466,10 @@ Result RocksDBCollection::removeDocument(
14411466
blackListKey(key->string().data(), static_cast<uint32_t>(key->string().size()));
14421467

14431468
RocksDBMethods* mthd = RocksDBTransactionState::toMethods(trx);
1469+
1470+
// disable indexing in this transaction if we are allowed to
1471+
IndexingDisabler disabler(mthd, !hasGeoIndex() && trx->isSingleOperationTransaction());
1472+
14441473
Result res = mthd->Delete(RocksDBColumnFamily::documents(), key.ref());
14451474
if (!res.ok()) {
14461475
return res;
@@ -1506,6 +1535,10 @@ Result RocksDBCollection::updateDocument(
15061535
static_cast<uint32_t>(newKey->string().size()));
15071536
rocksdb::Slice docSlice(reinterpret_cast<char const*>(newDoc.begin()),
15081537
static_cast<size_t>(newDoc.byteSize()));
1538+
1539+
// disable indexing in this transaction if we are allowed to
1540+
IndexingDisabler disabler(mthd, !hasGeoIndex() && trx->isSingleOperationTransaction());
1541+
15091542
Result res = mthd->Put(RocksDBColumnFamily::documents(), newKey.ref(), docSlice);
15101543
if (!res.ok()) {
15111544
return res;

arangod/RocksDBEngine/RocksDBReplicationTailing.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,10 @@ RocksDBReplicationResult rocksutils::tailWal(TRI_vocbase_t* vocbase,
616616
rocksdb::Status s;
617617
// no need verifying the WAL contents
618618
rocksdb::TransactionLogIterator::ReadOptions ro(false);
619-
uint64_t since = std::max(tickStart - 1, (uint64_t)0);
619+
uint64_t since = 0;
620+
if (tickStart > 0) {
621+
since = tickStart - 1;
622+
}
620623
s = rocksutils::globalRocksDB()->GetUpdatesSince(since, &iterator, ro);
621624

622625
if (!s.ok()) {

0 commit comments

Comments
 (0)
0