Skip to content

Commit 74f4bd5

Browse files
committed
adapter: rename controller_commands to catalog_implications
Better describes what it does, because the implications are not just for the controllers.
1 parent 037b0b9 commit 74f4bd5

File tree

10 files changed

+236
-229
lines changed

10 files changed

+236
-229
lines changed

src/adapter/src/catalog.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ pub use crate::catalog::transact::{
9898
use crate::command::CatalogDump;
9999
use crate::coord::TargetCluster;
100100
#[cfg(test)]
101-
use crate::coord::controller_commands::parsed_state_updates::ParsedStateUpdate;
101+
use crate::coord::catalog_implications::parsed_state_updates::ParsedStateUpdate;
102102
use crate::session::{Portal, PreparedStatement, Session};
103103
use crate::util::ResultExt;
104104
use crate::{AdapterError, AdapterNotice, ExecuteResponse};
@@ -1519,9 +1519,8 @@ impl Catalog {
15191519
CatalogError,
15201520
> {
15211521
let updates = self.storage().await.sync_to_current_updates().await?;
1522-
let (builtin_table_updates, controller_state_updates) =
1523-
self.state.apply_updates(updates)?;
1524-
Ok((builtin_table_updates, controller_state_updates))
1522+
let (builtin_table_updates, catalog_updates) = self.state.apply_updates(updates)?;
1523+
Ok((builtin_table_updates, catalog_updates))
15251524
}
15261525
}
15271526

src/adapter/src/catalog/apply.rs

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ use tracing::{Instrument, info_span, warn};
6262
use crate::AdapterError;
6363
use crate::catalog::state::LocalExpressionCache;
6464
use crate::catalog::{BuiltinTableUpdate, CatalogState};
65-
use crate::coord::controller_commands::parsed_state_updates::{self, ParsedStateUpdate};
65+
use crate::coord::catalog_implications::parsed_state_updates::{self, ParsedStateUpdate};
6666
use crate::util::index_sql;
6767

6868
/// Maintains the state of retractions while applying catalog state updates for a single timestamp.
@@ -108,7 +108,7 @@ impl CatalogState {
108108
Vec<ParsedStateUpdate>,
109109
) {
110110
let mut builtin_table_updates = Vec::with_capacity(updates.len());
111-
let mut controller_state_updates = Vec::with_capacity(updates.len());
111+
let mut catalog_updates = Vec::with_capacity(updates.len());
112112
let updates = sort_updates(updates);
113113

114114
let mut groups: Vec<Vec<_>> = Vec::new();
@@ -121,29 +121,28 @@ impl CatalogState {
121121

122122
for update in updates {
123123
let next_apply_state = BootstrapApplyState::new(update);
124-
let (next_apply_state, (builtin_table_update, controller_state_update)) =
125-
apply_state
126-
.step(
127-
next_apply_state,
128-
self,
129-
&mut retractions,
130-
local_expression_cache,
131-
)
132-
.await;
124+
let (next_apply_state, (builtin_table_update, catalog_update)) = apply_state
125+
.step(
126+
next_apply_state,
127+
self,
128+
&mut retractions,
129+
local_expression_cache,
130+
)
131+
.await;
133132
apply_state = next_apply_state;
134133
builtin_table_updates.extend(builtin_table_update);
135-
controller_state_updates.extend(controller_state_update);
134+
catalog_updates.extend(catalog_update);
136135
}
137136

138137
// Apply remaining state.
139-
let (builtin_table_update, controller_state_update) = apply_state
138+
let (builtin_table_update, catalog_update) = apply_state
140139
.apply(self, &mut retractions, local_expression_cache)
141140
.await;
142141
builtin_table_updates.extend(builtin_table_update);
143-
controller_state_updates.extend(controller_state_update);
142+
catalog_updates.extend(catalog_update);
144143
}
145144

146-
(builtin_table_updates, controller_state_updates)
145+
(builtin_table_updates, catalog_updates)
147146
}
148147

149148
/// Update in-memory catalog state from a list of updates made to the durable catalog state.
@@ -161,7 +160,7 @@ impl CatalogState {
161160
CatalogError,
162161
> {
163162
let mut builtin_table_updates = Vec::with_capacity(updates.len());
164-
let mut controller_state_updates = Vec::with_capacity(updates.len());
163+
let mut catalog_updates = Vec::with_capacity(updates.len());
165164

166165
// First, consolidate updates. The code that applies parsed state
167166
// updates _requires_ that the given updates are consolidated. There
@@ -175,16 +174,16 @@ impl CatalogState {
175174

176175
for (_, updates) in &updates.into_iter().chunk_by(|update| update.ts) {
177176
let mut retractions = InProgressRetractions::default();
178-
let (builtin_table_update, parsed_catalog_updates_op) = self.apply_updates_inner(
177+
let (builtin_table_update, catalog_updates_op) = self.apply_updates_inner(
179178
updates.collect(),
180179
&mut retractions,
181180
&mut LocalExpressionCache::Closed,
182181
)?;
183182
builtin_table_updates.extend(builtin_table_update);
184-
controller_state_updates.extend(parsed_catalog_updates_op);
183+
catalog_updates.extend(catalog_updates_op);
185184
}
186185

187-
Ok((builtin_table_updates, controller_state_updates))
186+
Ok((builtin_table_updates, catalog_updates))
188187
}
189188

190189
/// It can happen that the sequencing logic creates "fluctuating" updates
@@ -236,7 +235,7 @@ impl CatalogState {
236235
let mut update_system_config = false;
237236

238237
let mut builtin_table_updates = Vec::with_capacity(updates.len());
239-
let mut controller_state_updates = Vec::new();
238+
let mut catalog_updates = Vec::new();
240239

241240
for state_update in updates {
242241
if matches!(state_update.kind, StateUpdateKind::SystemConfiguration(_)) {
@@ -245,14 +244,13 @@ impl CatalogState {
245244

246245
match state_update.diff {
247246
StateDiff::Retraction => {
248-
// We want the parsed controller state updates to match the
249-
// state of the catalog _before_ applying a retraction. So
250-
// that we can still have useful in-memory state to work
251-
// with.
247+
// We want the parsed catalog updates to match the state of
248+
// the catalog _before_ applying a retraction. So that we can
249+
// still have useful in-memory state to work with.
252250
if let Some(update) =
253251
parsed_state_updates::parse_state_update(self, state_update.clone())
254252
{
255-
controller_state_updates.push(update);
253+
catalog_updates.push(update);
256254
}
257255

258256
// We want the builtin table retraction to match the state of the catalog
@@ -283,12 +281,12 @@ impl CatalogState {
283281
state_update.diff,
284282
));
285283

286-
// We want the parsed controller state updates to match the
287-
// state of the catalog _after_ applying an addition.
284+
// We want the parsed catalog updates to match the state of
285+
// the catalog _after_ applying an addition.
288286
if let Some(update) =
289287
parsed_state_updates::parse_state_update(self, state_update.clone())
290288
{
291-
controller_state_updates.push(update);
289+
catalog_updates.push(update);
292290
}
293291
}
294292
}
@@ -298,7 +296,7 @@ impl CatalogState {
298296
self.system_configuration.dyncfg_updates();
299297
}
300298

301-
Ok((builtin_table_updates, controller_state_updates))
299+
Ok((builtin_table_updates, catalog_updates))
302300
}
303301

304302
#[instrument(level = "debug")]

src/adapter/src/catalog/migrate.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ use uuid::Uuid;
4141
use crate::catalog::open::into_consolidatable_updates_startup;
4242
use crate::catalog::state::LocalExpressionCache;
4343
use crate::catalog::{BuiltinTableUpdate, CatalogState, ConnCatalog};
44-
use crate::coord::controller_commands::parsed_state_updates::ParsedStateUpdate;
44+
use crate::coord::catalog_implications::parsed_state_updates::ParsedStateUpdate;
4545

4646
/// Catalog key of the `migration_version` setting.
4747
///
@@ -118,7 +118,7 @@ where
118118

119119
pub(crate) struct MigrateResult {
120120
pub(crate) builtin_table_updates: Vec<BuiltinTableUpdate<&'static BuiltinTable>>,
121-
pub(crate) controller_state_updates: Vec<ParsedStateUpdate>,
121+
pub(crate) catalog_updates: Vec<ParsedStateUpdate>,
122122
pub(crate) post_item_updates: Vec<(BootstrapStateUpdateKind, Timestamp, Diff)>,
123123
}
124124

@@ -194,7 +194,7 @@ pub(crate) async fn migrate(
194194
.expect("known parameter");
195195
}
196196

197-
let (mut ast_builtin_table_updates, mut ast_controller_state_updates) = state
197+
let (mut ast_builtin_table_updates, mut ast_catalog_updates) = state
198198
.apply_updates_for_bootstrap(item_updates, local_expr_cache)
199199
.await;
200200

@@ -240,12 +240,12 @@ pub(crate) async fn migrate(
240240
// input and stages arbitrary transformations to the catalog on `tx`.
241241

242242
let op_item_updates = tx.get_and_commit_op_updates();
243-
let (item_builtin_table_updates, item_controller_state_updates) = state
243+
let (item_builtin_table_updates, item_catalog_updates) = state
244244
.apply_updates_for_bootstrap(op_item_updates, local_expr_cache)
245245
.await;
246246

247247
ast_builtin_table_updates.extend(item_builtin_table_updates);
248-
ast_controller_state_updates.extend(item_controller_state_updates);
248+
ast_catalog_updates.extend(item_catalog_updates);
249249

250250
info!(
251251
"migration from catalog version {:?} complete",
@@ -254,7 +254,7 @@ pub(crate) async fn migrate(
254254

255255
Ok(MigrateResult {
256256
builtin_table_updates: ast_builtin_table_updates,
257-
controller_state_updates: ast_controller_state_updates,
257+
catalog_updates: ast_catalog_updates,
258258
post_item_updates,
259259
})
260260
}

src/adapter/src/catalog/open.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ impl Catalog {
313313
}
314314
}
315315

316-
let (builtin_table_update, _controller_state_updates) = state
316+
let (builtin_table_update, _catalog_updates) = state
317317
.apply_updates_for_bootstrap(pre_item_updates, &mut LocalExpressionCache::Closed)
318318
.await;
319319
builtin_table_updates.extend(builtin_table_update);
@@ -410,12 +410,12 @@ impl Catalog {
410410
expr_cache_start.elapsed()
411411
);
412412

413-
// When initializing/bootstrapping, we don't use the controller state
414-
// updates but instead load the catalog fully and then go ahead and
415-
// apply commands to the controller(s). Maybe we _should_ instead use
416-
// the same logic and return and use the updates from here. But that's
417-
// at the very least future work.
418-
let (builtin_table_update, _controller_state_updates) = state
413+
// When initializing/bootstrapping, we don't use the catalog updates but
414+
// instead load the catalog fully and then go ahead and apply commands
415+
// to the controller(s). Maybe we _should_ instead use the same logic
416+
// and return and use the updates from here. But that's at the very
417+
// least future work.
418+
let (builtin_table_update, _catalog_updates) = state
419419
.apply_updates_for_bootstrap(system_item_updates, &mut local_expr_cache)
420420
.await;
421421
builtin_table_updates.extend(builtin_table_update);
@@ -431,7 +431,7 @@ impl Catalog {
431431
state.mock_authentication_nonce = Some(mz_authentication_mock_nonce);
432432

433433
// Migrate item ASTs.
434-
let (builtin_table_update, _controller_state_updates) = if !config.skip_migrations {
434+
let (builtin_table_update, _catalog_updates) = if !config.skip_migrations {
435435
let migrate_result = migrate::migrate(
436436
&mut state,
437437
&mut txn,
@@ -463,7 +463,7 @@ impl Catalog {
463463

464464
(
465465
migrate_result.builtin_table_updates,
466-
migrate_result.controller_state_updates,
466+
migrate_result.catalog_updates,
467467
)
468468
} else {
469469
state
@@ -480,7 +480,7 @@ impl Catalog {
480480
diff: diff.try_into().expect("valid diff"),
481481
})
482482
.collect();
483-
let (builtin_table_update, _controller_state_updates) = state
483+
let (builtin_table_update, _catalog_updates) = state
484484
.apply_updates_for_bootstrap(post_item_updates, &mut local_expr_cache)
485485
.await;
486486
builtin_table_updates.extend(builtin_table_update);
@@ -505,12 +505,12 @@ impl Catalog {
505505

506506
let state_updates = txn.get_and_commit_op_updates();
507507

508-
// When initializing/bootstrapping, we don't use the controller state
509-
// updates but instead load the catalog fully and then go ahead and
510-
// apply commands to the controller(s). Maybe we _should_ instead use
511-
// the same logic and return and use the updates from here. But that's
512-
// at the very least future work.
513-
let (table_updates, _controller_state_updates) = state
508+
// When initializing/bootstrapping, we don't use the catalog updates but
509+
// instead load the catalog fully and then go ahead and apply commands
510+
// to the controller(s). Maybe we _should_ instead use the same logic
511+
// and return and use the updates from here. But that's at the very
512+
// least future work.
513+
let (table_updates, _catalog_updates) = state
514514
.apply_updates_for_bootstrap(state_updates, &mut local_expr_cache)
515515
.await;
516516
builtin_table_updates.extend(table_updates);
@@ -656,13 +656,13 @@ impl Catalog {
656656
.map_err(mz_catalog::durable::DurableCatalogError::from)?;
657657

658658
let updates = txn.get_and_commit_op_updates();
659-
let (builtin_updates, controller_state_updates) = state.apply_updates(updates)?;
659+
let (builtin_updates, catalog_updates) = state.apply_updates(updates)?;
660660
assert!(
661661
builtin_updates.is_empty(),
662662
"storage is not allowed to generate catalog changes that would cause changes to builtin tables"
663663
);
664664
assert!(
665-
controller_state_updates.is_empty(),
665+
catalog_updates.is_empty(),
666666
"storage is not allowed to generate catalog changes that would change the catalog or controller state"
667667
);
668668
let commit_ts = txn.upper();

0 commit comments

Comments
 (0)