Skip to content
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

Fix false positive in check_integrity() #844

Merged
merged 1 commit into from
Aug 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,8 @@ impl Database {
transaction_id,
false,
true,
// don't trim the database file, because we want the allocator hash to match exactly
false,
)?;

Ok(())
Expand Down
1 change: 1 addition & 0 deletions src/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,7 @@ impl WriteTransaction {
self.transaction_id,
eventual,
two_phase,
true,
)?;

// Mark any pending non-durable commits as fully committed.
Expand Down
12 changes: 11 additions & 1 deletion src/tree_store/page_store/page_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ impl TransactionalMemory {
}

// Commit all outstanding changes and make them visible as the primary
#[allow(clippy::too_many_arguments)]
pub(crate) fn commit(
&self,
data_root: Option<BtreeHeader>,
Expand All @@ -464,6 +465,7 @@ impl TransactionalMemory {
transaction_id: TransactionId,
eventual: bool,
two_phase: bool,
allow_trim: bool,
) -> Result {
let result = self.commit_inner(
data_root,
Expand All @@ -472,13 +474,15 @@ impl TransactionalMemory {
transaction_id,
eventual,
two_phase,
allow_trim,
);
if result.is_err() {
self.needs_recovery.store(true, Ordering::Release);
}
result
}

#[allow(clippy::too_many_arguments)]
fn commit_inner(
&self,
data_root: Option<BtreeHeader>,
Expand All @@ -487,6 +491,7 @@ impl TransactionalMemory {
transaction_id: TransactionId,
eventual: bool,
two_phase: bool,
allow_trim: bool,
) -> Result {
// All mutable pages must be dropped, this ensures that when a transaction completes
// no more writes can happen to the pages it allocated. Thus it is safe to make them visible
Expand All @@ -497,7 +502,11 @@ impl TransactionalMemory {

let mut state = self.state.lock().unwrap();
// Trim surplus file space, before finalizing the commit
let shrunk = self.try_shrink(&mut state)?;
let shrunk = if allow_trim {
self.try_shrink(&mut state)?
} else {
false
};
// Copy the header so that we can release the state lock, while we flush the file
let mut header = state.header.clone();
drop(state);
Expand Down Expand Up @@ -1023,6 +1032,7 @@ impl Drop for TransactionalMemory {
non_durable_transaction_id,
false,
true,
true,
)
.is_err()
{
Expand Down
Loading