Add LARGEST_CONFIRMED_ROOT_UPLOAD_DELAY
This commit is contained in:
		
				
					committed by
					
						![mergify[bot]](/avatar/e3df20cd7a67969c41a65f03bea54961?size=40) mergify[bot]
						mergify[bot]
					
				
			
			
				
	
			
			
			
						parent
						
							67daa6f01e
						
					
				
				
					commit
					a018d78056
				
			| @@ -7,6 +7,14 @@ use std::{ | |||||||
| }; | }; | ||||||
| use tokio::runtime; | use tokio::runtime; | ||||||
|  |  | ||||||
|  | // Delay uploading the largest confirmed root for this many slots.  This is done in an attempt to | ||||||
|  | // ensure that the `CacheBlockTimeService` has had enough time to add the block time for the root | ||||||
|  | // before it's uploaded to BigTable. | ||||||
|  | // | ||||||
|  | // A more direct connection between CacheBlockTimeService and BigTableUploadService would be | ||||||
|  | // preferable... | ||||||
|  | const LARGEST_CONFIRMED_ROOT_UPLOAD_DELAY: usize = 100; | ||||||
|  |  | ||||||
| pub struct BigTableUploadService { | pub struct BigTableUploadService { | ||||||
|     thread: JoinHandle<()>, |     thread: JoinHandle<()>, | ||||||
| } | } | ||||||
| @@ -43,18 +51,19 @@ impl BigTableUploadService { | |||||||
|         block_commitment_cache: Arc<RwLock<BlockCommitmentCache>>, |         block_commitment_cache: Arc<RwLock<BlockCommitmentCache>>, | ||||||
|         exit: Arc<AtomicBool>, |         exit: Arc<AtomicBool>, | ||||||
|     ) { |     ) { | ||||||
|         let mut starting_slot = 0; |         let mut start_slot = 0; | ||||||
|         loop { |         loop { | ||||||
|             if exit.load(Ordering::Relaxed) { |             if exit.load(Ordering::Relaxed) { | ||||||
|                 break; |                 break; | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             let largest_confirmed_root = block_commitment_cache |             let end_slot = block_commitment_cache | ||||||
|                 .read() |                 .read() | ||||||
|                 .unwrap() |                 .unwrap() | ||||||
|                 .largest_confirmed_root(); |                 .largest_confirmed_root() | ||||||
|  |                 .saturating_sub(LARGEST_CONFIRMED_ROOT_UPLOAD_DELAY as u64); | ||||||
|  |  | ||||||
|             if largest_confirmed_root == starting_slot { |             if end_slot <= start_slot { | ||||||
|                 std::thread::sleep(std::time::Duration::from_secs(1)); |                 std::thread::sleep(std::time::Duration::from_secs(1)); | ||||||
|                 continue; |                 continue; | ||||||
|             } |             } | ||||||
| @@ -62,14 +71,14 @@ impl BigTableUploadService { | |||||||
|             let result = runtime.block_on(solana_ledger::bigtable_upload::upload_confirmed_blocks( |             let result = runtime.block_on(solana_ledger::bigtable_upload::upload_confirmed_blocks( | ||||||
|                 blockstore.clone(), |                 blockstore.clone(), | ||||||
|                 bigtable_ledger_storage.clone(), |                 bigtable_ledger_storage.clone(), | ||||||
|                 starting_slot, |                 start_slot, | ||||||
|                 Some(largest_confirmed_root), |                 Some(end_slot), | ||||||
|                 true, |                 true, | ||||||
|                 exit.clone(), |                 exit.clone(), | ||||||
|             )); |             )); | ||||||
|  |  | ||||||
|             match result { |             match result { | ||||||
|                 Ok(()) => starting_slot = largest_confirmed_root, |                 Ok(()) => start_slot = end_slot, | ||||||
|                 Err(err) => { |                 Err(err) => { | ||||||
|                     warn!("bigtable: upload_confirmed_blocks: {}", err); |                     warn!("bigtable: upload_confirmed_blocks: {}", err); | ||||||
|                     std::thread::sleep(std::time::Duration::from_secs(2)); |                     std::thread::sleep(std::time::Duration::from_secs(2)); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user