https://slatedb.io logo
I'll do some more rigorous testing and
# general
c
I'll do some more rigorous testing and patch it tomorrow (codex made a kinda messy patch that fixes it, but I want to clean it up)
p
I am so excited for this patch
Finally 😂
c
hahaha
p
Very cool that you found what it was
c
I am stil lfighting with it
:/
wackamole
Stay tuned 😛
p
Some implementation issue or hard to pinpoint what's going on?
c
the latter 🙁
I keep thinking I have it fixed and then it keeps failing 😛
p
At least we have a repro... 😄
c
thankfully it fails fast and is easy to produce locally
p
Yes
c
haha yea
Makes me confident we'll get it. I think my mental model of it is just busted in some weird way I haven't yet figured out.
p
@criccomini What about rethinking this and having a more naive approach, say have a exclusive access between the gc and compactions with a priority on the gc that gets "enqueued" right after the last compaction job?
c
@Rohan I'm a little confused about this code:
Copy code
rs
  pub(crate) fn new_checkpoint(
      &self,
      checkpoint_id: Uuid,
      options: &CheckpointOptions,
  ) -> Result<Checkpoint, SlateDBError> {
      let clock = self.clock.clone();
      let db_state = &self.inner.object().core;
      let manifest_id = match options.source {
          Some(source_checkpoint_id) => {
              let Some(source_checkpoint) = db_state.find_checkpoint(source_checkpoint_id) else {
                  return Err(CheckpointMissing(source_checkpoint_id));
              };
              source_checkpoint.manifest_id
          }
          None => {
              if !db_state.initialized {
                  return Err(InvalidDBState);
              }
              self.inner.id().next().into() // Why do we do next() here?
          }
      };
      Ok(Checkpoint {
          id: checkpoint_id,
          manifest_id,
          expire_time: options.lifetime.map(|l| clock.now() + l),
          create_time: clock.now(),
      })
  }
