From 7c95190b36a0ea3bfa91af9a5a62a95e7cac3138 Mon Sep 17 00:00:00 2001 From: Edward Hennis <ed@ripple.com> Date: Wed, 23 Jun 2021 09:08:34 -0400 Subject: [PATCH] Fix(?) the DatabaseShard manual test timing This fix has been included in #3875, so watch out for merge conflicts --- src/test/nodestore/DatabaseShard_test.cpp | 34 +++++++++++++++++------ 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/src/test/nodestore/DatabaseShard_test.cpp b/src/test/nodestore/DatabaseShard_test.cpp index e6f1e3e15d9..6922d4b24a1 100644 --- a/src/test/nodestore/DatabaseShard_test.cpp +++ b/src/test/nodestore/DatabaseShard_test.cpp @@ -19,6 +19,7 @@ #include <ripple/app/ledger/LedgerMaster.h> #include <ripple/app/ledger/LedgerToJson.h> +#include <ripple/app/misc/LoadFeeTrack.h> #include <ripple/app/misc/SHAMapStore.h> #include <ripple/app/rdb/backend/RelationalDBInterfaceSqlite.h> #include <ripple/basics/Slice.h> @@ -263,6 +264,10 @@ class DatabaseShard_test : public TestBase { using namespace test::jtx; + // The local fee may go up, especially in the online delete tests + while (env_.app().getFeeTrack().lowerLocalFee()) + std::this_thread::sleep_for(std::chrono::milliseconds(1)); + if (isNewAccounts(seq)) env_.fund(XRP(iniAmount), accounts_[nAccounts_[seq] - 1]); @@ -1249,14 +1254,22 @@ class DatabaseShard_test : public TestBase Database& ndb = env.app().getNodeStore(); BEAST_EXPECT(db); + auto& store = env.app().getSHAMapStore(); + + // Allow online delete to delete the startup ledgers + // so that it will take some time for the import to + // catch up to the point of the next rotation + store.setCanDelete(10); + // Create some ledgers for the shard store to import auto const shardCount = 5; TestData data(seedValue, 4, shardCount); if (!BEAST_EXPECT(data.makeLedgers(env))) return; - auto& store = env.app().getSHAMapStore(); - auto lastRotated = store.getLastRotated(); + store.rendezvous(); + auto const lastRotated = store.getLastRotated(); + BEAST_EXPECT(lastRotated >= 553 && lastRotated < 1103); // Start the import db->importDatabase(ndb); @@ -1267,24 +1280,27 @@ class DatabaseShard_test : public TestBase std::this_thread::sleep_for(std::chrono::milliseconds(1)); } - // Enable online deletion now that the import has started + // Enable unimpeded online deletion now that the import has started store.setCanDelete(std::numeric_limits<std::uint32_t>::max()); auto pauseVerifier = std::thread([lastRotated, &store, db, this] { - while (true) + // The import should still be running when this thread starts + BEAST_EXPECT(db->getDatabaseImportSequence()); + auto rotationProgress = lastRotated; + while (auto const ledgerSeq = db->getDatabaseImportSequence()) { // Make sure database rotations dont interfere // with the import - if (store.getLastRotated() != lastRotated) + auto const last = store.getLastRotated(); + if (last != rotationProgress) { // A rotation occurred during shard import. Not // necessarily an error - auto const ledgerSeq = db->getDatabaseImportSequence(); - BEAST_EXPECT(!ledgerSeq || ledgerSeq >= lastRotated); - - break; + BEAST_EXPECT( + !ledgerSeq || ledgerSeq >= rotationProgress); + rotationProgress = last; } } });