Skip to content

Commit 9efd4d5

Browse files
apkardongxinEric
authored andcommitted
Ignore index_wrong_build_id error in correctness. (#121)
Also * UpdateIndexPlan should always get a valid buildId * Adding few more TraceEvent on error messages.
1 parent cc97582 commit 9efd4d5

4 files changed

Lines changed: 23 additions & 17 deletions

File tree

src/MetadataManager.actor.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,12 +254,13 @@ ACTOR static Future<Void> buildIndex_impl(bson::BSONObj indexObj,
254254

255255
state Reference<Plan> finalizePlan = ec->isolatedWrapOperationPlan(
256256
ref(new UpdateIndexStatusPlan(ns, encodedIndexId, ec->mm,
257-
std::string(DocLayerConstants::INDEX_STATUS_READY), info.buildId)),
257+
std::string(DocLayerConstants::INDEX_STATUS_READY), build_id)),
258258
0, -1);
259259
int64_t _ = wait(executeUntilCompletionTransactionally(finalizePlan, ec->getOperationTransaction()));
260260

261261
return Void();
262262
} catch (Error& e) {
263+
TraceEvent(SevError, "indexRebuildFailed").error(e);
263264
state Error err = e;
264265
// try forever to set the index into an error status (unless somebody comes along before us and starts a
265266
// different build)
@@ -270,7 +271,7 @@ ACTOR static Future<Void> buildIndex_impl(bson::BSONObj indexObj,
270271
// buildId field does not exist (as is the case for 'ready' indexes).
271272
state Reference<Plan> errorPlan = ec->isolatedWrapOperationPlan(
272273
ref(new UpdateIndexStatusPlan(ns, encodedIndexId, ec->mm,
273-
std::string(DocLayerConstants::INDEX_STATUS_ERROR), info.buildId)),
274+
std::string(DocLayerConstants::INDEX_STATUS_ERROR), build_id)),
274275
0, -1);
275276
try {
276277
int64_t _ = wait(executeUntilCompletionTransactionally(errorPlan, ec->getOperationTransaction()));

src/QLPlan.actor.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,7 +1552,7 @@ ACTOR static Future<Void> updateIndexStatus(PlanCheckpoint* checkpoint,
15521552
Standalone<StringRef> encodedIndexId,
15531553
Reference<MetadataManager> mm,
15541554
std::string newStatus,
1555-
Optional<UID> buildId,
1555+
UID buildId,
15561556
PromiseStream<Reference<ScanReturnedContext>> output) {
15571557
state bool okay;
15581558
state FlowLock* flowControlLock = checkpoint->getDocumentFinishedLock();
@@ -1563,21 +1563,23 @@ ACTOR static Future<Void> updateIndexStatus(PlanCheckpoint* checkpoint,
15631563
indexCollection->bindCollectionContext(tr)->cx->getSubContext(encodedIndexId);
15641564
Reference<UnboundCollectionContext> ucx = wait(mm->getUnboundCollectionContext(tr, ns));
15651565
state Reference<CollectionContext> mcx = ucx->bindCollectionContext(tr);
1566-
if (buildId.present()) {
1567-
Optional<DataValue> dv =
1568-
wait(indexDoc->get(DataValue(DocLayerConstants::BUILD_ID_FIELD, DVTypeCode::STRING).encode_key_part()));
1569-
if (dv.present()) {
1570-
UID currId = UID::fromString(dv.get().getString());
1571-
if (currId == buildId.get()) {
1572-
okay = true;
1573-
} else {
1574-
okay = false;
1575-
}
1566+
Optional<DataValue> dv =
1567+
wait(indexDoc->get(DataValue(DocLayerConstants::BUILD_ID_FIELD, DVTypeCode::STRING).encode_key_part()));
1568+
if (dv.present()) {
1569+
UID currId = UID::fromString(dv.get().getString());
1570+
if (currId == buildId) {
1571+
okay = true;
15761572
} else {
1573+
TraceEvent(SevError, "MismatchedIndexBuildID")
1574+
.detail("indexDoc", indexDoc->toDbgString())
1575+
.detail("newStatus", newStatus);
15771576
okay = false;
15781577
}
15791578
} else {
1580-
okay = true;
1579+
TraceEvent(SevError, "MissingIndexBuildID")
1580+
.detail("indexDoc", indexDoc->toDbgString())
1581+
.detail("newStatus", newStatus);
1582+
okay = false;
15811583
}
15821584

15831585
if (okay) {

src/QLPlan.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -669,13 +669,13 @@ struct UpdateIndexStatusPlan : ConcretePlan<UpdateIndexStatusPlan> {
669669
Standalone<StringRef> encodedIndexId;
670670
Reference<MetadataManager> mm;
671671
std::string newStatus;
672-
Optional<UID> buildId;
672+
UID buildId;
673673

674674
UpdateIndexStatusPlan(Namespace const& ns,
675675
Standalone<StringRef> encodedIndexId,
676676
Reference<MetadataManager> mm,
677677
std::string newStatus,
678-
Optional<UID> buildId = Optional<UID>())
678+
UID buildId)
679679
: ns(ns), encodedIndexId(encodedIndexId), mm(mm), newStatus(newStatus), buildId(buildId) {}
680680

681681
bson::BSONObj describe() override {

test/correctness/document-correctness.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,9 +424,12 @@ def _run_operation_(op1, op2):
424424

425425
ignored_exceptions = [
426426
"Multi-multikey index size exceeds maximum value",
427-
"key too large to index", # it's hard to estimate the exact byte size of KVS key to be inserted, ignore for now.
427+
"key too large to index", # it's hard to estimate the exact byte size of KVS key to be inserted, ignore for now.
428428
"Key length exceeds limit",
429429
"Operation aborted because the transaction timed out",
430+
# This is another variant of "Operation aborted" error. For now, ignoring this error. We have to fix this part of
431+
# transaction handling redesign.
432+
"Attempting to change status of a different index build",
430433
]
431434

432435

0 commit comments

Comments
 (0)