Fix concurrent modification errors when serializing item/fluid storage off-thread - #63
Open
andriihorpenko wants to merge 1 commit into
Open
Fix concurrent modification errors when serializing item/fluid storage off-thread#63andriihorpenko wants to merge 1 commit into
andriihorpenko wants to merge 1 commit into
Conversation
Member
|
yeah, I know it. I cannot say that it was designed as it. but crash on a thread is currently allowed. and re-sync during next run of this thread. Because I want to reduce the cost and still maintain correctness. Currently, we may occasionally fail to retrieve the latest state, but eventually (usually in the next run), it will be retrieved. However, if copying is used, the same problem will still occur because the copy may also read the incorrect value. This is not a correct solution. I know that annoying log errors, and I'm also thinking about how to deal with it. I will keep this reminder to alert me of certain matters that require attention. Thank you |
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.
Description
With
ISyncPersistRPCBlockEntity.useAsyncThread()returning true, every managed block entity runspassivelySync()on LDLib async thread every 50ms.Dirty-checking a
@Persisted/@DescSynced INBTSerializablefield serializes it in full, while the server thread is mutating the same storage.Solution
Copy into a local first so the empty check and the encode see the same value.
ItemStackTransferneeds a new override because the racy implementation is NeoForge's. Output NBT is unchanged.Observed issues
Issue №1 - Fluid handler
Issue №2 - Item handler