-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Having Watch() and Changes() separately in ChangeIterator may lead to inconsistent usage when change iteration is combined with a write transaction: var changes statedb.ChangeIterator[someObject] wtxn := db.WriteTxn(someTable) for change := range changes { // changes are reflecting the state of objects coming from the previous // Watch(db.ReadTxn()) call below, not the state they're in "wtxn" someTable.Insert(...) } select { case <-changes.Watch(db.ReadTxn()) } The new API makes it easier to be consistent and use the same transaction for the changes and for the writes: var changeIterator statedb.ChangeIterator[someObject] wtxn := db.WriteTxn(someTable) // Give me the unobserved changes up to the "snapshot" of wtxn changes, watch := changeIterator.Next(wtxn) for change := range changes { // changes are reflecting the state of objects coming from the previous // Watch(db.ReadTxn()) call below, not the state they're in "wtxn" someTable.Insert(...) } select { case <-watch: } If the transaction given to Next() is a WriteTxn it will still use the snapshot of committed data for producing the iterator and will ignore the uncommitted data in the transaction. This is needed as the txn might be aborted, which would then reset the revision back and that would mess up the graveyard watermarks as the marked revision would be in the future. Signed-off-by: Jussi Maki <[email protected]>
- Loading branch information
Showing
13 changed files
with
242 additions
and
164 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.