Skip to content

Commit 4e79534

Browse files
authored
catalog: Clean up boot_ts usage in open (#25125)
This commit renames the `boot_ts` parameter of the open family of method in `OpenableDurableCatalogState` to `initial_ts`. `initial_ts` is more accurate because the timestamp is only used to initialize the catalog if it's a new environment. Additionally, `boot_ts` is used in other places and is linearized against the timestamp oracle. In the open family of methods, `boot_ts` wasn't linearized, so the name may have mistakenly led people to people that this `boot_ts` was also linearized. Additionally, `initial_ts` is removed as a parameter from `open_readonly`, because `open_readonly` cannot initialize a new environment, so it doesn't make sense to require a `initial_ts`.
1 parent d6c5764 commit 4e79534

File tree

9 files changed

+51
-54
lines changed

9 files changed

+51
-54
lines changed

src/adapter/src/catalog.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ impl Catalog {
615615
stash_config,
616616
));
617617
let storage = openable_storage
618-
.open_read_only(now(), &test_bootstrap_args())
618+
.open_read_only(&test_bootstrap_args())
619619
.await?;
620620
Self::open_debug_catalog_inner(storage, now, environment_id).await
621621
}
@@ -637,7 +637,7 @@ impl Catalog {
637637
.await,
638638
);
639639
let storage = openable_storage
640-
.open_read_only(now(), &test_bootstrap_args())
640+
.open_read_only(&test_bootstrap_args())
641641
.await?;
642642
Self::open_debug_catalog_inner(storage, now, Some(environment_id)).await
643643
}
@@ -661,7 +661,7 @@ impl Catalog {
661661
.await,
662662
);
663663
let storage = openable_storage
664-
.open_read_only(now(), &test_bootstrap_args())
664+
.open_read_only(&test_bootstrap_args())
665665
.await?;
666666
Self::open_debug_catalog_inner(storage, now, Some(environment_id)).await
667667
}

