Skip to content

fix(compression): correctness findings from compression audit#2803

Merged
ValentaTomas merged 2 commits into
mainfrom
lev-compression-correctness-fixes
May 25, 2026
Merged

fix(compression): correctness findings from compression audit#2803
ValentaTomas merged 2 commits into
mainfrom
lev-compression-correctness-fixes

Conversation

@ValentaTomas
Copy link
Copy Markdown
Member

@ValentaTomas ValentaTomas commented May 22, 2026

Compression-audit correctness fixes:

  • reject misaligned writes in Cache.WriteAtWithoutLock
  • cap V4 header LZ4 decompression at the size prefix
  • drop corrupt compressed cache entries on size mismatch
  • retry GCS 404 within a post-transition window with backoff
  • per-Read idle timeout on GCS range reads

@cla-bot cla-bot Bot added the cla-signed label May 22, 2026
@cursor
Copy link
Copy Markdown

cursor Bot commented May 22, 2026

PR Summary

Low Risk
Only lengthens a local/CI startup wait for the API health endpoint; no runtime product or security behavior changes.

Overview
CI service startup now waits up to 60 seconds (instead of the default 30) for the API process to pass its health check before failing the job. That only applies to the API step in the composite start-services action; other services keep the script default.

Reviewed by Cursor Bugbot for commit 6f9e52c. Bugbot is set up for automated code reviews on this repo. Configure here.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

❌ 2 Tests Failed:

Tests completed Failed Passed Skipped
2723 2 2721 5
View the full list of 2 ❄️ flaky test(s)
github.com/e2b-dev/infra/tests/integration/internal/tests/orchestrator::TestSandboxMemoryIntegrity

Flake rate in main: 60.01% (Passed 579 times, Failed 869 times)

Stack Traces | 60.1s run time
=== RUN   TestSandboxMemoryIntegrity
=== PAUSE TestSandboxMemoryIntegrity
=== CONT  TestSandboxMemoryIntegrity
    sandbox_memory_integrity_test.go:27: Build completed successfully
--- FAIL: TestSandboxMemoryIntegrity (60.11s)
github.com/e2b-dev/infra/tests/integration/internal/tests/orchestrator::TestSandboxMemoryIntegrity/tmpfs_hash

Flake rate in main: 60.18% (Passed 569 times, Failed 860 times)

Stack Traces | 99.8s run time
=== RUN   TestSandboxMemoryIntegrity/tmpfs_hash
=== PAUSE TestSandboxMemoryIntegrity/tmpfs_hash
=== CONT  TestSandboxMemoryIntegrity/tmpfs_hash
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{start:{pid:1253}}
Executing command bash in sandbox iqh2adgiiqvreeplmc82e (user: root)
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stdout:"Total memory: 985 MB\nUsed memory before tmpfs mount: 189 MB\nFree memory before tmpfs mount: 795 MB\nMemory to use in integrity test (80% of free, min 64MB): 636 MB\n"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"636+0 records in\n636+0 records out\n666894336 bytes (667 MB, 636 MiB) copied, 3.47257 s, 192 MB/s\n"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"\t"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"C"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"o"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"m"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"m"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"a"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"n"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"d"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:" "}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"b"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"e"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"i"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"n"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"g"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:" "}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"t"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"i"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"m"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"e"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"d"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:":"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:" "}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"\""}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"dd"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:" "}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"if=/dev/urandom"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:" "}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"of=/mnt/testfile"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:" "}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"bs=1M"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:" "}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"count=636"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"\""}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"\n"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"\t"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"U"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"s"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"e"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"r"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:" "}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"t"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"i"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"m"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"e"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:" "}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"("}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"s"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"e"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"c"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"o"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"n"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"d"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"s"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:")"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:":"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:" "}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"0.00"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"\n"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"\t"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"S"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"y"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"s"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"t"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"e"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"m"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:" "}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"time (seconds): 3.19\n\tPercent of CPU this job got: 91%\n\tElapsed (wall clock) time (h:mm:ss or m:ss): 0:03.47\n\tAverage shared text size (kbytes): 0\n\tAverage unshared data size (kbytes): 0\n\tAverage stack size (kbytes): 0\n\tAverage total size (kbytes): 0\n\tMaximum resident set size (kbytes): 2636\n\tAverage resident set size (kbytes): 0\n\tMajor (requiring I/O) page faults: 3\n\tMinor (reclaiming a frame) page faults: 343\n\tVoluntary context s"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stderr:"witches: 4\n\tInvoluntary context switches: 36\n\tSwaps: 0\n\tFile system inputs: 176\n\tFile system outputs: 0\n\tSocket messages sent: 0\n\tSocket messages received: 0\n\tSignals delivered: 0\n\tPage size (bytes): 4096\n\tExit status: 0\n"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{data:{stdout:"Used memory after tmpfs mount and file fill: 834 MB\n"}}
    sandbox_memory_integrity_test.go:70: Command [bash] output: event:{end:{exited:true status:"exit status 0"}}
    sandbox_memory_integrity_test.go:70: Command [bash] completed successfully in sandbox i9afxyariy9mjyhd6tk0g
