-
Notifications
You must be signed in to change notification settings - Fork 217
Bug fixes: ungraceful test crash fixes #637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8aa1073
58ba334
a169b4d
0bffb60
200cda0
c1a7c04
c677877
a8341c4
4e91574
328044d
6b08428
c6d3b99
e1cf33e
5a6021e
29012b9
80ec39e
ef1b52e
74a370a
a6d39cf
a68d477
9a6be4c
68869e1
69c2e54
724b3ed
8fe8629
75bec2c
00756be
3cfdb74
40454b6
fc848e6
f19d651
78f194c
9eeadf3
b0fdde1
1770afa
162ee59
b4b7e0f
52b65b6
fb2607a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -383,11 +383,17 @@ impl Display for UtxosChangedSubscription { | |
|
||
impl Drop for UtxosChangedSubscription { | ||
fn drop(&mut self) { | ||
trace!( | ||
"UtxosChangedSubscription: {} in total (drop {})", | ||
UTXOS_CHANGED_SUBSCRIPTIONS.fetch_sub(1, Ordering::SeqCst) - 1, | ||
self | ||
); | ||
// Prevent underflow; [ERROR] thread 'tokio-runtime-worker' panicked at notify/src/subscription/single.rs:388:13: attempt to subtract with overflow | ||
let _ = UTXOS_CHANGED_SUBSCRIPTIONS.fetch_update(Ordering::SeqCst, Ordering::SeqCst, |count| { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if we just did:
Also, I wonder what the root cause of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. afaik saturating_sub only applies to old value from fetch_sub not the atomic itself, so it doesnt prevent actual atomic variable from becoming negative. Suggested fetch_update solution only applies if the value is greater than zero There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
if count > 0 { | ||
Some(count - 1) | ||
} else { | ||
log::warn!("Tried subtracting UtxosChangedSubscription when it's already zero!"); | ||
None | ||
} | ||
}); | ||
|
||
trace!("UtxosChangedSubscription: {} in total (drop {})", UTXOS_CHANGED_SUBSCRIPTIONS.load(Ordering::SeqCst), self); | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,7 +128,7 @@ fn reachability_stretch_test(use_attack_json: bool) { | |
map.get_mut(&blocks[0]).unwrap().parents.push(root); | ||
|
||
// Act | ||
let (_temp_db_lifetime, db) = create_temp_db!(ConnBuilder::default().with_files_limit(10)); | ||
let (_temp_db_lifetime, db) = create_temp_db!(ConnBuilder::default().with_files_limit(10)).unwrap(); | ||
let mut store = DbReachabilityStore::new(db.clone(), CachePolicy::Count(50_000), CachePolicy::Count(50_000)); | ||
let mut relations = DbRelationsStore::new(db, 0, CachePolicy::Count(100_000), CachePolicy::Count(100_000)); // TODO: remove level | ||
let mut builder = DagBuilder::new(&mut store, &mut relations); | ||
|
@@ -955,9 +955,9 @@ async fn json_test(file_path: &str, concurrency: bool) { | |
let notify_service = Arc::new(NotifyService::new(tc.notification_root(), notification_recv, subscription_context.clone())); | ||
|
||
// External storage for storing block bodies. This allows separating header and body processing phases | ||
let (_external_db_lifetime, external_storage) = create_temp_db!(ConnBuilder::default().with_files_limit(10)); | ||
let (_external_db_lifetime, external_storage) = create_temp_db!(ConnBuilder::default().with_files_limit(10)).unwrap(); | ||
let external_block_store = DbBlockTransactionsStore::new(external_storage, CachePolicy::Count(config.perf.block_data_cache_size)); | ||
let (_utxoindex_db_lifetime, utxoindex_db) = create_temp_db!(ConnBuilder::default().with_files_limit(10)); | ||
let (_utxoindex_db_lifetime, utxoindex_db) = create_temp_db!(ConnBuilder::default().with_files_limit(10)).unwrap(); | ||
let consensus_manager = Arc::new(ConsensusManager::new(Arc::new(TestConsensusFactory::new(tc.clone())))); | ||
let utxoindex = UtxoIndex::new(consensus_manager.clone(), utxoindex_db).unwrap(); | ||
let index_service = Arc::new(IndexService::new( | ||
|
@@ -1739,7 +1739,7 @@ async fn staging_consensus_test() { | |
init_allocator_with_default_settings(); | ||
let config = ConfigBuilder::new(MAINNET_PARAMS).build(); | ||
|
||
let db_tempdir = get_kaspa_tempdir(); | ||
let db_tempdir = get_kaspa_tempdir().unwrap(); | ||
let db_path = db_tempdir.path().to_owned(); | ||
let consensus_db_dir = db_path.join("consensus"); | ||
let meta_db_dir = db_path.join("meta"); | ||
|
@@ -1773,6 +1773,7 @@ async fn staging_consensus_test() { | |
|
||
core.shutdown(); | ||
core.join(joins); | ||
drop(consensus_manager); | ||
} | ||
|
||
/// Tests the KIP-10 transaction introspection opcode activation by verifying that: | ||
|
@@ -1826,7 +1827,7 @@ async fn run_kip10_activation_test() { | |
let mut genesis_multiset = MuHash::new(); | ||
consensus.append_imported_pruning_point_utxos(&initial_utxo_collection, &mut genesis_multiset); | ||
consensus.import_pruning_point_utxo_set(config.genesis.hash, genesis_multiset).unwrap(); | ||
consensus.init(); | ||
let wait_handles = consensus.init(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add comments on why this is necessary There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this was done in previous tests as well. pub fn init(&self) -> Vec<JoinHandle<()>> {
self.consensus.run_processors()
} and pub fn shutdown(&mut self) {
self.core.shutdown();
self.join();
} where core is wrapped in Arc, so its reference counted. Without it some background threads might stay running, thought it might be related to getting System File Descriptor problems and not getting /tmp/rusty-kaspa cleanups early. |
||
|
||
// Build blockchain up to one block before activation | ||
let mut index = 0; | ||
|
@@ -1885,6 +1886,8 @@ async fn run_kip10_activation_test() { | |
let status = consensus.add_utxo_valid_block_with_parents((index + 1).into(), vec![index.into()], vec![tx.clone()]).await; | ||
assert!(matches!(status, Ok(BlockStatus::StatusUTXOValid))); | ||
assert!(consensus.lkg_virtual_state.load().accepted_tx_ids.contains(&tx_id)); | ||
consensus.shutdown(wait_handles); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here and the rest of similar changes: Add comments on why this is necessary. |
||
drop(consensus); | ||
} | ||
|
||
#[tokio::test] | ||
|
@@ -1981,7 +1984,7 @@ async fn payload_activation_test() { | |
let mut genesis_multiset = MuHash::new(); | ||
consensus.append_imported_pruning_point_utxos(&initial_utxo_collection, &mut genesis_multiset); | ||
consensus.import_pruning_point_utxo_set(config.genesis.hash, genesis_multiset).unwrap(); | ||
consensus.init(); | ||
let wait_handles = consensus.init(); | ||
|
||
// Build blockchain up to one block before activation | ||
let mut index = 0; | ||
|
@@ -2048,6 +2051,8 @@ async fn payload_activation_test() { | |
|
||
assert!(matches!(status, Ok(BlockStatus::StatusUTXOValid))); | ||
assert!(consensus.lkg_virtual_state.load().accepted_tx_ids.contains(&tx_id)); | ||
consensus.shutdown(wait_handles); | ||
drop(consensus); | ||
} | ||
|
||
#[tokio::test] | ||
|
@@ -2114,7 +2119,7 @@ async fn runtime_sig_op_counting_test() { | |
let mut genesis_multiset = MuHash::new(); | ||
consensus.append_imported_pruning_point_utxos(&initial_utxo_collection, &mut genesis_multiset); | ||
consensus.import_pruning_point_utxo_set(config.genesis.hash, genesis_multiset).unwrap(); | ||
consensus.init(); | ||
let wait_handles = consensus.init(); | ||
|
||
// Build blockchain up to one block before activation | ||
let mut index = 0; | ||
|
@@ -2184,4 +2189,6 @@ async fn runtime_sig_op_counting_test() { | |
// Test 2: After activation, tx should be accepted as runtime counting only sees 1 executed sig op | ||
let status = consensus.add_utxo_valid_block_with_parents((index + 1).into(), vec![index.into()], vec![tx]).await; | ||
assert!(matches!(status, Ok(BlockStatus::StatusUTXOValid))); | ||
consensus.shutdown(wait_handles); | ||
drop(consensus); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We moved away from
test
and switched to usingnextest
. But I do wonder why nextest doesn't capture the errors that test is displaying here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cargo test
still shows tests failing that nextest does not, so what is a recommended solution?