8000 Chore 3.8/better corruption visibility (#15242) · rnshah9/arangodb@b49f16e · GitHub
[go: up one dir, main page]

Skip to content

Commit b49f16e

Browse files
KVS85neunhoefjsteemann
authored
Chore 3.8/better corruption visibility (arangodb#15242)
* Backport from devel. * Update arangod/RocksDBEngine/RocksDBCollection.cpp Co-authored-by: Jan <jsteemann@users.noreply.github.com> * added collection name * fix version in CHANGELOG Co-authored-by: Max Neunhoeffer <max@arangodb.com> Co-authored-by: Jan <jsteemann@users.noreply.github.com>
1 parent 4f1263b commit b49f16e

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
v3.8.5 (XXXX-XX-XX)
22
-------------------
33

4+
* Improve visibility in case of potential data corruption between primary index
5+
and actual document store in documents column family.
6+
47
* Fixed BTS-611: In some cases AQL queries, in particular in a cluster, reported
58
the wrong fullCount when the optimizer rule(s) `late-document-materialization`
69
and/or `sort-limit` were active.

arangod/RocksDBEngine/RocksDBCollection.cpp

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,23 @@ struct TruncateTimeTracker : public TimeTracker {
210210
}
211211
};
212212

213+
void reportPrimaryIndexInconsistency(
214+
arangodb::Result const& res,
215+
arangodb::velocypack::StringRef const& key,
216+
arangodb::LocalDocumentId const& rev,
217+
arangodb::LogicalCollection const& collection) {
218+
219+
if (res.is(TRI_ERROR_ARANGO_DOCUMENT_NOT_FOUND)) {
220+
// Scandal! A primary index entry is pointing to nowhere! Let's report
221+
// this to the authorities immediately:
222+
LOG_TOPIC("42536", ERR, arangodb::Logger::ENGINES)
223+
<< "Found primary index entry for which there is no actual "
224+
"document: collection=" << collection.name() << ", _key="
225+
<< key << ", _rev=" << rev.id();
226+
TRI_ASSERT(false);
227+
}
228+
}
229+
213230
} // namespace
214231

215232
namespace arangodb {
@@ -949,11 +966,12 @@ Result RocksDBCollection::read(transaction::Methods* trx,
949966

950967
rocksdb::PinnableSlice ps;
951968
Result res;
969+
LocalDocumentId documentId;
952970
do {
953-
LocalDocumentId const documentId = primaryIndex()->lookupKey(trx, key, readOwnWrites);
971+
documentId = primaryIndex()->lookupKey(trx, key, readOwnWrites);
954972
if (!documentId.isSet()) {
955973
res.reset(TRI_ERROR_ARANGO_DOCUMENT_NOT_FOUND);
956-
break;
974+
return res;
957975
} // else found
958976

959977
TRI_IF_FAILURE("RocksDBCollection::read-delay") {
@@ -966,6 +984,7 @@ Result RocksDBCollection::read(transaction::Methods* trx,
966984
}
967985
} while (res.is(TRI_ERROR_ARANGO_DOCUMENT_NOT_FOUND) &&
968986
RocksDBTransactionState::toState(trx)->ensureSnapshot());
987+
::reportPrimaryIndexInconsistency(res, key, documentId, _logicalCollection);
969988
return res;
970989
}
971990

@@ -1219,6 +1238,7 @@ Result RocksDBCollection::replace(transaction::Methods* trx,
12191238
res = lookupDocumentVPack(trx, oldDocumentId, previousPS,
12201239
/*readCache*/ true, /*fillCache*/ false, ReadOwnWrites::yes);
12211240
if (res.fail()) {
1241+
::reportPrimaryIndexInconsistency(res, keyStr, oldDocumentId, _logicalCollection);
12221242
return res;
12231243
}
12241244

@@ -1334,7 +1354,9 @@ Result RocksDBCollection::remove(transaction::Methods& trx, velocypack::Slice sl
13341354
expectedId = RevisionId::fromSlice(slice);
13351355
}
13361356

1337-
return remove(trx, documentId, expectedId, previousMdr, options);
1357+
Result res = remove(trx, documentId, expectedId, previousMdr, options);
1358+
::reportPrimaryIndexInconsistency(res, keyStr, documentId, _logicalCollection);
1359+
return res;
13381360
}
13391361

13401362
Result RocksDBCollection::remove(transaction::Methods& trx, LocalDocumentId documentId,

0 commit comments

Comments
 (0)
0