Executing command bash in sandbox i9afxyariy9mjyhd6tk0g (user: root)
    sandbox_memory_integrity_test.go:80: Command [bash] output: event:{start:{pid:1269}}
Executing command bash in sandbox i5rn459cmk2mgr6f849au (user: root)
    sandbox_memory_integrity_test.go:80: Command [bash] output: event:{data:{stdout:"048624f5f95606e4582b1b73e591a1f391355b1c2eeecc74966668029a8efe48\n"}}
    sandbox_memory_integrity_test.go:80: Command [bash] output: event:{end:{exited:true status:"exit status 0"}}
    sandbox_memory_integrity_test.go:80: Command [bash] completed successfully in sandbox i9afxyariy9mjyhd6tk0g
Executing command bash in sandbox i9afxyariy9mjyhd6tk0g (user: root)
    sandbox_memory_integrity_test.go:80: Command [bash] output: event:{start:{pid:1272}}
Executing command bash in sandbox i9afxyariy9mjyhd6tk0g (user: root)
Executing command bash in sandbox i9afxyariy9mjyhd6tk0g (user: root)
Executing command bash in sandbox i9afxyariy9mjyhd6tk0g (user: root)
Executing command bash in sandbox i9afxyariy9mjyhd6tk0g (user: root)
Executing command bash in sandbox i9afxyariy9mjyhd6tk0g (user: root)
Executing command bash in sandbox i9afxyariy9mjyhd6tk0g (user: root)
Executing command bash in sandbox i9afxyariy9mjyhd6tk0g (user: root)
Executing command bash in sandbox i9afxyariy9mjyhd6tk0g (user: root)
Executing command bash in sandbox i9afxyariy9mjyhd6tk0g (user: root)
Executing command bash in sandbox i9afxyariy9mjyhd6tk0g (user: root)
Executing command bash in sandbox i9afxyariy9mjyhd6tk0g (user: root)
Executing command bash in sandbox i9afxyariy9mjyhd6tk0g (user: root)
Executing command bash in sandbox i9afxyariy9mjyhd6tk0g (user: root)
Executing command bash in sandbox i9afxyariy9mjyhd6tk0g (user: root)
Executing command bash in sandbox i9afxyariy9mjyhd6tk0g (user: root)
Executing command bash in sandbox i9afxyariy9mjyhd6tk0g (user: root)
Executing command bash in sandbox i9afxyariy9mjyhd6tk0g (user: root)
Executing command bash in sandbox i9afxyariy9mjyhd6tk0g (user: root)
Executing command bash in sandbox i9afxyariy9mjyhd6tk0g (user: root)
Executing command bash in sandbox i9afxyariy9mjyhd6tk0g (user: root)
Executing command bash in sandbox i9afxyariy9mjyhd6tk0g (user: root)
Executing command bash in sandbox i9afxyariy9mjyhd6tk0g (user: root)
Executing command bash in sandbox i9afxyariy9mjyhd6tk0g (user: root)
Executing command bash in sandbox i9afxyariy9mjyhd6tk0g (user: root)
Executing command bash in sandbox i9afxyariy9mjyhd6tk0g (user: root)
Executing command bash in sandbox i9afxyariy9mjyhd6tk0g (user: root)
Executing command bash in sandbox i9afxyariy9mjyhd6tk0g (user: root)
Executing command bash in sandbox i9afxyariy9mjyhd6tk0g (user: root)
Executing command bash in sandbox i9afxyariy9mjyhd6tk0g (user: root)
Executing command bash in sandbox i9afxyariy9mjyhd6tk0g (user: root)
Executing command bash in sandbox i9afxyariy9mjyhd6tk0g (user: root)
Executing command bash in sandbox i9afxyariy9mjyhd6tk0g (user: root)
Executing command bash in sandbox i9afxyariy9mjyhd6tk0g (user: root)
Executing command bash in sandbox i9afxyariy9mjyhd6tk0g (user: root)
Executing command bash in sandbox i9afxyariy9mjyhd6tk0g (user: root)
Executing command bash in sandbox i9afxyariy9mjyhd6tk0g (user: root)
Executing command bash in sandbox i9afxyariy9mjyhd6tk0g (user: root)
Executing command bash in sandbox i9afxyariy9mjyhd6tk0g (user: root)
    sandbox_memory_integrity_test.go:110: 
        	Error Trace:	.../tests/orchestrator/sandbox_memory_integrity_test.go:81
        	            				.../hostedtoolcache/go/1.26.3.../src/runtime/asm_amd64.s:1771
        	Error:      	Received unexpected error:
        	            	failed to execute command bash in sandbox i9afxyariy9mjyhd6tk0g: unavailable: HTTP status 502 Bad Gateway
    sandbox_memory_integrity_test.go:110: 
        	Error Trace:	.../tests/orchestrator/sandbox_memory_integrity_test.go:78
        	            				.../tests/orchestrator/sandbox_memory_integrity_test.go:110
        	Error:      	Condition never satisfied
        	Test:       	TestSandboxMemoryIntegrity/tmpfs_hash
