Skip to content

Commit 7750cf8

Browse files
committed
fixup! Implement tiered storage
Previously, the implementations for `list` and paginated listing on `TierStore` contained a bug where, if the ephemeral store was configured, these operations could return only keys from the ephemeral tier for shared root namespaces such as ("", ""). This meant durable keys saved to the primary store could be ignored whenever their namespace was shared with ephemeral-cached keys. While the solution to `list` seemed straightforward, the one for paginated listing raised questions about the potential difference in store types between the primary and ephemeral stores, and the conflict that would arise from them having independent pagination orders and tokens. `TierStore`, as currently designed, does not maintain a cross-store cursor, so we rely on a simple overlay strategy: paginate through primary first, then append ephemeral keys once primary is on its terminal page. This does mean the resulting paginated listing is not a strict cross-store creation-order merge: ephemeral keys are returned after primary pagination is exhausted, regardless of their creation order in the ephemeral store. We accept that tradeoff because `TierStore` has no shared creation order across backing stores, and the overlay is bounded to the current ephemeral-cached key set. This commit allows us to merge listings across `TierStore`'s primary and ephemeral tiers by treating the latter as an overlay for ephemeral-cached keys only. We filter stale primary copies of ephemeral-cached keys, append live ephemeral copies once primary pagination is complete, and only consult the ephemeral store for namespaces that can contain ephemeral-cached keys.
1 parent cb0035a commit 7750cf8

3 files changed

Lines changed: 466 additions & 49 deletions

File tree

src/io/in_memory_store.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use lightning::util::persist::{
1515
KVStore, MigratableKVStore, PageToken, PaginatedKVStore, PaginatedListResponse,
1616
};
1717

18-
const IN_MEMORY_PAGE_SIZE: usize = 50;
18+
pub(crate) const IN_MEMORY_PAGE_SIZE: usize = 50;
1919

2020
pub struct InMemoryStore {
2121
persisted_bytes: Mutex<HashMap<String, HashMap<String, Vec<u8>>>>,

src/io/test_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ impl<K: KVStore + Sync> chainmonitor::Persist<TestChannelSigner>
159159

160160
const EXPECTED_UPDATES_PER_PAYMENT: u64 = 5;
161161

162-
pub(crate) use in_memory_store::InMemoryStore;
162+
pub(crate) use in_memory_store::{InMemoryStore, IN_MEMORY_PAGE_SIZE};
163163

164164
pub(crate) fn random_storage_path() -> PathBuf {
165165
let mut temp_path = std::env::temp_dir();

0 commit comments

Comments
 (0)