Set a multi-thread scheduled executor for tests#4348
Open
ScottDugas wants to merge 4 commits into
Open
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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