-
Notifications
You must be signed in to change notification settings - Fork 618
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(mirror): fix a crash in the mirror traffic generator (#12168)
In queue_block(), we lock the TxTracker struct and add some data to it related to the current block's worth of transactions we're queuing. This includes references to transactions that will be queued to the tx_block_queue passed to that function. But we actually add these to the tx_block_queue only after we release the lock on the TxTracker, so another thread that's waiting for that lock might start looking through it and trying to find the transactions whose references were added to the TxTracker in queue_block(), but before these blocks get added to the tx_block_queue. This leads to a possible crash in get_tx() if we try to look up one of these transactions: ``` thread 'actix-rt|system:0|arbiter:0' panicked at tools/mirror/src/chain_tracker.rs:366:14: called `Result::unwrap()` on an `Err` value: 100 stack backtrace: 0: rust_begin_unwind 1: core::panicking::panic_fmt 2: core::result::unwrap_failed 3: near_mirror::chain_tracker::TxTracker::get_tx 4: near_mirror::chain_tracker::TxTracker::try_set_nonces ``` We can fix it by keeping the lock on the TxTracker until after we queue this new batch of transactions onto the tx_block_queue. This is a more involved change than it would seem, because we can't hold the lock across await points, and so we need to add some logic to do the async operations before we take the lock. In the end we get logic here that is closer to what it looked like before #11916. In the future it would make things simpler to move the tx_block_queue back into the TxTracker, but for now this should work
- Loading branch information
1 parent
2b882c8
commit a9bf310
Showing
2 changed files
with
106 additions
and
89 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