Skip to content

Commit 388aef0

Browse files
emmaling27Convex, Inc.
authored andcommitted
Move schema validation progress table and model to bootstrap_model (#40572)
Moves `_schema_validation_progress` table and model to `bootstrap_model` so that we can delete documents in `_schema_validation_progress` atomically in `SchemaModel::mark_failed` and `SchemaModel::mark_validated`. GitOrigin-RevId: 954691071c2e01fa624166fa92d27823a1c06538
1 parent 08b1037 commit 388aef0

File tree

7 files changed

+31
-13
lines changed

7 files changed

+31
-13
lines changed

crates/database/src/bootstrap_model/defaults.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ use crate::{
3838
index_backfills::IndexBackfillTable,
3939
index_workers::IndexWorkerMetadataTable,
4040
schema::SchemasTable,
41+
schema_validation_progress::{
42+
SchemaValidationProgressTable,
43+
SCHEMA_VALIDATION_PROGRESS_TABLE,
44+
},
4145
table::TablesTable,
4246
},
4347
system_tables::ErasedSystemTable,
@@ -58,6 +62,7 @@ pub fn bootstrap_system_tables() -> Vec<&'static dyn ErasedSystemTable> {
5862
&IndexWorkerMetadataTable,
5963
&ComponentDefinitionsTable,
6064
&ComponentsTable,
65+
&SchemaValidationProgressTable,
6166
]
6267
}
6368

@@ -72,6 +77,7 @@ pub static DEFAULT_BOOTSTRAP_TABLE_NUMBERS: LazyLock<BTreeMap<TableName, TableNu
7277
COMPONENT_DEFINITIONS_TABLE.clone() => tn(31),
7378
COMPONENTS_TABLE.clone() => tn(32),
7479
INDEX_BACKFILLS_TABLE.clone() => tn(36),
80+
SCHEMA_VALIDATION_PROGRESS_TABLE.clone() => tn(37)
7581
// To add a bootstrap system table, first add to model/src/lib and then
7682
// replicate that table number to here.
7783
}

crates/database/src/bootstrap_model/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ pub mod index;
99
pub mod index_backfills;
1010
pub mod index_workers;
1111
pub mod schema;
12+
pub mod schema_validation_progress;
1213
pub mod system_metadata;
1314
pub mod table;
1415
pub mod user_facing;

crates/model/src/schema_validation_progress/mod.rs renamed to crates/database/src/bootstrap_model/schema_validation_progress/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@ pub mod types;
33
use std::sync::LazyLock;
44

55
use common::document::CREATION_TIME_FIELD_PATH;
6-
use database::system_tables::{
7-
SystemIndex,
8-
SystemTable,
9-
};
106
use value::{
117
FieldPath,
128
TableName,
139
};
1410

11+
use crate::system_tables::{
12+
SystemIndex,
13+
SystemTable,
14+
};
15+
1516
pub static SCHEMA_VALIDATION_PROGRESS_TABLE: LazyLock<TableName> = LazyLock::new(|| {
1617
"_schema_validation_progress"
1718
.parse()

crates/database/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,12 @@ pub use self::{
136136
SCHEMAS_TABLE,
137137
SCHEMA_STATE_FIELD,
138138
},
139+
schema_validation_progress::{
140+
types::SchemaValidationProgressMetadata,
141+
SchemaValidationProgressTable,
142+
SCHEMA_VALIDATION_PROGRESS_BY_SCHEMA_ID,
143+
SCHEMA_VALIDATION_PROGRESS_TABLE,
144+
},
139145
system_metadata::SystemMetadataModel,
140146
table::{
141147
TableModel,

crates/model/src/components/config.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ use database::{
2828
IndexModel,
2929
SchemaDiff,
3030
SchemaModel,
31+
SchemaValidationProgressTable,
3132
SchemasTable,
3233
SerializedSchemaDiff,
3334
SystemMetadataModel,
@@ -372,6 +373,13 @@ impl<'a, RT: Runtime> ComponentConfigModel<'a, RT> {
372373
&DEFAULT_TABLE_NUMBERS,
373374
)
374375
.await?;
376+
initialize_application_system_table(
377+
self.tx,
378+
&SchemaValidationProgressTable,
379+
component_id.into(),
380+
&DEFAULT_TABLE_NUMBERS,
381+
)
382+
.await?;
375383
for table in component_system_tables() {
376384
initialize_application_system_table(
377385
self.tx,

crates/model/src/lib.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ use database::{
9797
IndexModel,
9898
IndexTable,
9999
IndexWorkerMetadataTable,
100+
SchemaValidationProgressTable,
100101
SchemasTable,
101102
TablesTable,
102103
Transaction,
@@ -110,6 +111,8 @@ use database::{
110111
NUM_RESERVED_LEGACY_TABLE_NUMBERS,
111112
SCHEMAS_STATE_INDEX,
112113
SCHEMAS_TABLE,
114+
SCHEMA_VALIDATION_PROGRESS_BY_SCHEMA_ID,
115+
SCHEMA_VALIDATION_PROGRESS_TABLE,
113116
TABLES_BY_NAME_INDEX,
114117
};
115118
use database_globals::{
@@ -197,11 +200,6 @@ use crate::{
197200
exports::ExportsTable,
198201
external_packages::EXTERNAL_PACKAGES_TABLE,
199202
log_sinks::LOG_SINKS_TABLE,
200-
schema_validation_progress::{
201-
SchemaValidationProgressTable,
202-
SCHEMA_VALIDATION_PROGRESS_BY_SCHEMA_ID,
203-
SCHEMA_VALIDATION_PROGRESS_TABLE,
204-
},
205203
};
206204

207205
pub mod airbyte_import;
@@ -225,7 +223,6 @@ mod metrics;
225223
pub mod migrations;
226224
pub mod modules;
227225
pub mod scheduled_jobs;
228-
pub mod schema_validation_progress;
229226
pub mod session_requests;
230227
pub mod snapshot_imports;
231228
pub mod source_packages;
@@ -551,8 +548,8 @@ pub fn app_system_tables() -> Vec<&'static dyn ErasedSystemTable> {
551548
system_tables
552549
}
553550

554-
/// NOTE: Does not include _schemas because that's not an app system table,
555-
/// but it is created for each component.
551+
/// NOTE: Does not include _schemas or _schema_validation_progress because they
552+
/// are in bootstrapped system tables, but they are created for each component.
556553
pub fn component_system_tables() -> Vec<&'static dyn ErasedSystemTable> {
557554
vec![
558555
&FileStorageTable,
@@ -563,7 +560,6 @@ pub fn component_system_tables() -> Vec<&'static dyn ErasedSystemTable> {
563560
&ModulesTable,
564561
&UdfConfigTable,
565562
&SourcePackagesTable,
566-
&SchemaValidationProgressTable,
567563
]
568564
}
569565

0 commit comments

Comments
 (0)