fix seal issue

This commit is contained in:
Peter Zhang 2025-11-26 21:20:36 +08:00
parent 5a94554799
commit 1480d85603
2 changed files with 13 additions and 12 deletions

View File

@ -263,12 +263,15 @@ impl FlowWrite for FlowStore {
)?;
if self.seal_manager.seal_worker_available() && batch.is_complete() {
for seal_index in 0..SEALS_PER_LOAD {
// Only add seals that are not already sealed
if !batch.is_seal_sealed(seal_index as u16) {
to_seal_set.insert(
chunk_index as usize * SEALS_PER_LOAD + seal_index,
self.seal_manager.to_seal_version(),
);
}
}
}
batch_list.push((chunk_index, batch));
}
@ -391,23 +394,17 @@ pub struct PadPair {
pub struct FlowDBStore {
kvdb: Arc<dyn ZgsKeyValueDB>,
// Mutex to prevent race condition between put_entry_batch_list and put_entry_raw
write_mutex: Mutex<()>,
}
impl FlowDBStore {
pub fn new(kvdb: Arc<dyn ZgsKeyValueDB>) -> Self {
Self {
kvdb,
write_mutex: Mutex::new(()),
}
Self { kvdb }
}
fn put_entry_batch_list(
&self,
batch_list: Vec<(u64, EntryBatch)>,
) -> Result<Vec<(u64, DataRoot)>> {
let _lock = self.write_mutex.lock();
let start_time = Instant::now();
let mut completed_batches = Vec::new();
let mut tx = self.kvdb.transaction();
@ -429,7 +426,6 @@ impl FlowDBStore {
}
fn put_entry_raw(&self, batch_list: Vec<(u64, EntryBatch)>) -> Result<()> {
let _lock = self.write_mutex.lock();
let mut tx = self.kvdb.transaction();
for (batch_index, batch) in batch_list {
tx.put(

View File

@ -71,6 +71,11 @@ impl EntryBatch {
pub fn is_complete(&self) -> bool {
matches!(self.data, EntryBatchData::Complete(_))
}
/// Check if a specific seal is already sealed
pub fn is_seal_sealed(&self, seal_index: u16) -> bool {
self.seal.is_sealed(seal_index)
}
}
impl EntryBatch {