Repository navigation
Conversation
…ding When an upgrade fails and handleTransactionException returns MARK_BROKEN, the holder is no longer allowed to upgrade, but the futures of the statuses that are still requested were left incomplete. Anyone waiting on them kept waiting until the ticket was removed, which may never happen if the waiter is the one holding the ticket (e.g. a blocking chunk load). Remember the failure that broke the holder and, whenever a tick finds that a broken holder is asked to upgrade, complete the requested futures above the current status exceptionally with that failure. This also covers tickets added after the holder broke and the forced downgrade after a failed postUpgradeToThis. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XCHZDR58MAQKirDihoKp1M
Contributor
|
Do not submit AI slop. The current behavior is intentional and there's no plan to change this in FlowSched. |
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.
I am currently working on a fork of the Async mod and found a bug when trying to use it with C2ME so i let my Agent write the PR below:
Problem
When a status upgrade fails and
handleTransactionExceptionreturnsMARK_BROKEN(C2ME'sTheChunkSystemalways does), the holder getsFLAG_BROKENandtickHolder0refuses any further upgrade. The futures for the statuses that are still requested are never completed, though. They only complete (withUNLOADED_EXCEPTION) once the ticket is removed and the target drops.So anything that waits on such a future while it also keeps the ticket waits forever. In C2ME that is, for example, a blocking chunk load on the server thread: the original error is logged and reported via
onChunkLoadFailure, but thegetChunkcaller never returns and the server ends up in the watchdog instead of failing with the real cause.The same happens after a failed
postUpgradeToThis: the forced downgrade re-creates the (still requested) future of the downgraded status, and nothing can complete it any more.Reproduction
BrokenItemTestin this PR. Against currentmaster, all four failure cases time out (TimeoutExceptionafter 5 s), while the success control passes:mastertestSuccessfulUpgradeCompletesFuturestestUpgradeFailureFailsRequestedFuturestestTicketAddedAfterBreakFailstestFreshHolderCanRetryAfterUnloadtestPostUpgradeFailureFailsRequestedFuturesHow to reproduce
No Minecraft is needed. The scheduler alone shows it:
ItemStatuswhoseupgradeToThisreturnsCompletable.error(...), and ahandleTransactionExceptionthat returnsMARK_BROKEN(what C2ME does).addTicket(key, target, null), then wait onholder.getFutureForStatus0(target)while keeping the ticket.master, the future never completes. The holder is broken and idle, and the error has been handed tohandleTransactionException. Removing the ticket completes it withUNLOADED_EXCEPTION.To see it with this PR's tests, keep
BrokenItemTest.javaand revert the two main sources tomaster:In a real server, this is reached whenever a chunk status upgrade throws (C2ME logs
Error upgrading chunk ... to ...) while something still waits on that chunk, e.g. a broken worldgen mod or datapack, or a chunk that fails to load. I did not trigger it in a running server. I reproduced it with the actual FlowSched classes shipped in C2ME 0.4.2-alpha.0.106+26.3, using the same steps as above.Fix
ItemHolderremembers the first failure that marked it broken (markBroken(Throwable), which replaces the directsetFlag(FLAG_BROKEN)calls inStatusAdvancingScheduler).tickHolder0finds a broken holder whose target is above its current status, it no longer just returns. It callsfailUnreachableFutures(current), which completes every still-pending future in(current, target]exceptionally with that failure, outside the holder lock (same assetStatusdoes).Because this runs on every tick, it covers the initial failure, tickets added later, and the forced downgrade after a
postUpgradeToThisfailure. Nothing changes for holders that are not broken.The existing future invariants still hold: futures at or below the current status are untouched, failed futures are never
UNLOADED_FUTURE, andflushUnloadedStatusand the downgrade path still replace or flush them as before when the target drops. Once all tickets are gone the broken holder is removed as usual, and a new ticket creates a fresh holder that can retry (covered bytestFreshHolderCanRetryAfterUnload).Effect on C2ME
NewChunkHolderVanillaInterface.wrapOptional*Futurealready handles futures that fail with something other thanUNLOADED_EXCEPTION: it rethrows the cause into the returned vanilla future. With this change, a waiter on a broken chunk gets the original chunk error instead of waiting forever. For a blockinggetChunkthat means a crash report with the real cause, rather than a watchdog kill. Once this is merged, C2ME only needs a FlowSched submodule bump.If you'd rather waiters get
UNLOADED_EXCEPTION(so vanilla seesChunkResult"unloaded" instead of an exception), that's a one-line change infailUnreachableFutures. I went with the original cause because it's more informative and the C2ME wrappers already expect it.Not covered
clearFlag(FLAG_BROKEN)followed by an upgrade would hit the!future.isDone()assertion insetStatus, because the futures were already failed. Nothing in FlowSched or C2ME clears that flag today.Testing
./gradlew test: full suite green (3 runs), andBrokenItemTestalone 20/20 runs green.master.