--- FAIL: TestSandboxMemoryIntegrity/tmpfs_hash (99.77s)

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@ValentaTomas ValentaTomas changed the title fix(compression): correctness-critical findings from compression audit fix(compression): correctness + perf findings from compression audit May 22, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

The alignment check in WriteAtWithoutLock only verifies that the write is at least one block long but does not ensure the total length is a multiple of the block size, which could lead to a panic when slicing the buffer for the final block; the condition should be updated to require that len(b) is an exact multiple of c.blockSize.

Comment thread packages/orchestrator/pkg/sandbox/block/cache.go Outdated
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: Idle timer not reset after successful Read completion
    • Added timer.Reset(r.idle) after successful reads to give consumers the full idle budget between reads instead of reducing it by the read duration.

Create PR

Or push these changes by commenting:

@cursor push f40a25dca8
Preview (f40a25dca8)
diff --git a/packages/shared/pkg/storage/storage_google.go b/packages/shared/pkg/storage/storage_google.go
--- a/packages/shared/pkg/storage/storage_google.go
+++ b/packages/shared/pkg/storage/storage_google.go
@@ -303,6 +303,8 @@
 	n, err := r.ReadCloser.Read(p)
 	if err != nil {
 		r.timer.Stop()
+	} else {
+		r.timer.Reset(r.idle)
 	}
 	return n, err
 }

You can send follow-ups to the cloud agent here.

