feat(F16): Migrate to structured concurrency and ReentrantLock - #72
Merged
Merged
Conversation
- Replace all synchronized blocks with ReentrantLock across SnapshotExecutor, SnapshotWorker, and RegionalDataSourceFactory to prevent virtual thread carrier-thread pinning - Adopt StructuredTaskScope for parallel snapshot chunk fan-out, replacing manual work-queue + Thread.startVirtualThread() pattern - Enable spring.threads.virtual.enabled for Tomcat virtual threads - Update ADR-004 to reflect completed migration - Mark F16 complete in ARCHITECTURE_ANALYSIS.md
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.
Summary
Migrates the codebase to structured concurrency and carrier-thread-safe locking as part of F16.
Changes
SnapshotExecutor.javasynchronized->ReentrantLock, unstructured virtual threads ->StructuredTaskScope.open(Joiner.allSuccessfulOrThrow())SnapshotWorker.javaObjectlock params ->ReentrantLock,synchronized->lock/try/finally/unlockRegionalDataSourceFactory.javaReentrantLock failoverLock,synchronizedmethods -> explicit lockapplication.ymlspring.threads.virtual.enabled: trueADR-004ARCHITECTURE_ANALYSIS.mdWhy
synchronizedblocks pin virtual threads to carrier threads, defeating the purpose of virtual threadsStructuredTaskScopereplaces manualLinkedBlockingQueue+Thread.startVirtualThread()+Thread.join()with structured lifecycle and automatic failure propagationspring.threads.virtual.enabled: trueenables virtual threads for Tomcat HTTP request handlingReactive path deferred
Virtual threads + structured concurrency deliver equivalent resource control to Project Reactor/WebFlux without the servlet->reactive ecosystem migration. Revisited if backpressure becomes a requirement.