mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-08 17:54:22 +01:00
panic on corruption
This commit is contained in:
@@ -2534,6 +2534,7 @@ impl BTreeCursor {
|
||||
// Let's now make a in depth check that we in fact added all possible cells somewhere and they are not lost
|
||||
for (page_idx, page) in pages_to_balance_new.iter().enumerate() {
|
||||
let contents = page.get_contents();
|
||||
debug_validate_cells!(contents, self.usable_space() as u16);
|
||||
// Cells are distributed in order
|
||||
for cell_idx in 0..contents.cell_count() {
|
||||
let (cell_start, cell_len) = contents.cell_get_raw_region(
|
||||
@@ -4370,7 +4371,11 @@ fn free_cell_range(
|
||||
}
|
||||
}
|
||||
if removed_fragmentation > page.num_frag_free_bytes() {
|
||||
return_corrupt!("Invalid fragmentation count");
|
||||
return_corrupt!(format!(
|
||||
"Invalid fragmentation count. Had {} and removed {}",
|
||||
page.num_frag_free_bytes(),
|
||||
removed_fragmentation
|
||||
));
|
||||
}
|
||||
let frag = page.num_frag_free_bytes() - removed_fragmentation;
|
||||
page.write_u8(PAGE_HEADER_OFFSET_FRAGMENTED_BYTES_COUNT, frag);
|
||||
|
||||
@@ -4,6 +4,7 @@ use anarchist_readable_name_generator_lib::readable_name_custom;
|
||||
use antithesis_sdk::random::{get_random, AntithesisRng};
|
||||
use antithesis_sdk::*;
|
||||
use clap::Parser;
|
||||
use core::panic;
|
||||
use hex;
|
||||
use limbo::Builder;
|
||||
use opts::Opts;
|
||||
@@ -417,7 +418,16 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||
for stmt in &plan.ddl_statements {
|
||||
println!("executing ddl {}", stmt);
|
||||
if let Err(e) = conn.execute(stmt, ()).await {
|
||||
println!("Error creating table: {}", e);
|
||||
match e {
|
||||
limbo::Error::SqlExecutionFailure(e) => {
|
||||
if e.contains("Corrupt database") {
|
||||
panic!("Error creating table: {}", e);
|
||||
} else {
|
||||
println!("Error creating table: {}", e);
|
||||
}
|
||||
}
|
||||
_ => panic!("Error creating table: {}", e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -430,7 +440,16 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||
let sql = &plan.queries_per_thread[thread][query_index];
|
||||
println!("executing: {}", sql);
|
||||
if let Err(e) = conn.execute(&sql, ()).await {
|
||||
println!("Error: {}", e);
|
||||
match e {
|
||||
limbo::Error::SqlExecutionFailure(e) => {
|
||||
if e.contains("Corrupt database") {
|
||||
panic!("Error executing query: {}", e);
|
||||
} else {
|
||||
println!("Error executing query: {}", e);
|
||||
}
|
||||
}
|
||||
_ => panic!("Error executing query: {}", e),
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok::<_, Box<dyn std::error::Error + Send + Sync>>(())
|
||||
|
||||
Reference in New Issue
Block a user