Comment thread packages/shared/pkg/storage/storage_google.go
@ValentaTomas ValentaTomas force-pushed the lev-compression-correctness-fixes branch from 1a7b59d to c8b0411 Compare May 22, 2026 21:12
@ValentaTomas ValentaTomas changed the title fix(compression): correctness + perf findings from compression audit fix(compression): correctness findings from compression audit May 22, 2026
@ValentaTomas ValentaTomas force-pushed the lev-compression-correctness-fixes branch from c8b0411 to d26c7de Compare May 22, 2026 22:00
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: GCS ErrObjectNotExist check never matches in peerSeekable
    • Added error translation in openRangeReader to wrap cloud library ErrObjectNotExist with local package sentinel, matching the pattern used in Size() and WriteTo() methods.

Create PR

Or push these changes by commenting:

@cursor push 3750f3cd4c
Preview (3750f3cd4c)
diff --git a/packages/shared/pkg/storage/storage_google.go b/packages/shared/pkg/storage/storage_google.go
--- a/packages/shared/pkg/storage/storage_google.go
+++ b/packages/shared/pkg/storage/storage_google.go
@@ -274,6 +274,10 @@
 	if err != nil {
 		cancel()
 
+		if errors.Is(err, storage.ErrObjectNotExist) {
+			return nil, fmt.Errorf("failed to create GCS range reader for %q at %d+%d: %w", o.path, off, length, ErrObjectNotExist)
+		}
+
 		return nil, fmt.Errorf("failed to create GCS range reader for %q at %d+%d: %w", o.path, off, length, err)
 	}

You can send follow-ups to the cloud agent here.

Comment thread packages/orchestrator/pkg/sandbox/template/peerclient/seekable.go
@ValentaTomas ValentaTomas marked this pull request as ready for review May 22, 2026 22:49
@ValentaTomas ValentaTomas force-pushed the lev-compression-correctness-fixes branch 2 times, most recently from ddf1bab to 5584b06 Compare May 22, 2026 22:51
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ef6431c76c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/orchestrator/pkg/sandbox/template/peerclient/seekable.go Outdated
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: Concurrent reads lose transition retry
    • Removed the conditional CAS check so all concurrent goroutines in the retry window receive PeerTransitionedError and can retry after header swap.

Create PR

Or push these changes by commenting:

@cursor push 2c923d7144
Preview (2c923d7144)
diff --git a/packages/orchestrator/pkg/sandbox/template/peerclient/seekable.go b/packages/orchestrator/pkg/sandbox/template/peerclient/seekable.go
--- a/packages/orchestrator/pkg/sandbox/template/peerclient/seekable.go
+++ b/packages/orchestrator/pkg/sandbox/template/peerclient/seekable.go
@@ -145,9 +145,8 @@
 	if errors.Is(err, storage.ErrObjectNotExist) {
 		at := s.transitionAt.Load()
 		if at != 0 && time.Since(time.Unix(0, at)) < postTransitionRetryWindow {
-			if s.transitionAt.CompareAndSwap(at, 0) {
-				return nil, &storage.PeerTransitionedError{}
-			}
+			s.transitionAt.CompareAndSwap(at, 0)
+			return nil, &storage.PeerTransitionedError{}
 		}
 	}

You can send follow-ups to the cloud agent here.

Comment thread packages/orchestrator/pkg/sandbox/template/peerclient/seekable.go Outdated
Comment thread packages/shared/pkg/storage/header/serialization_v4.go
Comment thread packages/orchestrator/pkg/sandbox/build_upload_v4.go Outdated
Comment thread packages/orchestrator/pkg/sandbox/template/peerclient/seekable.go Outdated
Comment thread packages/orchestrator/pkg/sandbox/template/peerclient/seekable.go
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 27eeb26591

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/shared/pkg/storage/storage_google.go Outdated
@ValentaTomas ValentaTomas force-pushed the lev-compression-correctness-fixes branch 2 times, most recently from 6b02855 to 393ddbe Compare May 25, 2026 06:25
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 prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Stat failure deletes valid cache
    • Modified logic to only remove cached files on confirmed size mismatch, treating Stat failures as transient errors that fall through to cache miss without deletion.

Create PR

Or push these changes by commenting:

@cursor push 93e492f915
Preview (93e492f915)
diff --git a/packages/shared/pkg/storage/storage_cache_seekable_compressed.go b/packages/shared/pkg/storage/storage_cache_seekable_compressed.go
--- a/packages/shared/pkg/storage/storage_cache_seekable_compressed.go
+++ b/packages/shared/pkg/storage/storage_cache_seekable_compressed.go
@@ -32,23 +32,29 @@
 	// Cache hit: open compressed frame from NFS, validate size, wrap with decompressor.
 	// On size mismatch the file is corrupt (truncated write, disk full), drop it.
 	if f, err := os.Open(path); err == nil {
-		if fi, statErr := f.Stat(); statErr == nil && fi.Size() == int64(r.Length) {
-			recordCacheRead(ctx, true, int64(r.Length), cacheTypeSeekable, cacheOpOpenRangeReader)
-			timer.Success(ctx, int64(r.Length))
+		if fi, statErr := f.Stat(); statErr == nil {
+			if fi.Size() == int64(r.Length) {
+				recordCacheRead(ctx, true, int64(r.Length), cacheTypeSeekable, cacheOpOpenRangeReader)
+				timer.Success(ctx, int64(r.Length))
 
-			decompressed, err := newDecompressingReadCloser(f, frameTable.CompressionType())
-			if err != nil {
-				f.Close()
+				decompressed, err := newDecompressingReadCloser(f, frameTable.CompressionType())
+				if err != nil {
+					f.Close()
 
-				return nil, fmt.Errorf("decompress cached frame: %w", err)
+					return nil, fmt.Errorf("decompress cached frame: %w", err)
+				}
+
+				return withNFSGauge(ctx, decompressed), nil
 			}
-
-			return withNFSGauge(ctx, decompressed), nil
+			f.Close()
+			_ = os.Remove(path)
+			recordCacheReadError(ctx, cacheTypeSeekable, cacheOpOpenRangeReader,
+				fmt.Errorf("cached frame %s size mismatch", path))
+		} else {
+			f.Close()
+			recordCacheReadError(ctx, cacheTypeSeekable, cacheOpOpenRangeReader,
+				fmt.Errorf("cached frame %s stat failed: %w", path, statErr))
 		}
-		f.Close()
-		_ = os.Remove(path)
-		recordCacheReadError(ctx, cacheTypeSeekable, cacheOpOpenRangeReader,
-			fmt.Errorf("cached frame %s invalid", path))
 	} else if !os.IsNotExist(err) {
 		recordCacheReadError(ctx, cacheTypeSeekable, cacheOpOpenRangeReader, err)
 	}

You can send follow-ups to the cloud agent here.

Reviewed by Cursor Bugbot for commit 393ddbe. Configure here.

Comment thread packages/shared/pkg/storage/storage_cache_seekable_compressed.go Outdated
@ValentaTomas ValentaTomas force-pushed the lev-compression-correctness-fixes branch 2 times, most recently from c5d0197 to ea94b8f Compare May 25, 2026 06:33
@ValentaTomas ValentaTomas requested a review from jakubno May 25, 2026 06:33
Comment thread packages/shared/pkg/storage/storage_google.go Outdated
Comment thread packages/shared/pkg/storage/storage_google.go
- reject misaligned writes in Cache.WriteAtWithoutLock to avoid OOB slice
- cap V4 header LZ4 decompression at the size prefix
- drop corrupt compressed cache entries on size mismatch
- retry GCS 404 within post-transition window with backoff
- use per-Read idle timeout on GCS range reads
@ValentaTomas ValentaTomas force-pushed the lev-compression-correctness-fixes branch from ea94b8f to 819c7a3 Compare May 25, 2026 07:30
The API takes ~20s after starting to listen before its readiness gate
clears (cluster init), so the default 30s polling window can lose the
race and report 'API failed to become healthy in time' on slower
runners. Bump just the API leg to 60s.
@ValentaTomas ValentaTomas merged commit d21a6a9 into main May 25, 2026
51 checks passed
@ValentaTomas ValentaTomas deleted the lev-compression-correctness-fixes branch May 25, 2026 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants