https://slatedb.io logo
@criccomini I got two DST tests failing
# general
d
@criccomini I got two DST tests failing after making the configuration more random 🎊 I'll open an issue when I have more details, but they always fail with this read configuration: `ReadOptions { durability_filter: Remote, dirty: true }`:
Copy code
2025-08-09T22:01:59.333009Z DEBUG slatedb_dst::dst: running step [step_action=Get([36, 100, 0, 60, 109, 236, 246, 248]..., ReadOptions { durability_filter: Remote, dirty: true })]

thread 'test_dst_is_deterministic::case_03' panicked at /home/david/src/slatedb/slatedb-dst/src/dst.rs:614:9:
assertion `left == right` failed: expected_val=Some([20, 185, 203, 249, 32, 104, 84, 23])..., actual_val=None...
c
Interesting. Regardless of the seed, they fail?
I have to refresh what
dirty
means now...
I think since
Remote
is set,
dirty
is a noop. The read would only see data that's been written to object storage. We don't split a single atomic operation across batches. So I think the issue might simply be that the in-memory "expected state" is reflecting what's been put, but the read is reading against the
LocalFilesystem
object store, which doesn't contain the most recent writes (that are in the active/imm memtables but not yet flushed to object storage).
d
yeah, that would make sense. I'll open a PR with my changes
c
cc @flaneur233 is my understanding correct here?
d
I opened this PR as a draft: https://github.com/slatedb/slatedb/pull/759
f
agree, when Remote is set, i think the data we should should always be considered as Committed, thus we can not read
Remote
persisted data that not committed 😯
d
I think that makes sense, but it opens the question about whether
dirty
affects the read when DL is remote or not. I left a comment with more data in the PR: https://github.com/slatedb/slatedb/pull/759#issuecomment-3172891685
c
@flaneur233 I'm thinking through how to best test this stuff. It appears to be that a single batch is no longer atomically written to durable storage.
batch_write.rs
currently appends row-by-row to the WAL buffer, which might flush at any moment. Is this intend behavior? I thought we had the invariant that a single write batch will always be durably written as a single WAL SST (or single L0 SST if WAL is disabled). Without this invariant, we can end up with a single batch being partially written if a failure occurs half way through, right?
d
look at my latest commit in the PR. I don't know if it's a hack or not, but it makes the DST tests pass 😅 https://github.com/slatedb/slatedb/pull/759/commits/89fe44708c30e97f9631a605a067eeb9e3070b98
c
Hmm, I'm think this works. The patch appears to: 1. Track when writes are flushed by dst.rs 2. Always return reads if read durability level is Memory. 3. Only return a read for a key if it's been flushed. That said, I think it does leave a gap in our state exploration: what if
wal_buffer.rs
(wal enabled) or
mem_table_flusher.rs
(wal disabled) flushes data before
dst.rs
calls flush? That data should be visible even if we haven't called flush yet. This leaves a gap in the state exploration (but not technically wrong).
But for now, I think this strategy is good, since it at least expands our state exploration space (even though it's not complete)
Separately, I think we should wrap both the sized tree and the real
Db
in a single
DstDb
or something. That thing should coordinate writes, deletes, and flushes to both the sized tree and the
Db
so it's easier to keep things in sync. This is mostly just a code cleanliness thing that's been on my mind, but this PR makes me think now's the time to do it.
Actually, I need to think on this a bit more.. the patch conflates isolation (dirty) with durability a bit.. need to think on this
d
yeah, I didn’t change any semantics around dirty reads. I saw tests failing regardless of it, so I addressed just the durability aspect of the state management
I can make that refactor to wrap both structures into a single one. It might be better to address other variables in future PRs to keep things small
c
Thinkin a bit.. there are so many scenarios lol
What we really need is visibility into these:
Copy code
pub(crate) struct Oracle {
    /// is assigned immediately when a write begins, it's possible that the write
    /// has not been committed or finally failed.
    pub(crate) last_seq: Arc<MonotonicSeq>,
    /// The sequence number of the most recent write that has been fully committed.
    /// For reads with dirty=false, the maximum visible sequence number is capped
    /// at last_committed_seq.
    pub(crate) last_committed_seq: Arc<MonotonicSeq>,
    /// The sequence number of the most recent write that has been fully durable
    /// flushed to the remote storage.
    pub(crate) last_remote_persisted_seq: Arc<MonotonicSeq>,
}
Ok, ya so I think your patch works for the way things are set up..
Because we currently block on write_with_options in our run_simulation loop untiul the write returns. This means, if await_durable is false, we block until the write is committed, and if await_durable is true, we block until the write is persisted to storage. The patch change means that, on dirty=true, we see all committed data, which is guaranteed since we block on write until the data is committed. on dirty=false, we are very conservative and only check writes that are guaranteed to be written to object storage becasue we called
flush
. This still leaves a bunch of gaps in state exploration, but is an improvement on our current defaults that don't explore any of this. 😛
f
> It appears to be that a single batch is no longer atomically written to durable storage. batch_write.rs currently appends row-by-row to the WAL buffer, which might flush at any moment. Is this intend behavior? I think this is a very reasonable concern. I previously wanted to use
maybe_trigger_flush
to ensure that flush is triggered after batch writes, but after double thinking, this mechanism cannot guarantee that flush always happens at batch boundaries.. it's possible that after
maybe_trigger_flush
, the actual write occurs halfway through the next batch... I think
maybe_trigger_flush
might need to work together with a lock for appends, or freeze the WAL's kvtable within
maybe_trigger_flush
..