From 0872cbfb2f00886817f18584d95af217e28ad51d Mon Sep 17 00:00:00 2001 From: Jingyu Zhou Date: Wed, 19 Oct 2022 09:45:56 -0700 Subject: [PATCH] Fix a test timeout (#8488) * Fix a test timeout due to buggified knob MAX_WRITE_TRANSACTION_LIFE_VERSIONS The buggified knob MAX_WRITE_TRANSACTION_LIFE_VERSIONS can be only 1M. In some tests, this transaction always end up commitVersion - readVersion is a little above 1M, thus always getting transaction_too_old error. * Change MAX_COMMIT_BATCH_INTERVAL instead So that the master may give out versions fast enough. * Fix an assertion failure in a unit test 48125>>8 = 187, 48125 = 0xbbfd 48128>>8 = 188, 48128 = 0xbc00 So if 48125 is chosen as the index, 48128 changes the higher order byte. 48125 & 0xff7f = 47997 = 0xbb7d. Thus +5 won't change the higher order byte. --- fdbclient/IdempotencyId.cpp | 1 + fdbclient/ServerKnobs.cpp | 3 ++- fdbserver/tester.actor.cpp | 8 ++++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/fdbclient/IdempotencyId.cpp b/fdbclient/IdempotencyId.cpp index 69f4a9a136..eaba38ed34 100644 --- a/fdbclient/IdempotencyId.cpp +++ b/fdbclient/IdempotencyId.cpp @@ -122,6 +122,7 @@ IdempotencyIdRef generate(Arena& arena) { TEST_CASE("/fdbclient/IdempotencyId/basic") { Arena arena; uint16_t firstBatchIndex = deterministicRandom()->randomUInt32(); + firstBatchIndex &= 0xff7f; // ensure firstBatchIndex+5 won't change the higher order byte uint16_t batchIndex = firstBatchIndex; Version commitVersion = deterministicRandom()->randomInt64(0, std::numeric_limits::max()); std::vector idVector; // Reference diff --git a/fdbclient/ServerKnobs.cpp b/fdbclient/ServerKnobs.cpp index a4dc755ae5..dca0e22058 100644 --- a/fdbclient/ServerKnobs.cpp +++ b/fdbclient/ServerKnobs.cpp @@ -39,11 +39,12 @@ void ServerKnobs::initialize(Randomize randomize, ClientKnobs* clientKnobs, IsSi init( ENABLE_VERSION_VECTOR, false ); init( ENABLE_VERSION_VECTOR_TLOG_UNICAST, false ); - bool buggifyShortReadWindow = randomize && BUGGIFY && !ENABLE_VERSION_VECTOR; + bool buggifyShortReadWindow = randomize && BUGGIFY && !ENABLE_VERSION_VECTOR; init( MAX_READ_TRANSACTION_LIFE_VERSIONS, 5 * VERSIONS_PER_SECOND ); if (randomize && BUGGIFY) MAX_READ_TRANSACTION_LIFE_VERSIONS = VERSIONS_PER_SECOND; else if (buggifyShortReadWindow) MAX_READ_TRANSACTION_LIFE_VERSIONS = std::max(1, 0.1 * VERSIONS_PER_SECOND); else if( randomize && BUGGIFY ) MAX_READ_TRANSACTION_LIFE_VERSIONS = 10 * VERSIONS_PER_SECOND; init( MAX_WRITE_TRANSACTION_LIFE_VERSIONS, 5 * VERSIONS_PER_SECOND ); if (randomize && BUGGIFY) MAX_WRITE_TRANSACTION_LIFE_VERSIONS=std::max(1, 1 * VERSIONS_PER_SECOND); init( MAX_COMMIT_BATCH_INTERVAL, 2.0 ); if( randomize && BUGGIFY ) MAX_COMMIT_BATCH_INTERVAL = 0.5; // Each commit proxy generates a CommitTransactionBatchRequest at least this often, so that versions always advance smoothly MAX_COMMIT_BATCH_INTERVAL = std::min(MAX_COMMIT_BATCH_INTERVAL, MAX_READ_TRANSACTION_LIFE_VERSIONS/double(2*VERSIONS_PER_SECOND)); // Ensure that the proxy commits 2 times every MAX_READ_TRANSACTION_LIFE_VERSIONS, otherwise the master will not give out versions fast enough + MAX_COMMIT_BATCH_INTERVAL = std::min(MAX_COMMIT_BATCH_INTERVAL, MAX_WRITE_TRANSACTION_LIFE_VERSIONS/double(2*VERSIONS_PER_SECOND)); // Ensure that the proxy commits 2 times every MAX_WRITE_TRANSACTION_LIFE_VERSIONS, otherwise the master will not give out versions fast enough init( MAX_VERSION_RATE_MODIFIER, 0.1 ); init( MAX_VERSION_RATE_OFFSET, VERSIONS_PER_SECOND ); // If the calculated version is more than this amount away from the expected version, it will be clamped to this value. This prevents huge version jumps. init( ENABLE_VERSION_VECTOR_HA_OPTIMIZATION, false ); diff --git a/fdbserver/tester.actor.cpp b/fdbserver/tester.actor.cpp index 4f10fe9972..2d0de7cb7a 100644 --- a/fdbserver/tester.actor.cpp +++ b/fdbserver/tester.actor.cpp @@ -838,21 +838,25 @@ ACTOR Future testerServerCore(TesterInterface interf, ACTOR Future clearData(Database cx) { state Transaction tr(cx); state UID debugID = debugRandom()->randomUniqueID(); - TraceEvent("TesterClearingDatabaseStart", debugID).log(); tr.debugTransaction(debugID); + loop { try { + TraceEvent("TesterClearingDatabaseStart", debugID).log(); // This transaction needs to be self-conflicting, but not conflict consistently with // any other transactions tr.clear(normalKeys); tr.makeSelfConflicting(); - wait(success(tr.getReadVersion())); // required since we use addReadConflictRange but not get + Version rv = wait(tr.getReadVersion()); // required since we use addReadConflictRange but not get + TraceEvent("TesterClearingDatabaseRV", debugID).detail("RV", rv); wait(tr.commit()); TraceEvent("TesterClearingDatabase", debugID).detail("AtVersion", tr.getCommittedVersion()); break; } catch (Error& e) { TraceEvent(SevWarn, "TesterClearingDatabaseError", debugID).error(e); wait(tr.onError(e)); + debugID = debugRandom()->randomUniqueID(); + tr.debugTransaction(debugID); } }