Skip to content

Commit 15c5cf3

Browse files
committed
fixup! Implement tiered storage
Replace the ephemeral_store() method with direct is_ephemeral_cached_key() checks followed by self.ephemeral_store.as_ref() at each callsite, making the routing decision explicit.
1 parent 623eecf commit 15c5cf3

1 file changed

Lines changed: 52 additions & 54 deletions

File tree

src/io/tier_store.rs

Lines changed: 52 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -277,15 +277,21 @@ impl TierStoreInner {
277277
"read",
278278
)?;
279279

280-
if let Some(eph_store) =
281-
self.ephemeral_store(&primary_namespace, &secondary_namespace, &key)
282-
{
283-
// We don't retry ephemeral-store reads here. Local failures are treated as
284-
// terminal for this access path rather than falling back to another store.
285-
KVStore::read(eph_store.as_ref(), &primary_namespace, &secondary_namespace, &key).await
286-
} else {
287-
self.read_primary(&primary_namespace, &secondary_namespace, &key).await
280+
if is_ephemeral_cached_key(&primary_namespace, &secondary_namespace, &key) {
281+
if let Some(eph_store) = self.ephemeral_store.as_ref() {
282+
// We don't retry ephemeral-store reads here. Local failures are treated as
283+
// terminal for this access path rather than falling back to another store.
284+
return KVStore::read(
285+
eph_store.as_ref(),
286+
&primary_namespace,
287+
&secondary_namespace,
288+
&key,
289+
)
290+
.await;
291+
}
288292
}
293+
294+
self.read_primary(&primary_namespace, &secondary_namespace, &key).await
289295
}
290296

291297
async fn write_internal(
@@ -298,26 +304,26 @@ impl TierStoreInner {
298304
"write",
299305
)?;
300306

301-
if let Some(eph_store) =
302-
self.ephemeral_store(&primary_namespace, &secondary_namespace, &key)
303-
{
304-
KVStore::write(
305-
eph_store.as_ref(),
306-
primary_namespace.as_str(),
307-
secondary_namespace.as_str(),
308-
key.as_str(),
309-
buf,
310-
)
311-
.await
312-
} else {
313-
self.write_primary_backup_async(
314-
primary_namespace.as_str(),
315-
secondary_namespace.as_str(),
316-
key.as_str(),
317-
buf,
318-
)
319-
.await
307+
if is_ephemeral_cached_key(&primary_namespace, &secondary_namespace, &key) {
308+
if let Some(eph_store) = self.ephemeral_store.as_ref() {
309+
return KVStore::write(
310+
eph_store.as_ref(),
311+
primary_namespace.as_str(),
312+
secondary_namespace.as_str(),
313+
key.as_str(),
314+
buf,
315+
)
316+
.await;
317+
}
320318
}
319+
320+
self.write_primary_backup_async(
321+
primary_namespace.as_str(),
322+
secondary_namespace.as_str(),
323+
key.as_str(),
324+
buf,
325+
)
326+
.await
321327
}
322328

323329
async fn remove_internal(
@@ -330,26 +336,26 @@ impl TierStoreInner {
330336
"remove",
331337
)?;
332338

333-
if let Some(eph_store) =
334-
self.ephemeral_store(&primary_namespace, &secondary_namespace, &key)
335-
{
336-
KVStore::remove(
337-
eph_store.as_ref(),
338-
primary_namespace.as_str(),
339-
secondary_namespace.as_str(),
340-
key.as_str(),
341-
lazy,
342-
)
343-
.await
344-
} else {
345-
self.remove_primary_backup_async(
346-
primary_namespace.as_str(),
347-
secondary_namespace.as_str(),
348-
key.as_str(),
349-
lazy,
350-
)
351-
.await
339+
if is_ephemeral_cached_key(&primary_namespace, &secondary_namespace, &key) {
340+
if let Some(eph_store) = self.ephemeral_store.as_ref() {
341+
return KVStore::remove(
342+
eph_store.as_ref(),
343+
primary_namespace.as_str(),
344+
secondary_namespace.as_str(),
345+
key.as_str(),
346+
lazy,
347+
)
348+
.await;
349+
}
352350
}
351+
352+
self.remove_primary_backup_async(
353+
primary_namespace.as_str(),
354+
secondary_namespace.as_str(),
355+
key.as_str(),
356+
lazy,
357+
)
358+
.await
353359
}
354360

355361
async fn list_internal(
@@ -381,14 +387,6 @@ impl TierStoreInner {
381387
}
382388
}
383389

384-
fn ephemeral_store(
385-
&self, primary_namespace: &str, secondary_namespace: &str, key: &str,
386-
) -> Option<&Arc<DynStore>> {
387-
self.ephemeral_store
388-
.as_ref()
389-
.filter(|_s| is_ephemeral_cached_key(primary_namespace, secondary_namespace, key))
390-
}
391-
392390
fn handle_primary_backup_results(
393391
&self, op: &str, primary_namespace: &str, secondary_namespace: &str, key: &str,
394392
primary_res: io::Result<()>, backup_res: io::Result<()>,

0 commit comments

Comments
 (0)