Skip to content

feat(buffer): Disable flush-to-disk for ephemeral storage#5751

Merged
jjbayer merged 4 commits intomasterfrom
feat/buffer-ephemeral
Mar 20, 2026
Merged

feat(buffer): Disable flush-to-disk for ephemeral storage#5751
jjbayer merged 4 commits intomasterfrom
feat/buffer-ephemeral

Conversation

@jjbayer
Copy link
Copy Markdown
Member

@jjbayer jjbayer commented Mar 20, 2026

Follow-up to #5746: With our current setup using local SSDs we should not flush in-flight data to disk on shutdown, and rather attempt to process all data like we do for the in-memory buffer.

ref: INGEST-510

@linear-code
Copy link
Copy Markdown

linear-code bot commented Mar 20, 2026

@jjbayer jjbayer marked this pull request as ready for review March 20, 2026 09:17
@jjbayer jjbayer requested a review from a team as a code owner March 20, 2026 09:17
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: New is_ephemeral method is never called anywhere
    • shutdown() now uses self.is_ephemeral() for its flush guard, making the helper method actively used while preserving behavior.

Create PR

Or push these changes by commenting:

@cursor push f4454c5117
Preview (f4454c5117)
diff --git a/relay-server/src/services/buffer/envelope_buffer/mod.rs b/relay-server/src/services/buffer/envelope_buffer/mod.rs
--- a/relay-server/src/services/buffer/envelope_buffer/mod.rs
+++ b/relay-server/src/services/buffer/envelope_buffer/mod.rs
@@ -191,8 +191,9 @@
         // Currently, we want to flush the buffer only for disk, since the in memory implementation
         // tries to not do anything and pop as many elements as possible within the shutdown
         // timeout.
+        let is_ephemeral = self.is_ephemeral();
         match self {
-            Self::Sqlite(buffer) if !buffer.stack_provider.ephemeral() => {
+            Self::Sqlite(buffer) if !is_ephemeral => {
                 buffer.flush().await;
                 true
             }

This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

Comment thread relay-server/src/services/buffer/envelope_buffer/mod.rs Outdated
Comment thread relay-config/src/config.rs
Comment thread tests/integration/test_basic.py Outdated
Co-authored-by: Joris Bayer <jjbayer@gmail.com>
@jjbayer jjbayer enabled auto-merge March 20, 2026 09:46
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

relay_log::trace!("shutdown procedure not needed");
false
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ephemeral SQLite blocked by memory backpressure during shutdown

Medium Severity

When an ephemeral SQLite buffer returns false from shutdown(), the service loop continues to drain envelopes — matching the in-memory behavior. However, system_ready still gates unspooling on buffer.is_memory() || self.memory_ready(), and is_memory() returns false for all SQLite variants including ephemeral. Under high memory pressure (>80%), the ephemeral buffer gets stuck waiting indefinitely in system_ready, unlike the in-memory buffer which always bypasses that check. Data on ephemeral storage would then be lost when the process is eventually killed.

Fix in Cursor Fix in Web

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intended behavior. The memory implementation bypasses the memory check because it would otherwise get stuck -- it cannot lower memory pressure without unspooling & processing envelopes. The disk spooler, even the ephemeral one, can lower memory pressure by pausing the dequeue.

@jjbayer jjbayer added this pull request to the merge queue Mar 20, 2026
Merged via the queue into master with commit 96c1076 Mar 20, 2026
47 of 48 checks passed
@jjbayer jjbayer deleted the feat/buffer-ephemeral branch March 20, 2026 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants