Skip to content

Commit a4ee72f

Browse files
committed
Assert that the table invariant is preserved
1 parent ab47e02 commit a4ee72f

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/storage-client/src/storage_collections.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,6 +1286,35 @@ where
12861286
.send(BackgroundCmd::DowngradeSince(persist_compaction_commands))
12871287
.expect("cannot fail to send");
12881288
}
1289+
1290+
// Assert table invariants
1291+
for (id, state) in &*collections {
1292+
match &state.description.data_source {
1293+
DataSource::Table {
1294+
primary: Some(mut primary_id),
1295+
} => {
1296+
let primary = loop {
1297+
let primary = collections.get(&primary_id).expect("must still exist");
1298+
if let DataSource::Table {
1299+
primary: Some(other),
1300+
} = &primary.description.data_source
1301+
{
1302+
primary_id = *other;
1303+
} else {
1304+
break primary;
1305+
}
1306+
};
1307+
assert!(
1308+
PartialOrder::less_equal(
1309+
&primary.read_capabilities.frontier(),
1310+
&state.read_capabilities.frontier(),
1311+
),
1312+
"primary ({primary_id}) since must be held back at least as much as secondary ({id})"
1313+
)
1314+
}
1315+
_ => {}
1316+
}
1317+
}
12891318
}
12901319

12911320
/// Remove any shards that we know are finalized

0 commit comments

Comments
 (0)