feat(ext-api): ChunkFileManager/Sink closeAsync — no all.get(10min)#1307
Merged
Conversation
…async manifest write
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Owner
Author
|
@codex review |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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
Converts the 10-minute hard blocking
all.get(600_000L, TimeUnit.MILLISECONDS)inChunkFileManager.awaitAllUploadsto an async CF chain. AddscloseAsync()toChunkedSnapshotSinkthat chains shutdown → await uploads → write manifest → publish event viathenCompose/whenComplete. Migrates all 3 callers (RankingFetchPhase, CharacterBasicFetchPhase, ItemEquipmentFetchPhase) to the async API. Syncclose()kept as@Deprecatedshim for legacy callers.Audit Reference
docs/05_Reports/2026-06-18-blocking-audit.mdline 69 (HIGH site:module-external-api/snapshot/ChunkFileManager.kt:132). This PR addresses Sub-PR 4 from the recommended path forward.Changes (2 commits)
module-external-api/snapshot/ChunkFileManager.ktawaitAllUploadsAsync(timeoutMs): CF<Boolean>— returns immediately; chains via.orTimeout()+.exceptionally { false }DEFAULT_AWAIT_TIMEOUT_MSconst valawaitAllUploadsunchanged (no callers use it after migration, but kept as documented compat)module-external-api/snapshot/ChunkedSnapshotSink.ktcloseAsync(): CF<Void>— chains shutdown → writer termination → upload await → manifest write → run event viathenComposecloseAsyncExecutor(single-thread VT) to avoid deadlock with the writer executorclose()marked@Deprecated(body unchanged)closeAsync().whenComplete { ... }3 caller migrations
.whenComplete { _, ex -> sink.close() }→.thenCompose { sink.closeAsync() }.whenComplete { _, ex -> ... }try { ... } finally { sink.close() }, chainedsink.closeAsync()after theCoroutineScope.future { }completesCI gate extension
ExtApiBlockingPrimitiveGateTestnow also walkssnapshot/(was:runstatus/+scheduler/)New test
ChunkFileManagerAsyncTest: 2 tests verifyingawaitAllUploadsAsyncreturns CF immediately (no blocking) and completes correctly with no in-flight uploadsVerification
./gradlew compileKotlin compileJava --continue— cleanImplementation notes
closeAsyncinitially usedwriterExecutorfor the close-signal enqueue andawaitTermination. Since the writer thread is blocked inqueue.take()waiting for the close signal on the SAME single-thread executor, this deadlocks. Added a dedicatedExecutors.newSingleThreadExecutor(snapshot-close-async-$endpoint) for the close-path work; both executors are shutdown inwhenComplete.thenCompose { sink.closeAsync() }(no.join()) so the CI grep gate stays green —.join()on a CF is a blocking primitive, even inside a coroutinefuture { }adapter. ThethenComposechain runs the close work asynchronously on the closeAsyncExecutor.thenComposelambda — the manifest is a small JSON object (single PUT), and keeping it sync preserves the ordering guarantee without introducing an extra executor hop.