mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-01 14:24:23 +01:00
reset internal states on rollback
This commit is contained in:
@@ -204,7 +204,7 @@ impl DumbLruPageCache {
|
||||
|
||||
if clean_page {
|
||||
entry_mut.page.clear_loaded();
|
||||
debug!("cleaning up page {}", entry_mut.page.get().id);
|
||||
debug!("clean(page={})", entry_mut.page.get().id);
|
||||
let _ = entry_mut.page.get().contents.take();
|
||||
}
|
||||
self.unlink(entry);
|
||||
|
||||
@@ -1014,7 +1014,10 @@ impl Pager {
|
||||
let page = {
|
||||
let mut cache = self.page_cache.write();
|
||||
let page_key = PageCacheKey::new(page_id);
|
||||
let page = cache.get(&page_key).expect("we somehow added a page to dirty list but we didn't mark it as dirty, causing cache to drop it.");
|
||||
let page = cache.get(&page_key).expect(&format!(
|
||||
"we somehow added a page to dirty list but we didn't mark it as dirty, causing cache to drop it. page={}",
|
||||
page_id
|
||||
));
|
||||
let page_type = page.get().contents.as_ref().unwrap().maybe_page_type();
|
||||
trace!(
|
||||
"commit_dirty_pages(page={}, page_type={:?}",
|
||||
@@ -1528,6 +1531,9 @@ impl Pager {
|
||||
tracing::debug!(schema_did_change);
|
||||
self.dirty_pages.borrow_mut().clear();
|
||||
let mut cache = self.page_cache.write();
|
||||
|
||||
self.reset_internal_states();
|
||||
|
||||
cache.unset_dirty_all_pages();
|
||||
cache.clear().expect("failed to clear page cache");
|
||||
if schema_did_change {
|
||||
@@ -1537,6 +1543,17 @@ impl Pager {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn reset_internal_states(&self) {
|
||||
self.checkpoint_state.replace(CheckpointState::Checkpoint);
|
||||
self.checkpoint_inflight.replace(0);
|
||||
self.syncing.replace(false);
|
||||
self.flush_info.replace(FlushInfo {
|
||||
state: FlushState::Start,
|
||||
in_flight_writes: Rc::new(RefCell::new(0)),
|
||||
dirty_pages: Vec::new(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
pub fn allocate_page(page_id: usize, buffer_pool: &Arc<BufferPool>, offset: usize) -> PageRef {
|
||||
|
||||
@@ -1038,6 +1038,7 @@ impl Wal for WalFile {
|
||||
}
|
||||
self.last_checksum = shared.last_checksum;
|
||||
}
|
||||
self.reset_internal_states();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1128,6 +1129,12 @@ impl WalFile {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn reset_internal_states(&self) {
|
||||
self.sync_state.set(SyncState::NotSyncing);
|
||||
self.syncing.set(false);
|
||||
self.ongoing_checkpoint.state = CheckpointState::Start;
|
||||
}
|
||||
}
|
||||
|
||||
impl WalFileShared {
|
||||
|
||||
Reference in New Issue
Block a user