-
Notifications
You must be signed in to change notification settings - Fork 1k
Make parallel apply compatible with RUN_STANDALONE #5146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3069,6 +3069,12 @@ TEST_CASE("remove applied", "[herder][transactionqueue]") | |||||||||||||||||||
| app->getConfig().NODE_SEED); | ||||||||||||||||||||
| herder.getHerderSCPDriver().valueExternalized(ledgerSeq, | ||||||||||||||||||||
| xdr::xdr_to_opaque(sv)); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| // With background apply, crank until the ledger is fully applied | ||||||||||||||||||||
| while (lm.getLastClosedLedgerNum() < ledgerSeq) | ||||||||||||||||||||
| { | ||||||||||||||||||||
|
Comment on lines
+3073
to
+3075
|
||||||||||||||||||||
| // With background apply, crank until the ledger is fully applied | |
| while (lm.getLastClosedLedgerNum() < ledgerSeq) | |
| { | |
| // With background apply, crank until the ledger is fully applied | |
| auto const timeout = | |
| clock.now() + std::chrono::seconds(10); | |
| while (lm.getLastClosedLedgerNum() < ledgerSeq) | |
| { | |
| REQUIRE(clock.now() < timeout); |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1599,6 +1599,14 @@ TEST_CASE_VERSIONS( | |||||||||||||||||||
|
|
||||||||||||||||||||
| while (hm.getPublishQueueCount() != 1) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| // With background apply, wait for any in-progress | ||||||||||||||||||||
| // ledger close to finish before writing to the shared | ||||||||||||||||||||
| // test-entry vectors that finalizeLedgerTxnChanges | ||||||||||||||||||||
| // reads on the apply thread. | ||||||||||||||||||||
| while (lm.isApplying()) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| clock.crank(true); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| auto lcl = lm.getLastClosedLedgerHeader(); | ||||||||||||||||||||
| lcl.header.ledgerSeq += 1; | ||||||||||||||||||||
| // Generate entries excluding soroban types to avoid worrying | ||||||||||||||||||||
|
|
@@ -1975,6 +1983,12 @@ TEST_CASE("Introduce and fix gap without starting catchup", | |||||||||||||||||||
| // Fill in the second gap. All buffered ledgers should be applied, but we | ||||||||||||||||||||
| // wait for another ledger to close to get in sync | ||||||||||||||||||||
| catchupSimulation.externalizeLedger(herder, nextLedger + 4); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| // With background apply, crank until all queued ledgers are applied | ||||||||||||||||||||
| while (lm.getLastClosedLedgerNum() < nextLedger + 5) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| app->getClock().crank(true); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
Comment on lines
+1987
to
+1991
|
||||||||||||||||||||
| // With background apply, crank until all queued ledgers are applied | |
| while (lm.getLastClosedLedgerNum() < nextLedger + 5) | |
| { | |
| app->getClock().crank(true); | |
| } | |
| // With background apply, crank until all queued ledgers are applied. | |
| REQUIRE(testutil::crankUntil(app->getClock(), [&]() { | |
| return lm.getLastClosedLedgerNum() >= nextLedger + 5; | |
| })); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -987,6 +987,15 @@ ApplicationImpl::manualClose(std::optional<uint32_t> const& manualLedgerSeq, | |
|
|
||
| if (mConfig.RUN_STANDALONE) | ||
| { | ||
| // With background apply, triggerNextLedger posts work to the | ||
| // apply thread. Crank until the ledger is fully applied and | ||
| // LCL has advanced. | ||
| while (getLedgerManager().getLastClosedLedgerNum() < | ||
| targetLedgerSeq) | ||
| { | ||
| getClock().crank(true); | ||
| } | ||
|
Comment on lines
+990
to
+997
|
||
|
|
||
| auto const newLedgerSeq = | ||
| getLedgerManager().getLastClosedLedgerNum(); | ||
| if (newLedgerSeq != targetLedgerSeq) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1966,19 +1966,10 @@ Config::processConfig(std::shared_ptr<cpptoml::table> t) | |
|
|
||
| if (PARALLEL_LEDGER_APPLY && !parallelLedgerClose()) | ||
| { | ||
| if (RUN_STANDALONE) | ||
| { | ||
| LOG_WARNING(DEFAULT_LOG, "RUN_STANDALONE is enabled, disabling " | ||
| "PARALLEL_LEDGER_APPLY"); | ||
| PARALLEL_LEDGER_APPLY = false; | ||
| } | ||
| else | ||
| { | ||
| std::string msg = | ||
| "Invalid configuration: PARALLEL_LEDGER_APPLY " | ||
| "does not support in-memory database modes."; | ||
| throw std::runtime_error(msg); | ||
| } | ||
| LOG_WARNING(DEFAULT_LOG, | ||
| "PARALLEL_LEDGER_APPLY is not supported with " | ||
| "in-memory SQLite, disabling."); | ||
| PARALLEL_LEDGER_APPLY = false; | ||
|
Comment on lines
1967
to
+1972
|
||
| } | ||
|
|
||
| if (INVARIANT_EXTRA_CHECKS && NODE_IS_VALIDATOR) | ||
|
|
@@ -2547,9 +2538,7 @@ Config::allBucketsInMemory() const | |
| bool | ||
| Config::parallelLedgerClose() const | ||
| { | ||
| // Standalone mode expects synchronous ledger application | ||
| return PARALLEL_LEDGER_APPLY && !RUN_STANDALONE && | ||
| DATABASE.value != "sqlite3://:memory:"; | ||
| return PARALLEL_LEDGER_APPLY && DATABASE.value != "sqlite3://:memory:"; | ||
| } | ||
|
|
||
| void | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This helper now contains an unbounded
whileloop that will crank forever if ledger apply stalls. Since this is used by multiple tests, it’s especially important to add a deadline/timeout and fail fast with a clear error whenledgerSeqisn’t reached.