Skip to content

Commit bf998db

Browse files
goffrieConvex, Inc.
authored andcommitted
Drop shapes for deleted tables (#43098)
GitOrigin-RevId: b7ddac45e773287f1681ae0b94f9aa91245c99b8
1 parent bad3a91 commit bf998db

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

crates/database/src/table_summary.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ use std::{
66
};
77

88
use common::{
9+
bootstrap_model::tables::{
10+
TableMetadata,
11+
TableState,
12+
},
13+
document::{
14+
ParseDocument,
15+
ParsedDocument,
16+
},
917
json::JsonForm,
1018
persistence::{
1119
new_static_repeatable_recent,
@@ -547,6 +555,19 @@ fn add_revision(
547555
},
548556
_ => {},
549557
}
558+
if let Some(new_doc) = revision_pair.document() {
559+
let table_metadata: ParsedDocument<TableMetadata> = new_doc.parse()?;
560+
if table_metadata.state == TableState::Deleting {
561+
// Hax alert! Remove shape tracking from soft-deleted tables'
562+
// summaries, to prevent old shapes from filling up the overall
563+
// table summary object.
564+
// It's not correct to remove the summary entry entirely because
565+
// we still want to be able to rewind through this revision.
566+
if let Some(summary) = tables.get_mut(&tablet_id) {
567+
summary.reset_shape();
568+
}
569+
}
570+
}
550571
}
551572
let id = &revision_pair.id;
552573
let summary = tables.entry(id.table()).or_insert_with(

0 commit comments

Comments
 (0)