small fixes

This commit is contained in:
Nikita Sivukhin
2025-09-17 19:20:42 +04:00
parent 93e4dfbd69
commit c1176356f7
2 changed files with 14 additions and 7 deletions

View File

@@ -1956,7 +1956,7 @@ impl WalFile {
return_if_io!(self.truncate_log());
}
if mode.should_restart_log() {
Self::unlock(&self.shared, None);
Self::unlock_after_restart(&self.shared, None);
}
let mut checkpoint_result = {
let CheckpointState::Truncate {
@@ -2129,7 +2129,10 @@ impl WalFile {
let shared = self.shared.clone();
move |result| {
if let Err(err) = result {
Self::unlock(&shared, Some(&LimboError::InternalError(err.to_string())));
Self::unlock_after_restart(
&shared,
Some(&LimboError::InternalError(err.to_string())),
);
} else {
tracing::trace!("WAL file truncated to 0 B");
}
@@ -2137,7 +2140,7 @@ impl WalFile {
});
let c = file
.truncate(0, c)
.inspect_err(|e| Self::unlock(&self.shared, Some(e)))?;
.inspect_err(|e| Self::unlock_after_restart(&self.shared, Some(e)))?;
*truncate_sent = true;
io_yield_one!(c);
} else if !*sync_sent {
@@ -2145,19 +2148,23 @@ impl WalFile {
let c = file
.sync(Completion::new_sync(move |result| {
if let Err(err) = result {
Self::unlock(&shared, Some(&LimboError::InternalError(err.to_string())));
Self::unlock_after_restart(
&shared,
Some(&LimboError::InternalError(err.to_string())),
);
} else {
tracing::trace!("WAL file synced after reset/truncation");
}
}))
.inspect_err(|e| Self::unlock(&self.shared, Some(e)))?;
.inspect_err(|e| Self::unlock_after_restart(&self.shared, Some(e)))?;
*sync_sent = true;
io_yield_one!(c);
}
Ok(IOResult::Done(()))
}
fn unlock(shared: &Arc<RwLock<WalFileShared>>, e: Option<&LimboError>) {
// unlock shared read locks taken by RESTART/TRUNCATE checkpoint modes
fn unlock_after_restart(shared: &Arc<RwLock<WalFileShared>>, e: Option<&LimboError>) {
// release all read locks we just acquired, the caller will take care of the others
let shared = shared.write();
for idx in 1..shared.read_locks.len() {

View File

@@ -23,7 +23,7 @@ fn test_schema_reprepare() {
assert_eq!(err.to_string(), "Parse error: no such column: x");
break;
}
r => panic!("unexpected response: {:?}", r),
r => panic!("unexpected response: {r:?}"),
}
}