Skip to content

Set a multi-thread scheduled executor for tests#4348

Open
ScottDugas wants to merge 4 commits into
FoundationDB:mainfrom
ScottDugas:subissue-4333
Open

Set a multi-thread scheduled executor for tests#4348
ScottDugas wants to merge 4 commits into
FoundationDB:mainfrom
ScottDugas:subissue-4333

Conversation

@ScottDugas

Copy link
Copy Markdown
Collaborator

MoreAsyncUtil installs a JVM-wide single-thread ScheduledThreadPoolExecutor by default. When the suite runs N tests concurrently and they each schedule deadline timers on that single shared thread, the timers fire late and produce spurious DeadlineExceededException from AsyncLoadingCache -- most prominently FDBDatabase.resolverStateCache during KeySpacePath.toTuple cleanup.

Override the FDBDatabaseFactory default scheduled executor in FDBDatabaseExtension and other tests with a multi-threaded pool (max(availableProcessors, 4)) shared across all tests.

Closes #4333

MoreAsyncUtil installs a JVM-wide single-thread ScheduledThreadPoolExecutor
by default. When the suite runs N tests concurrently and they each schedule
deadline timers on that single shared thread, the timers fire late and
produce spurious DeadlineExceededException from AsyncLoadingCache -- most
prominently FDBDatabase.resolverStateCache during KeySpacePath.toTuple
cleanup.

Override the FDBDatabaseFactory default scheduled executor in
FDBDatabaseExtension with a multi-threaded pool
(max(availableProcessors, 4)) shared across all tests using the extension.

The same override should be applied to any other test extension that uses
the default scheduler; that is left as follow-up.

Closes FoundationDB#4333
Move the multi-thread ScheduledExecutorService that FDBDatabaseExtension
installs on its FDBDatabaseFactory (added in the previous commit) into
TestExecutors.defaultScheduledThreadPool(), mirroring the existing
newThreadPool / defaultThreadPool pair.

Behavior-neutral refactor: same pool sizing (max(cpu, 4) threads),
same TestThreadFactory naming. Prepares the way for the next commit
which sprinkles the same override across every other test-time
FDBDatabaseFactory site.

For FoundationDB#4333
Follow-up to the FDBDatabaseExtension change: apply the same
setScheduledExecutor(TestExecutors.defaultScheduledThreadPool())
override to every other test-time construction of an
FDBDatabaseFactory I could find. Without this, JUnit-parallel
tests that don't go through FDBDatabaseExtension still race against
MoreAsyncUtil's single-thread default scheduler and see spurious
DeadlineExceededException from AsyncLoadingCache (most prominently
FDBDatabase.resolverStateCache during KeySpacePath.toTuple cleanup).

Sites updated:
  - EmbeddedRelationalExtension (its setup() @beforeeach — the
    biggest win; used by many parallel tests)
  - RecordLayerStoreCatalogImplTest.setUpCatalog
  - RecordLayerStoreCatalogWithNoTemplateOperationsTest.setUpCatalog
  - CatalogMetaDataProviderTest.canLoadMetaDataFromStore
  - JDBCEmbedDriverTest (its per-test factory setup)
  - LocatableResolverTest.testParallelDbAndScopeGetVersion (the one
    site there that constructs a fresh FDBDatabaseFactoryImpl; other
    sites in that file already go through dbExtension.getDatabaseFactory)
  - yaml-tests Command.applyMetadataOperationDirectly

Sites that already inherit the override (no change): every test that
delegates via dbExtension.getDatabaseFactory() — FDBRecordStorePerformanceTest,
FDBLuceneQueryTest, subclasses of FDBRecordStoreConcurrentTestBase.

Closes FoundationDB#4333
@ScottDugas ScottDugas added the testing improvement Change that improves our testing label Jul 13, 2026
@ScottDugas ScottDugas requested a review from alecgrieser July 13, 2026 19:24
@ScottDugas ScottDugas marked this pull request as ready for review July 13, 2026 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing improvement Change that improves our testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Configure FDBDatabaseExtension with a multi-thread scheduled executor

1 participant