src/catalog/src/durable.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,11 @@ pub trait OpenableDurableCatalogState: Debug + Send {
101101
/// Will return an error in the following scenarios:
102102
/// - Catalog initialization fails.
103103
/// - Catalog migrations fail.
104+
///
105+
/// `initial_ts` is used as the initial timestamp for new environments.
104106
async fn open_savepoint(
105107
mut self: Box<Self>,
106-
boot_ts: EpochMillis,
108+
initial_ts: EpochMillis,
107109
bootstrap_args: &BootstrapArgs,
108110
deploy_generation: Option<u64>,
109111
epoch_lower_bound: Option<Epoch>,
@@ -116,19 +118,19 @@ pub trait OpenableDurableCatalogState: Debug + Send {
116118
/// it will fail to open in read only mode.
117119
async fn open_read_only(
118120
mut self: Box<Self>,
119-
boot_ts: EpochMillis,
120121
bootstrap_args: &BootstrapArgs,
121122
) -> Result<Box<dyn DurableCatalogState>, CatalogError>;
122123

123124
/// Opens the catalog in a writeable mode. Optionally initializes the
124125
/// catalog, if it has not been initialized, and perform any migrations
125126
/// needed.
126127
///
128+
/// `initial_ts` is used as the initial timestamp for new environments.
127129
/// `epoch_lower_bound` is used as a lower bound for the epoch that is used by the returned
128130
/// catalog.
129131
async fn open(
130132
mut self: Box<Self>,
131-
boot_ts: EpochMillis,
133+
initial_ts: EpochMillis,
132134
bootstrap_args: &BootstrapArgs,
133135
deploy_generation: Option<u64>,
134136
epoch_lower_bound: Option<Epoch>,

src/catalog/src/durable/impls/migrate.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pub struct CatalogMigrator {
6969
impl OpenableDurableCatalogState for CatalogMigrator {
7070
async fn open_savepoint(
7171
mut self: Box<Self>,
72-
boot_ts: EpochMillis,
72+
initial_ts: EpochMillis,
7373
bootstrap_args: &BootstrapArgs,
7474
deploy_generation: Option<u64>,
7575
epoch_lower_bound: Option<Epoch>,
@@ -85,7 +85,7 @@ impl OpenableDurableCatalogState for CatalogMigrator {
8585
let tombstone = self.get_tombstone().await?;
8686
let mut stash = self
8787
.openable_stash
88-
.open_savepoint(boot_ts, bootstrap_args, deploy_generation, None)
88+
.open_savepoint(initial_ts, bootstrap_args, deploy_generation, None)
8989
.await?;
9090
// Forcibly mark the rollback as complete so we look at the correct implementation
9191
// (stash) on re-boot. This is really a no-op because it's a savepoint catalog, but
@@ -107,15 +107,15 @@ impl OpenableDurableCatalogState for CatalogMigrator {
107107
let stash = self
108108
.openable_stash
109109
.open_savepoint(
110-
boot_ts.clone(),
110+
initial_ts.clone(),
111111
bootstrap_args,
112112
deploy_generation.clone(),
113113
persist_epoch,
114114
)
115115
.await;
116116
let persist = self
117117
.openable_persist
118-
.open_savepoint(boot_ts, bootstrap_args, deploy_generation, stash_epoch)
118+
.open_savepoint(initial_ts, bootstrap_args, deploy_generation, stash_epoch)
119119
.await;
120120

121121
// If our target implementation is the stash, but persist is uninitialized, then we can
@@ -147,15 +147,14 @@ impl OpenableDurableCatalogState for CatalogMigrator {
147147

148148
async fn open_read_only(
149149
self: Box<Self>,
150-
_boot_ts: EpochMillis,
151150
_bootstrap_args: &BootstrapArgs,
152151
) -> Result<Box<dyn DurableCatalogState>, CatalogError> {
153152
panic!("cannot use a read only catalog with the migrate implementation")
154153
}
155154

156155
async fn open(
157156
mut self: Box<Self>,
158-
boot_ts: EpochMillis,
157+
initial_ts: EpochMillis,
159158
bootstrap_args: &BootstrapArgs,
160159
deploy_generation: Option<u64>,
161160
epoch_lower_bound: Option<Epoch>,
@@ -171,7 +170,7 @@ impl OpenableDurableCatalogState for CatalogMigrator {
171170
let tombstone = self.get_tombstone().await?;
172171
let mut stash = self
173172
.openable_stash
174-
.open(boot_ts, bootstrap_args, deploy_generation, None)
173+
.open(initial_ts, bootstrap_args, deploy_generation, None)
175174
.await?;
176175
// Forcibly mark the rollback as complete so we look at the correct implementation
177176
// (stash) on re-boot.
@@ -201,7 +200,7 @@ impl OpenableDurableCatalogState for CatalogMigrator {
201200
let stash = self
202201
.openable_stash
203202
.open(
204-
boot_ts.clone(),
203+
initial_ts.clone(),
205204
bootstrap_args,
206205
deploy_generation.clone(),
207206
persist_epoch,
@@ -210,7 +209,7 @@ impl OpenableDurableCatalogState for CatalogMigrator {
210209
fail::fail_point!("post_stash_fence");
211210
let persist = self
212211
.openable_persist
213-
.open(boot_ts, bootstrap_args, deploy_generation, stash_epoch)
212+
.open(initial_ts, bootstrap_args, deploy_generation, stash_epoch)
214213
.await?;
215214
fail::fail_point!("post_persist_fence");
216215
Self::open_inner(stash, persist, direction).await

src/catalog/src/durable/impls/persist.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ impl UnopenedPersistCatalogState {
342342
async fn open_inner(
343343
mut self,
344344
mode: Mode,
345-
boot_ts: EpochMillis,
345+
initial_ts: EpochMillis,
346346
bootstrap_args: &BootstrapArgs,
347347
deploy_generation: Option<u64>,
348348
epoch_lower_bound: Option<Epoch>,
@@ -434,7 +434,7 @@ impl UnopenedPersistCatalogState {
434434
catalog.snapshot
435435
);
436436
let mut txn = catalog.transaction().await?;
437-
initialize::initialize(&mut txn, bootstrap_args, boot_ts, deploy_generation).await?;
437+
initialize::initialize(&mut txn, bootstrap_args, initial_ts, deploy_generation).await?;
438438
txn
439439
};
440440

@@ -664,14 +664,14 @@ impl OpenableDurableCatalogState for UnopenedPersistCatalogState {
664664
#[tracing::instrument(level = "info", skip(self))]
665665
async fn open_savepoint(
666666
mut self: Box<Self>,
667-
boot_ts: EpochMillis,
667+
initial_ts: EpochMillis,
668668
bootstrap_args: &BootstrapArgs,
669669
deploy_generation: Option<u64>,
670670
epoch_lower_bound: Option<Epoch>,
671671
) -> Result<Box<dyn DurableCatalogState>, CatalogError> {
672672
self.open_inner(
673673
Mode::Savepoint,
674-
boot_ts,
674+
initial_ts,
675675
bootstrap_args,
676676
deploy_generation,
677677
epoch_lower_bound,
@@ -683,25 +683,24 @@ impl OpenableDurableCatalogState for UnopenedPersistCatalogState {
683683
#[tracing::instrument(level = "info", skip(self))]
684684
async fn open_read_only(
685685
mut self: Box<Self>,
686-
boot_ts: EpochMillis,
687686
bootstrap_args: &BootstrapArgs,
688687
) -> Result<Box<dyn DurableCatalogState>, CatalogError> {
689-
self.open_inner(Mode::Readonly, boot_ts, bootstrap_args, None, None)
688+
self.open_inner(Mode::Readonly, EpochMillis::MIN, bootstrap_args, None, None)
690689
.boxed()
691690
.await
692691
}
693692

694693
#[tracing::instrument(level = "info", skip(self))]
695694
async fn open(
696695
mut self: Box<Self>,
697-
boot_ts: EpochMillis,
696+
initial_ts: EpochMillis,
698697
bootstrap_args: &BootstrapArgs,
699698
deploy_generation: Option<u64>,
700699
epoch_lower_bound: Option<Epoch>,
701700
) -> Result<Box<dyn DurableCatalogState>, CatalogError> {
702701
self.open_inner(
703702
Mode::Writable,
704-
boot_ts,
703+
initial_ts,
705704
bootstrap_args,
706705
deploy_generation,
707706
epoch_lower_bound,

src/catalog/src/durable/impls/persist/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ async fn test_upgrade_shard() {
9999
.await
100100
.expect("failed to create persist catalog");
101101
let _persist_state = Box::new(persist_openable_state)
102-
.open_read_only(NOW_ZERO(), &test_bootstrap_args())
102+
.open_read_only(&test_bootstrap_args())
103103
.await
104104
.expect("failed to open readonly persist catalog");
105105

src/catalog/src/durable/impls/shadow.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -80,19 +80,19 @@ where
8080
{
8181
async fn open_savepoint(
8282
self: Box<Self>,
83-
boot_ts: EpochMillis,
83+
initial_ts: EpochMillis,
8484
bootstrap_args: &BootstrapArgs,
8585
deploy_generation: Option<u64>,
8686
epoch_lower_bound: Option<Epoch>,
8787
) -> Result<Box<dyn DurableCatalogState>, CatalogError> {
8888
let stash = self.stash.open_savepoint(
89-
boot_ts.clone(),
89+
initial_ts.clone(),
9090
bootstrap_args,
9191
deploy_generation.clone(),
9292
epoch_lower_bound,
9393
);
9494
let persist = self.persist.open_savepoint(
95-
boot_ts,
95+
initial_ts,
9696
bootstrap_args,
9797
deploy_generation,
9898
epoch_lower_bound,
@@ -110,11 +110,10 @@ where
110110

111111
async fn open_read_only(
112112
self: Box<Self>,
113-
boot_ts: EpochMillis,
114113
bootstrap_args: &BootstrapArgs,
115114
) -> Result<Box<dyn DurableCatalogState>, CatalogError> {
116-
let stash = self.stash.open_read_only(boot_ts.clone(), bootstrap_args);
117-
let persist = self.persist.open_read_only(boot_ts, bootstrap_args);
115+
let stash = self.stash.open_read_only(bootstrap_args);
116+
let persist = self.persist.open_read_only(bootstrap_args);
118117
let (stash, persist) = futures::future::join(stash, persist).await;
119118
soft_assert_eq_or_log!(
120119
stash.is_ok(),
@@ -128,19 +127,19 @@ where
128127

129128
async fn open(
130129
self: Box<Self>,
131-
boot_ts: EpochMillis,
130+
initial_ts: EpochMillis,
132131
bootstrap_args: &BootstrapArgs,
133132
deploy_generation: Option<u64>,
134133
epoch_lower_bound: Option<Epoch>,
135134
) -> Result<Box<dyn DurableCatalogState>, CatalogError> {
136135
let stash = self.stash.open(
137-
boot_ts.clone(),
136+
initial_ts.clone(),
138137
bootstrap_args,
139138
deploy_generation.clone(),
140139
epoch_lower_bound,
141140
);
142141
let persist = self.persist.open(
143-
boot_ts,
142+
initial_ts,
144143
bootstrap_args,
145144
deploy_generation,
146145
epoch_lower_bound,

src/catalog/src/durable/impls/stash.rs

+14-16
Original file line numberDiff line numberDiff line change
@@ -207,38 +207,37 @@ impl OpenableDurableCatalogState for OpenableConnection {
207207
#[tracing::instrument(name = "storage::open_check", level = "info", skip_all)]
208208
async fn open_savepoint(
209209
mut self: Box<Self>,
210-
boot_ts: EpochMillis,
210+
initial_ts: EpochMillis,
211211
bootstrap_args: &BootstrapArgs,
212212
deploy_generation: Option<u64>,
213213
epoch_lower_bound: Option<Epoch>,
214214
) -> Result<Box<dyn DurableCatalogState>, CatalogError> {
215215
self.open_stash_savepoint(epoch_lower_bound).await?;
216216
let stash = self.stash.take().expect("opened above");
217-
retry_open(stash, boot_ts, bootstrap_args, deploy_generation).await
217+
retry_open(stash, initial_ts, bootstrap_args, deploy_generation).await
218218
}
219219

220220
#[tracing::instrument(name = "storage::open_read_only", level = "info", skip_all)]
221221
async fn open_read_only(
222222
mut self: Box<Self>,
223-
boot_ts: EpochMillis,
224223
bootstrap_args: &BootstrapArgs,
225224
) -> Result<Box<dyn DurableCatalogState>, CatalogError> {
226225
self.open_stash_read_only().await?;
227226
let stash = self.stash.take().expect("opened above");
228-
retry_open(stash, boot_ts, bootstrap_args, None).await
227+
retry_open(stash, EpochMillis::MIN, bootstrap_args, None).await
229228
}
230229

231230
#[tracing::instrument(name = "storage::open", level = "info", skip_all)]
232231
async fn open(
233232
mut self: Box<Self>,
234-
boot_ts: EpochMillis,
233+
initial_ts: EpochMillis,
235234
bootstrap_args: &BootstrapArgs,
236235
deploy_generation: Option<u64>,
237236
epoch_lower_bound: Option<Epoch>,
238237
) -> Result<Box<dyn DurableCatalogState>, CatalogError> {
239238
self.open_stash(epoch_lower_bound).await?;
240239
let stash = self.stash.take().expect("opened above");
241-
retry_open(stash, boot_ts, bootstrap_args, deploy_generation).await
240+
retry_open(stash, initial_ts, bootstrap_args, deploy_generation).await
242241
}
243242

244243
#[tracing::instrument(name = "storage::open_debug", level = "info", skip_all)]
@@ -451,7 +450,7 @@ impl OpenableDurableCatalogState for OpenableConnection {
451450
/// If the inner stash has not been opened.
452451
async fn retry_open(
453452
mut stash: Stash,
454-
boot_ts: EpochMillis,
453+
initial_ts: EpochMillis,
455454
bootstrap_args: &BootstrapArgs,
456455
deploy_generation: Option<u64>,
457456
) -> Result<Box<dyn DurableCatalogState>, CatalogError> {
@@ -462,7 +461,7 @@ async fn retry_open(
462461
let mut retry = pin::pin!(retry);
463462

464463
loop {
465-
match open_inner(stash, boot_ts.clone(), bootstrap_args, deploy_generation).await {
464+
match open_inner(stash, initial_ts.clone(), bootstrap_args, deploy_generation).await {
466465
Ok(conn) => {
467466
return Ok(conn);
468467
}
@@ -480,7 +479,7 @@ async fn retry_open(
480479
#[tracing::instrument(name = "storage::open_inner", level = "info", skip_all)]
481480
async fn open_inner(
482481
mut stash: Stash,
483-
boot_ts: EpochMillis,
482+
initial_ts: EpochMillis,
484483
bootstrap_args: &BootstrapArgs,
485484
deploy_generation: Option<u64>,
486485
) -> Result<Box<Connection>, (Stash, CatalogError)> {
@@ -499,7 +498,7 @@ async fn open_inner(
499498
Ok(txn) => txn,
500499
Err(e) => return Err((conn.stash, e)),
501500
};
502-
match initialize::initialize(&mut tx, &args, boot_ts, deploy_generation).await {
501+
match initialize::initialize(&mut tx, &args, initial_ts, deploy_generation).await {
503502
Ok(()) => {}
504503
Err(e) => return Err((conn.stash, e)),
505504
}
@@ -1318,14 +1317,14 @@ impl TestOpenableConnection<'_> {
13181317
impl OpenableDurableCatalogState for TestOpenableConnection<'_> {
13191318
async fn open_savepoint(
13201319
mut self: Box<Self>,
1321-
boot_ts: EpochMillis,
1320+
initial_ts: EpochMillis,
13221321
bootstrap_args: &BootstrapArgs,
13231322
deploy_generation: Option<u64>,
13241323
epoch_lower_bound: Option<Epoch>,
13251324
) -> Result<Box<dyn DurableCatalogState>, CatalogError> {
13261325
self.openable_connection
13271326
.open_savepoint(
1328-
boot_ts,
1327+
initial_ts,
13291328
bootstrap_args,
13301329
deploy_generation,
13311330
epoch_lower_bound,
@@ -1335,24 +1334,23 @@ impl OpenableDurableCatalogState for TestOpenableConnection<'_> {
13351334

13361335
async fn open_read_only(
13371336
mut self: Box<Self>,
1338-
boot_ts: EpochMillis,
13391337
bootstrap_args: &BootstrapArgs,
13401338
) -> Result<Box<dyn DurableCatalogState>, CatalogError> {
13411339
self.openable_connection
1342-
.open_read_only(boot_ts, bootstrap_args)
1340+
.open_read_only(bootstrap_args)
13431341
.await
13441342
}
13451343

13461344
async fn open(
13471345
mut self: Box<Self>,
1348-
boot_ts: EpochMillis,
1346+
initial_ts: EpochMillis,
13491347
bootstrap_args: &BootstrapArgs,
13501348
deploy_generation: Option<u64>,
13511349
epoch_lower_bound: Option<Epoch>,
13521350
) -> Result<Box<dyn DurableCatalogState>, CatalogError> {
13531351
self.openable_connection
13541352
.open(
1355-
boot_ts,
1353+
initial_ts,
13561354
bootstrap_args,
13571355
deploy_generation,
13581356
epoch_lower_bound,

0 commit comments

Comments
 (0)