As I read it, if no checkpoint source is provided, we set the manifest_id for the checkpoint to the next manifest that will be written rather than the current manifest (the most recently written one). Is this intentional? It seems off to me.
That's roughly equivalent to what the compactor state persistence stuff will do. The theory was that my little hacky patch would be a quick workaround 😛
Sadly it appears to .. not work lolsob
p
🫨
Wouldn't, a very hacky solution but perhaps sound enough be to just share a mutex between the compactor and the gc?
Definitely won't fly long term but as a quick fix...
r
> As I read it, if no checkpoint source is provided, we set the manifest_id for the checkpoint to the next manifest that will be written rather than the current manifest (the most recently written one). Is this intentional? yeah, that way if you have other changes to the manifest they get included in the checkpoint
is it causing a problem? the compactor writes its checkpoint before applying the state updates so it should still reference the old ssts
c
Ok, I noticed the SSTs that seem to be missing seem to always be L0. Do you guys think this is possible?
Copy code
1. New L0 is written
2. 100ms passes
3. GC lists SSTs
4. GC sees L0 SST from (1)
5. GC deletes L0 SST from (1) (it is > min_age=100ms old and is not in any manifests)
6. L0 is added to manifest
7. Manifest is written to object storage
(trying to replicate in test..)
p
I actually wanted to check this hypothesis the other day
c
suspect we need to limit deletions to any SST with a ULID timestamp > the lowest active L0 SST
Yea, so I fixed the L0 race issue, but still see the original thing you reported Pierre. Inspecting the state and logs, I can see that the GC is deleting the file correctly and it is an expired file. So at this point I am leaning toward the compactor running on a stale state, scheduling a compaction for stuff that’s been deleted. I will continue investigating tomorrow…
Been staring at this for hours.. need to let my brain recover
This really opened a can of worms lol
Yep, here's some interesting logs. You can see that: 1. SST 01KAC7R7CZBFNH73AZ0EA58PCK.sst is written 2. GC detects 01KAC7R7CZBFNH73AZ0EA58PCK.sst as ready for deletion (it is) 3. GC deletes 01KAC7R7CZBFNH73AZ0EA58PCK.sst 4. A compaction job with ID 01KAC7RCEXDP6JSWR8TP31KE4X is submitted with input SSTs = [2131934471718904712261223295296493971] (01KAC7R7CZBFNH73AZ0EA58PCK in u128 for) https://cdn.discordapp.com/attachments/1439864083053809684/1440430077618946099/message.txt?ex=691e208c&is=691ccf0c&hm=3e50a1af1d776c770c9c60073050382fb9fbc5da2d8a0bdf65c977561a1b8131&
(you'll have to download the file to see the log.. the discord preview is truncated)
p
@criccomini Is there not some step with writing a new manifest? Otherwise, how in this scenario would you get a corrupted database?
c
Lemme see
To make sure I understand: you're saying the error you see is on read, right?
p
Yes
(IIRC?)
c
yea just re-read your comment
And the DB was just totally hosed after this? You couldn't re-open it?
p
I cannot recall, I can reproduce again if that's helpful
c
Could you reproduce in a test 😅
I'm having trouble. I used the configs you supplied
I can get the compactor to do weird stuff
p
ok
c
But it recovers
p
Ok let me try
on it
c
th
p
Ah yeah now I recall
I get what looks like an infinite loop
Copy code
2025-11-18T20:27:21.547471Z  INFO slatedb::compactor: in-flight compaction [compaction=["l0", "l0", "l0", "l0", "l0", "l0"] -> 0]
2025-11-18T20:27:21.567001Z  INFO slatedb::retrying_object_store: retrying object store operation [error=NotFound { path: "zerofs2/compacted/01KACAC51YCV8S1PRY50P5YH2J.sst", source: RetryError(RetryErrorImpl { method: GET, uri: Some(https://<account>.blob.core.windows.net/zerofs/zerofs2/compacted/01KACAC51YCV8S1PRY50P5YH2J.sst), retries: 0, max_retries: 10, elapsed: 3.160234ms, retry_timeout: 180s, inner: Status { status: 404, body: Some("\u{feff}<?xml version=\"1.0\" encoding=\"utf-8\"?><Error><Code>BlobNotFound</Code><Message>The specified blob does not exist.\nRequestId:ce48ff7a-d01e-0070-0ac9-58c6af000000\nTime:2025-11-18T20:27:21.5658080Z</Message></Error>") } }) }, duration=4s]
But indeed
It doesn't look like the db is actually corrupted?
The question is, is this actually infinite then
So it's different than the initial gc bug
Because this actually broke the database before
c
IIRC, with 404 it retries forever
c
In 0.9.0, it might be limited to 5m tho
p
So it prevents making space in l0
c
yea if it blocks the compactor, L0's will pile up until backpressure is applied
p
So, do that confirms that?
At least it's good to know that no data is lost
c
If you try restarting, does everything work as expected?
I don't think it should corrupt
So a restart should work
p
When I restart:
c
Yea... so it seems like it's referencing an L0 SST in the manifest, which doesn't exist
I wonder if you're seeing the bug I have a PR up for
Can you try replicating it with my patch applied? I'm curious if it fixes that
p
Are you sure?
When you look at it it just seems that it gets a new compaction job immediately
Copy code
2025-11-18T20:32:35.871072Z  INFO slatedb::db::builder: opening SlateDB database [path=zerofs2, settings={"flush_interval":"30s","manifest_poll_interval":"1s","manifest_update_timeout":"300s","min_filter_keys":1000,"filter_bits_per_key":10,"l0_sst_size_bytes":67108864,"l0_max_ssts":16,"max_unflushed_bytes":1073741824,"compactor_options":{"poll_interval":"5s","manifest_update_timeout":"300s","max_sst_size":268435456,"max_concurrent_compactions":8},"compression_codec":null,"object_store_cache_options":{"root_folder":"/mnt/.cache/zerofs/bucket_f0e4174f/slatedb","max_cache_size_bytes":200000000000,"part_size_bytes":4194304,"cache_puts":true,"preload_disk_cache_on_startup":null,"scan_interval":"3600s"},"garbage_collector_options":{"manifest_options":{"interval":"100ms","min_age":"100ms"},"wal_options":{"interval":"100ms","min_age":"100ms"},"compacted_options":{"interval":"100ms","min_age":"100ms"}},"default_ttl":null}]
2025-11-18T20:32:35.922613Z  INFO slatedb::compactor_state: accepted submitted compactor job [job=["l0", "l0", "l0", "l0", "l0", "l0", "l0", "l0"] -> 0]
2025-11-18T20:32:35.922642Z  INFO slatedb::compactor: in-flight compaction [compaction=["l0", "l0", "l0", "l0", "l0", "l0", "l0", "l0"] -> 0]
c
When you restart, it's scheduling compactions because it sees L0 is full in the manifest
But the input SSTs it's scheduling for appear not to exist in the object store
p
Got it
c
L0 SSTs can be missing due to the bug described in https://github.com/slatedb/slatedb/pull/1028
p
Let me try
c
🤞
running with min_age and interval at 0 is quite informative lol
I want to run the chaos tests this way I think...
p
Arghh, this is hanging Updating git repository
https://github.com/slatedb/slatedb.git
c
🤔
p
After cloudflare down 3 hours
Now it's github? 😄
Copy code
git clone "https://github.com/slatedb/slatedb.git"
Cloning into 'slatedb'...
Yeah this is broken
c
lolsob
p
Testing right now
Still happen
Copy code
2025-11-18T21:44:30.018610Z ERROR slatedb::compactor: error executing compaction [error=ObjectStoreError(
    NotFound {
        path: "zerofs3/compacted/01KACESF0VF3KEHRWD2TVY6PPT.sst",
        source: RetryError(
            RetryErrorImpl {
                method: GET,
                uri: Some(
                    https://merklemap.blob.core.windows.net/zerofs/zerofs3/compacted/01KACESF0VF3KEHRWD2TVY6PPT.sst,
                ),
                retries: 0,
                max_retries: 10,
                elapsed: 2.757995ms,
                retry_timeout: 180s,
                inner: Status {
                    status: 404,
                    body: Some(
                        "\u{feff}<?xml version=\"1.0\" encoding=\"utf-8\"?><Error><Code>BlobNotFound</Code><Message>The specified blob does not exist.\nRequestId:6c361106-201e-005b-42d4-584663000000\nTime:2025-11-18T21:44:29.9895138Z</Message></Error>",
                    ),
                },
When restarting
Copy code
2025-11-18T21:44:50.911892Z  INFO slatedb::compactor_state: accepted submitted compaction [compaction=["l0", "l0", "l0", "l0", "l0", "l0", "l0", "l0"] -> 3]
2025-11-18T21:44:50.911924Z  INFO slatedb::compactor: in-flight compaction [compaction=["l0", "l0", "l0", "l0", "l0", "l0", "l0", "l0"] -> 3]
2025-11-18T21:44:50.912017Z  INFO slatedb::compactor: in-flight compaction [compaction=["l0", "l0", "l0", "l0", "l0", "l0", "l0", "l0"] -> 3]
2025-11-18T21:44:50.915257Z  WARN slatedb::mem_table_flush: won't flush imm to l0 because too many l0 files [l0_len=16, l0_max_ssts=16]
2025-11-18T21:44:51.290212Z  INFO slatedb::retrying_object_store: retrying object store operation [error=NotFound { path: "zerofs3/compacted/01KACESF0VF3KEHRWD2TVY6PPT.sst", source: RetryError(RetryErrorImpl { method: GET, uri: Some(https://merklemap.blob.core.windows.net/zerofs/zerofs3/compacted/01KACESF0VF3KEHRWD2TVY6PPT.sst), retries: 0, max_retries: 10, elapsed: 2.52709ms, retry_timeout: 180s, inner: Status { status: 404, body: Some("\u{feff}<?xml version=\"1.0\" encoding=\"utf-8\"?><Error><Code>BlobNotFound</Code><Message>The specified blob does not exist.\nRequestId:573fc436-901e-00d8-71d4-585801000000\nTime:2025-11-18T21:44:51.2888703Z</Message></Error>") } }) }, duration=1s]
r
@criccomini I was looking at the gc code while looking at something unrelated but noticed this which might be relevant. Seems like there's a bug here: https://github.com/slatedb/slatedb/blob/d788c8afa1d934da38cee05c385f9c6835a8ee1b/slatedb/src/garbage_collector/compacted_gc.rs#L126 The low watermark gets set to None if there are no running compactions. That stat (
RUNNING_COMPACTIONS
) is set by the executor before the manifest is written. If the low watermark is None then the SST is included in the filter and could get GCd before its added to the manifest.
why even condition setting the watermark on
RUNNING_COMPACTIONS
?
c
Yup
This is what I'm thinking as well. I got rid of it yesterday to see if it would fi it, and it didn't
I suspect as Pierre said that we had multiple issues
My hope is that removing that None will fix it now that the L0 thing is ALSO fixed (I'm working off a branch of that)
But it seems clearly wrong
First thing I want to do is just get a decent test.. the one I had was to high-level so I think it was surfacing multiple bugs
The
none
would explain the logs I pasted above
I think we just need to live with the fact that if there are no compaction jobs running, we won't delete anything that was written later than the last compaction run
I think that's fine
I also think there might be an issue with wher I'm updating the watermark--need to check that
Though it'd be irrelevant if I just remove the None
Can you post your test?
The sequence of events to reproduce this is .. a lot lol
I feel like we need a little lab for writing these scripts .. I wonder if the Python API will suffice
Rust is so cumbersome for these little things
Ah, wait, I reproduced it!
thread 'db::tests::test_gc_race_deletes_compaction_output_before_manifest_update' (37906674) panicked at slatedb/src/db.rs:5643:9: expected compaction outputs to still exist yey
Yep, removing the None's did it now
thank god... lemme run the whole suite now. that was not fun.
Multiple bugs suck
@Pierre want to give this one a shot? https://github.com/slatedb/slatedb/pull/1029
p
So it's basically mount zerofs with tiny gc params
and dd if=/dev/urandom of=./test bs=10M status=progress oflag=direct
c
I think I was able to reproduce it anyway.. there's a test in 1029 that does so
p
I just need /1029? I'll try now
c
So I think if you could confirm the patch works, that would be good news
🤞 🙏
p
Let me try
It's running
No, still there
Copy code
2025-11-19T07:11:34.038314Z  INFO slatedb::compactor: in-flight compaction [compaction=["l0", "l0", "l0", "l0"] -> 4]
2025-11-19T07:11:35.380044Z  WARN slatedb::db: unflushed memtable size exceeds max_unflushed_bytes. applying backpressure. [total_mem_size_bytes=1077076149, wal_size_bytes=538541474, imm_memtable_size_bytes=538534675, max_unflushed_bytes=1073741824]
2025-11-19T07:11:35.512558Z  INFO slatedb::retrying_object_store: retrying object store operation [error=NotFound { path: "zerofs4/compacted/01KADF8DRZ2M9N031BVY6HD0XD.sst", source: RetryError(RetryErrorImpl { method: GET, uri: Some(https://merklemap.blob.core.windows.net/zerofs/zerofs4/compacted/01KADF8DRZ2M9N031BVY6HD0XD.sst), retries: 0, max_retries: 10, elapsed: 3.022197ms, retry_timeout: 180s, inner: Status { status: 404, body: Some("\u{feff}<?xml version=\"1.0\" encoding=\"utf-8\"?><Error><Code>BlobNotFound</Code><Message>The specified blob does not exist.\nRequestId:835fa066-101e-008b-5723-597b35000000\nTime:2025-11-19T07:11:35.5114908Z</Message></Error>") } }) }, duration=4s]
2025-11-19T07:11:39.527651Z ERROR slatedb::compactor: error executing compaction [error=ObjectStoreError(NotFound { path: "zerofs4/compacted/01KADF8DRZ2M9N031BVY6HD0XD.sst", source: RetryError(RetryErrorImpl { method: GET, uri: Some(https://merklemap.blob.core.windows.net/zerofs/zerofs4/compacted/01KADF8DRZ2M9N031BVY6HD0XD.sst), retries: 0, max_retries: 10, elapsed: 3.718788ms, retry_timeout: 180s, inner: Status { status: 404, body: Some("\u{feff}<?xml version=\"1.0\" encoding=\"utf-8\"?><Error><Code>BlobNotFound</Code><Message>The specified blob does not exist.\nRequestId:835fa5ff-101e-008b-1223-597b35000000\nTime:2025-11-19T07:11:39.5154263Z</Message></Error>") } }) })]
2025-11-19T07:11:42.547855Z  INFO slatedb::compactor_state: accepted submitted compaction [compaction=["l0", "l0", "l0", "l0", "l0", "l0", "l0", "l0"] -> 1]
@criccomini Do you want me to tell you the steps to reproduce with zerofs?
Perhaps that'd be easy
And it's 2 mins of setup on a linux vm
c
😿
fml.. let's do it tomorrow
This will be 3rd entire day spent incinerating time on this thing lol
It looks to me like that is running on Azure
So I assume I'd need that.. unless you think it works with InMemory
Plus then I'd need to build the crate custom
It will not take me 2 minutes, I'll be lucky if it takes 2 hours to get it set up and building correctly with custom crate and vm and object store.
Please try and make a unit test I can run
Else I'll see what I can do.... sigh
Was really hoping these patches would fix it...
I'm curious: did you check out the branch? or just apply the specific diff from that branch to 0.9.0?
p
> So I assume I'd need that.. I will try but I think it'll even work with file:///
c
Welp.. time for bed for me 🙁
p
> 'll be lucky if it takes 2 hours to get it set up and building correctly with custom crate and vm and object store. You are pessimistic 😄
c

https://tenor.com/i7UZjb1R5AD.gif▾

p
Appropriate LOL
Anyway thank you and rest well
c
No prob.. we'll get it
p
I'll dig too
c
Thanks. A unit test would be SO helpful.
(Or integration)
p
Would a actions workflow work for you?
That I'd submit as a PR against slatedb just so that it's easy to run?
c
Ya that could work!
p
Yeah I tried https://github.com/slatedb/slatedb/pull/1031 as a quick fix but no
It does seem hardeer to trigger that way though lol
c
Yea.. noodling on this a bit. Need to take kid to school
p
@criccomini Following your comment, is it stupid to add a mutex there to serialize as you say?
c
Yea we can do that.. I'm just trying to keep things from getting even more hacky
I want to try a CompactionStatus approach which would let us serialize the low watermark updates so we always pick the lowest
p
If it’s temporary, who cares if it’s sound? 🤪
c
That's how I got into this mess in the first place
p
Fair 😅
r
> https://github.com/slatedb/slatedb/pull/1029#issuecomment-3554355450 @criccomini did this change with the introduction of message dispatcher? The whole compactor loop assumes its running as a single task and is fully serialized.
c
Ah no you're right, it's a single event loop. the ticker just spits messages into the channel which are processed iteratively
sigh
r
whew. got a little scared
actually rust really protects us here.
handle
takes a
&mut
and nothing in the compactor would work without a mutable reference to self. which can't be shared. So you wouldn't be able to change it without considering the synchronization
c
hahaha my bad 😛
Every time I think I have this pinned down.. it still fails lol
I tried you suggestion of moving the watermark read before the active sst/manifest read and that didn't help
Now I'm trying to use compaction status to keep track of "complete" but not "persisted" jobs.. so we can use the min timestamp for all non-persisted jobs... even that doesn't work
I thought for sure that would...
p
@criccomini What about preventing the GC to run when the compactor is active?
Gc runs fast and not often
c
K, I think I have a fix
p
May the lord be with you
c
lol
p
🤣
c
I ended up just doing @Rohan 's L0-only barrier that he mentioned in 1028. I kinda hate it, but it's the least invasive.
... and more importantly: it works
p
So cool
c
Copy code
1. GC lists and sees L0 SST with ts=2 (written by the writer)
2. L0 SST with ts=2 is not in active manifest (writer hasn't yet added it)
3. Oldest compaction job started at ts=4
4. Oldest compaction job writes a compacted SST with ts=5 (manifest has been update with max(SST ts) = 5)
5. Oldest compaction job finishes and updates watermark (ts 4 for the watermark barrier)
5. min_age is configured to 0, min_age_cutoff = now - 0 = ts 7
6. calculated cutoff is min(7, ts 4, ts 5) = ts 4
7. Writer updates manifest with L0 SST with ts=2 (it's not active and visible to the compactor)
8. Compactor schedules a compaction job with input L0 SST with ts=2
7. GC deletes SST with ts=2
9. Compaction job with input L0 SST with ts=2 runs and fails forever.
10. Manifest poinst to dead L0 SST with ts=2 forever
I think it's something like this
@Pierre wanna try the latest fix? https://github.com/slatedb/slatedb/pull/1028
p
@criccomini Want me to try your patch with zerofs now?
c
Yes please!
p
Doing it now
Ah same thing on the mind 🙂
c
🤞
p
It's running for now all good
Let's make it run for something like 10 mins to see
But so far it's never been running that long
Copy code
2025-11-19T21:20:24.498387Z  INFO slatedb::retrying_object_store: retrying object store operation [error=NotFound { path: "test2144567/compacted/01KAEZSF3GDYMGACPDSHH10TMJ.sst", source: RetryError(RetryErrorImpl { method: GET, uri: Some(https://merklemap.blob.core.windows.net/zerofs/test2144567/compacted/01KAEZSF3GDYMGACPDSHH10TMJ.sst), retries: 0, max_retries: 10, elapsed: 2.325851ms, retry_timeout: 180s, inner: Status { status: 404, body: Some("\u{feff}<?xml version=\"1.0\" encoding=\"utf-8\"?><Error><Code>BlobNotFound</Code><Message>The specified blob does not exist.\nRequestId:15c4896e-601e-00f3-7d9a-59d8cd000000\nTime:2025-11-19T21:20:24.4967370Z</Message></Error>") } }) }, duration=2s]
But perhaps it's due to @Rohan comments
c
🫠
p
This time it lasted way longer before failing
c
fixing

https://tenor.com/hSCXP8S34mf.gif▾

p
On the + side it's pretty good to catch this kind of stuff early in the life of slatedb
c
wrapping up
rust compilation is so slow...
p
Yes, especially when there is a bit too much macros and generics
c
@Pierre want to try with the latest push?
😭
p
Doing it
Confidence level? 😄
c
eh.. 5 out of 10
I am a broken man
p
💀
Didn't error yet
Still fine
c
🥵
intensity intensifies
p
🤣
I think it's fine on my end because it didn't error yet
Ah fuck
Copy code
2025-11-19T22:52:18.982503Z  INFO slatedb::retrying_object_store: retrying object store operation [error=NotFound { path: "test21445678/compacted/01KAF50JJN08GFXN5R2BYSJXE8.sst", source: RetryError(RetryErrorImpl { method: GET, uri: Some(https://merklemap.blob.core.windows.net/zerofs/test21445678/compacted/01KAF50JJN08GFXN5R2BYSJXE8.sst), retries: 0, max_retries: 10, elapsed: 2.592276ms, retry_timeout: 180s, inner: Status { status: 404, body: Some("\u{feff}<?xml version=\"1.0\" encoding=\"utf-8\"?><Error><Code>BlobNotFound</Code><Message>The specified blob does not exist.\nRequestId:fa5208a1-501e-0023-21a7-59e59b000000\nTime:2025-11-19T22:52:18.9815376Z</Message></Error>") } }) }, duration=4s]
c
....
Welp.
Gonna take a break.
Ah wait
Rohan spotted one more thing
r
c
fml I lost the ordering when I broke out the manifest snapshot
good catch
I can't even see straight with this shit anymore..
@Pierre Just pushed. Try again.
p
Ok
It's running
c
it's gonna work
mic drop
p
Have a beer after that lol
c
I forgot to eat anything today. I will celebrate with .. food
p
@criccomini My repro works fine with this?
c
yup
Until it torches my laptop anyway
p
(Side note, the new (1128038962 bytes processed)] in compaction logs would be nice to be human readable)
c
haha noted
That one seems like a GH issue + community PR would be good (good first issue)
Mind opening that.. I'm drained
p
Yeah, for sure
(Tomorrow, midnight here, trying this before sleeping, need to wake up early)
I think it's fine
Because it doesn't fail on my end
c
Nice!
Let it run over night? Or for some extended period?
Else we can merge and cut a 0.9.2
p
Ah I went out of computer, let me do that morning
So that when it’s your morning it would have run for around 10 hours
c
Kewl
Follow the sun coverage! Gotta love it
p
Ahaha
Hmm looking at my terminal from last night
Uh
Copy code
2025-11-20T08:42:47.945157Z ERROR slatedb::compactor: error executing compaction [error=ObjectStoreError(
    NotFound {
        path: "test214456789/compacted/01KAF5YRB7SDG6WY1273MV4BR1.sst",
        source: RetryError(
            RetryErrorImpl {
                method: GET,
                uri: Some(
                    https://merklemap.blob.core.windows.net/zerofs/test214456789/compacted/01KAF5YRB7SDG6WY1273MV4BR1.sst,
                ),
                retries: 0,
                max_retries: 10,
                elapsed: 2.769386ms,
                retry_timeout: 180s,
                inner: Status {
                    status: 404,
                    body: Some(
                        "\u{feff}<?xml version=\"1.0\" encoding=\"utf-8\"?><Error><Code>BlobNotFound</Code><Message>The specified blob does not exist.\nRequestId:57afc7ce-601e-00dc-75f9-59d506000000\nTime:2025-11-20T08:42:47.9221049Z</Message></Error>",
                    ),
                },
            },
        ),
    },
)]
What's weird is that there was no write traffic full night
Ok so it takes around 20 mins to repro
But I am able to consistently break it, still
I pushed https://github.com/slatedb/slatedb/pull/1035 that seems to fix it completely
It's been running 1 hour with this patch, still fine
c
Thanks! Will take a look. I was under the impression that inputs were protected by our active SST manifest check.
Perhaps there is a race condition where one compaction sees another compactions output before either one has been written to the manifest, and thus the input is not protected…
I don’t think that should happen because the compactor event loop is single threaded. But maybe something in the compactor executor is causing this race. The executor is parallel and concurrent.
p
Won't lie, I'm not too confident in my patch
Would be good to know what's actually going on there
c
Then there’s so many edge cases with this stuff, the only way to be confident is really to test the heck of it I think. Either that or fizzbee.
p
@criccomini I think adding some form of locking would be pretty beneficial
Don't gc before we have the state sorted out
Gc doesn't have to run at the same time as the compactor
c
Yeah. Or just move the GC into the compactor event loop so it’s fully serial . That is what @User was asking about.
p
I fear this is going to always be somewhat flimsy otherwise
Could be in the same select!
c
Exactly
p
I think that makes sense, it's too messy right now IHMO
And I don't trust it lol
c
I opened a GH issue about this. I was a little skeptical, but maybe it warrants another look
p
When you think about it, the gc is a product of the compactor
It doesn't make much sense as an independent component
Because if the compactor didn't produce work, the gc would be useless
So they are interdependent thus, it's not ugly if they live together
Especially as the gc barely does any work
c
p
I think that'd be great
I don't believe anyone is going to be confident about the soundness of it in the current state
I was going to argue basically what you say here: https://github.com/slatedb/slatedb/issues/993#issuecomment-3507256030
I think it's great
c
K, I have breakfast booked with a friend. I’ll try and take a look after that.
Unless you want to take a crack at the PR in the meantime😁😁😁😁
p
Starting from master right?
c
cc @Rohan to keep you in the loop on this discussion.
Yeah, I think that would be fine. The one thing to consider is that we still need to cover the L0 case. Since the writer is on a separate event loop, it is not protected by the serialization. When it writes L0s, they are not yet in the manifest.
p
Couldn't the compactor communicate to the gc which l0s to process?
For crash cleanup, this can be done on startup
c
What happens if the writer is running when the compactor starts up?
p
I think it's a non issue because the compactor has to retrieve state when starting up
c
But there can be a recently written L0 from the writer that is not yet in the manifest state. I think we would have to prevent it from GC any SST’s newer than the latest one in the manifest.
p
Ah, so we are kind of back at square one hmm
c
Yeah, the writer and the compactor are always going to be separate
p
@criccomini What about adding state to the object store keys themselves? ...
c
Effective a version of what the plan was: coordinate the state through the object store. I prefer using the compaction strategy we already have in that case.
p
Yeah, makes sense
c
I think fundamentally the issue right now is that we are mixing in memory state with object store state in the GC and compactor. The GC can see both in memory state from the compactor because of my patch, as well as perhaps stale manifest state from the object store. Everything needs to be in the object store in order to give us a complete consistent view and make correct decisions on.
That’s a strong argument to just forge ahead with the compactions state persistence plan we had
p
What's a bit annoying is that it requires quite a bit more object store API operations, right?
Thinking about it, isn't it more that we store l0s before they are recorded anywhere else?
c
Yea that’s half. The other half is we store compaction output before it’s recoded elsewhere.
Nah, it’s identical protocol to the manifest protocol we already have. Rohan already abstracted it too.
a
just saw I was pinged on this 🫠 is there a summary of this thread?
c
@almog we were just discussing whether moving the GC into the compactor event loop would be helpful
a
ah yes! I'm all for it haha - what are the reasons not to?
c
My main gripe is/was deployment complexity, especially as we got to distributed compaction
I like the idea of just spinning up GC whenever/wherever we want without having to think about it
By coupling it with the compactor, we have to think through what tha means for deployment. It also means that the very easy way we can trigger "one_gc_once" now goes away--we'd need to do stateful compaction requests like we plan to do for external compaction requests.
I really prefer decentralization with the central coordination being data on object storage.. just my personal pref tho
vs. trying to unify and couple stuff in-process/in-memory
anywa
Back into the salt mine to figure out this bug..
@Pierre does the test you gave me reproduce it? Or just your actual workload?
a
Yeah I can see the appeal of decentralizing everything, it also tees us up well for a future where SlateDB is componentize and you can pick and choose the parts you need to build your system
p
I didn’t try but I see no reason why it wouldn’t work
Perhaps you’d need a vm for a longer runtime though?
c
hmm
r
+1 to the motivations above for keeping the GC decoupled. As @criccomini mentioned above it also doesn't fundamentally solve the problem of cross-process coordination since L0s are still written by the writer. Another good reason is checkpoints. If a db has a large tree of checkpoints/clones it puts a lot of burden on its GC. It's also possible that the db writer may no longer be running. So it's useful to have the option to run a gc process decoupled from the writer
c
Man I'm really struggling to come up with why this is breaking now though lol
I am basically manually doing fizzbee tests at this point lol
p
Doesn’t my patch help a bit?
To guess where it’s coming from?
c
IDK I feel like it works but hides the actual issue
It shouldn't make a difference...
> /// Pre-computed when the compaction is created to avoid > /// races with manifest updates. This is the part I don't get...
I feel like it might be hiding an issue with l0 or something
a
If you ever want to rubber duck I can hop on a zoom (I have little context, but maybe talking it out will help?)
c
I'll let you know.. right now it's pencil and paper time
@Pierre mind trying a run on the latest commit in my PR? I adjusted the compaction job watermark update sto be more conservative .. it only updates when jobs finish now (it used to update when jobs were submitted as well)
It also has some better debug output
We should be able to see when the GC is deleting the file that you're getting 404s on now
I have a slight concern that there is a possibility a new job starting could advance the watermark prematurely
p
Sorry I am not at home 🙁
c
dang
Unfortunately, the gc-repro code dies on my laptop after a while
LMK when you have a chance to test it. At the very least, I'd like to see the logs around the "deleting .. " line that I added when the GC deletes the SST that later appears as a 404
p
Perhaps on a small vm?
c
I just found that I can drop the memory pressure by reducing the batch size per-loop.. I did that and it still reproduces the error on the commit before my most recent.. lemme try on my most recentn ow
p
Oh great!!
c
🤞
My laptop is quite warm right now 😛
Nice on a rainy day
lol ran out of disk space
... but it didn't 404
so .. I am really curious if the current pr commit works for you
p
I’ll do a long run tomorrow as soon as I can
c
Yea man, this is promising.
The commit prior to the latest, I get a NotFound very quickly
On the latest commit (where I only advance low watermark when a job finishes, not when it starts) I have run out of disk space several times and not seen a NotFound yet
😬
p
Sounds very cool
What I am just a bit bothered about is that we don’t really feel confident about the solution lol
It’s a bit annoying because slatedb is pretty solid, this small part feels flimsy
And kind of not an easy problem at all
🫠
c
I agree. I hate what we're doing with this, but I'd rather stabilize what we have first, then implement the proper compaction state protocol that Sujeet documented in RFC13. The current approach was always meant to be temporary. It just ended up being more painful to get right than I anticpated (sigh).
Anyway, this experience has made me very motivated to get the compactor state in before 0.10 goes out.. or at least the bare minimum we need to ditch this low-watermark garbate.
Once we ditch in-memory coordination (the metric hack), I hope things go smoother. There are so many races between in-memory and on-objet-store... it's nasty
p
Currently running against your last commit @criccomini
c
intensity intensifies
p
Ahaha
I ran so much data through slatedb that I am pretty confident that everything else works though 😄
c
Hahaha.. you're a glass-half-full guy.. I admire that
p
TBH, it's a bit due to how much I am excited for slatedb, it's insane to me that it didn't go viral yet
Makes the distributed part of distributed systems "not my job" as it's delegated to whatever s3 provider you choose, pretty cool
Storage is the single most painful thing I always had to deal with in infra related work
Ah, this new log is cool
Copy code
2025-11-21T05:45:59.031278Z  INFO slatedb::compactor: in-flight compaction [compaction=["l0", "l0", "l0", "l0", "l0", "l0"] -> 82]
2025-11-21T05:46:00.546076Z  INFO slatedb::compactor_state: finished compaction [spec=["l0", "l0", "l0", "l0", "l0", "l0"] -> 82]
2025-11-21T05:46:03.541853Z  INFO slatedb::garbage_collector::compacted_gc: deleting SST [id=SsTableId::Compacted(01KAJE9JH8CC24DHD1VZE0H08K)]
2025-11-21T05:46:03.546374Z  INFO slatedb::garbage_collector::compacted_gc: deleting SST [id=SsTableId::Compacted(01KAJE9M235TEP6WAWGQRR4MYW)]
2025-11-21T05:46:03.550084Z  INFO slatedb::garbage_collector::compacted_gc: deleting SST [id=SsTableId::Compacted(01KAJE9N4TDK8MNH72QFW8N15E)]
2025-11-21T05:46:03.554047Z  INFO slatedb::garbage_collector::compacted_gc: deleting SST [id=SsTableId::Compacted(01KAJE9PSV92HMD6VXBV2BADCB)]
2025-11-21T05:46:03.558071Z  INFO slatedb::garbage_collector::compacted_gc: deleting SST [id=SsTableId::Compacted(01KAJE9RHKJDZD12KMKG69JK0X)]
2025-11-21T05:46:03.562414Z  INFO slatedb::garbage_collector::compacted_gc: deleting SST [id=SsTableId::Compacted(01KAJE9SPHKZFXT88CDRT0MFH5)]
2025-11-21T05:46:06.036781Z  INFO slatedb::garbage_collector::compacted_gc: deleting SST [id=SsTableId::Compacted(01KAJE9V69D10Z256H1TN72BGJ)]
2025-11-21T05:46:06.041944Z  INFO slatedb::garbage_collector::compacted_gc: deleting SST [id=SsTableId::Compacted(01KAJE9WJC8Y458SQH94WJTEK0)]
2025-11-21T05:46:06.045936Z  INFO slatedb::garbage_collector::compacted_gc: deleting SST [id=SsTableId::Compacted(01KAJE9Y69XH9MBGFT5Q2Z65TT)]
2025-11-21T05:46:06.049968Z  INFO slatedb::garbage_collector::compacted_gc: deleting SST [id=SsTableId::Compacted(01KAJE9ZFQJ0KQSM8CBQKK9GJK)]
(Are we clearing the disk cache too on delete btw?)
@criccomini I tend to think that it's all good now
I will let it run a bit more but it failed before during this timeline
So unless there is again something else...
c
🥵
Yea I was able to repro it almost immediately prior to my last commit
Then with the last commit, I couldn't trigger it once
So that seems promising
Rohan's idea 😁
I feel like this attribute is underappreciated simply because not enough people have been on-call for a distributed system.
p
Worst piece of software I used in this space is https://www.gluster.org/
Never again lol
@criccomini Perhaps it's a bit too tight I guess, but do you think we can get a new minor version published with this? I really would love to put this in zerofs ASAP
(Perhaps as a -RC?)
c
Absolutely. Once we're comfortable with this patch, I'll cut an 0.9.2. I'll probably cut it against main after this patch is merged in, since that's effectively what we're testing against
p
Still fine with this test, I'll stop it now
c
Wonderful!
Man.. that's a load off
p
Yes, for sure
Time to move on LOL
c
please yes lol
p
Remind me a colleague one day, he was working on some web page
c
cc @Rohan
Once I get a ✅ from the committers, I'll merge and cut a release
p
He loads the page in front of me, it returns a 500
He immediately refreshes it, and makes it as if it never happened
And just denied that it ever happened, even though I just saw it LOL
c
hahahaha
i been there
p
"It's a fluke"
c
🙈 🙉 🙊
r
I gave it a ✅
it's still kind of unnerving we don't understand why the last patch fixes the problem
p
I've been running my "git clone" workload since about 10 hours now, without problem
c
Yea I hate this lol
I will spend some more time today thinking it through. I couldn’t come up with a reason yesterday.
@Pierre FYI- I am dealing with O'Reilly book stuff right now. Plan to spend a little time thinking through why the patch works in a few hours. I'll shoot to merge/release later this evening (pacific time).
p
Reviewing or writing?
c
I'm co-author on the 2nd ed of Designing Data Intensive Applications.
p
So cool 🙂
c
AI is so good for this stuff, but I still have to read it and make sure it didn't do anything embarrassing
O'Reilly is bugging us for "quiz questions" now for their safari online offering
p
Sure — You are absolutely right — !
c
Ya I'm very lucky. Managed to work with Martin at LinkedIn about 15 years ago.
I think they (O'Reilly) were hounding him to go faster and so he invited me to contribute. It's been a fair bit of work, but it turned out decent. Definitely room for a 3rd edition, too, at some point in the future.
Oh shit, did codex just solve the riddle?!
Copy code
• You’re right that the compactor’s event handler is serial. The problem is that write_manifest_safely retries and, on each retry, calls load_manifest(), which calls
  refresh_db_state() → maybe_schedule_compactions() → submit_compaction(), and submit_compaction bumps the low watermark even though the just-finished compaction’s SSTs still
  aren’t in any persisted manifest. GC runs independently and can interleave while we’re in that retry loop.

  Concrete timeline:

  - t0 01:09:58.855 — Compaction C1 finishes writing SSTs 01KAMHRNZKXBT2GYWXEJTDB8VD/01KAMHRP5TFNCYV9XXQ6RCHJXF to storage. They’re not yet in a manifest.
  - t1 — C1’s finish_compaction runs, removes C1 from the active map, then enters write_manifest_safely(). The first write hits a manifest version conflict and loops.
  - t2 — On the retry, write_manifest_safely calls load_manifest() → refresh_db_state() → maybe_schedule_compactions(). A new compaction C2 is submitted, and (old code)
    submit_compaction immediately bumps compaction_low_watermark_ts to C2’s ULID time (~01:09:59.319). C1’s SSTs are still absent from any persisted manifest.
  - t3 01:09:59.xxx — GC tick fires. It reads the advanced low watermark (~01:09:59.319), then reads the still-old manifests (no C1 SSTs), computes the cutoff, and deletes
    01KAMHRNZ…/01KAMHRP5… as “inactive and older than the cutoff.”
  - t4 — The manifest write for C1 eventually succeeds, but those files are already gone. A later compaction that tries to read them gets the 404 you saw.

  Why the patch fixes it: finish_compaction now updates the low watermark immediately after the manifest write (when the SSTs are actually visible) and submit_compaction no
  longer bumps it. So during write_manifest_safely’s retry loop, scheduling new compactions can’t advance the watermark past the just-finished SSTs; GC never sees a “new”
  watermark paired with an “old” manifest.
I think this makes sense?!
So the fix is just that I removed the update watermark call in the submit_compaction fn
> The problem is that write_manifest_safely retries and, on each retry, calls load_manifest(), which calls refresh_db_state() → maybe_schedule_compactions() → submit_compaction(), and submit_compaction bumps the low watermark even though the just-finished compaction’s SSTs still aren’t in any persisted manifest 🤯🤯🤯🤯🤯
so a manifest write conflict can cause the compaction low watermark to jump up since: 1. The finished job has been removed from the compactions map 2. The manifest write fails with a conflict 3. The manifest update conflict results in a low watermark bump to a more recent compaction job ULID timestamp 4. The finished job's output is now eligible to be deleted since it's ULID is < the lowest current active ULID and its output is not in the manifest yet.
r
Shit yeah that's it. Pretty impressive from codex
Lesson learned. Triggering compactions from manifest writes was a bad idea
c
Kinda insane it figured that out. I had to cuss it out three times but dang