Skip to content

fix: compression is configured where the compression happens - #244

Merged
scttfrdmn merged 2 commits into
mainfrom
fix/157-compression-under-storage-s3
Aug 3, 2026
Merged

scttfrdmn merged 2 commits into
mainfrom
fix/157-compression-under-storage-s3

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

Closes #157.

write_buffer.compression configured the codec the S3 backend applies to a whole object on its way to the wire. Nothing has ever compressed a write buffer. The misplacement mattered in both directions: an operator tuning the write buffer was changing how every object in the bucket was stored, and an operator asking how objects are stored had no reason to read the write-buffer section. It now lives under storage.s3.compression, next to the backend that applies it. Defaults are unchanged — off, zstd, level 3, 4KB.

performance.compression_enabled is deleted. It defaulted to true, was read by nothing, and sat two sections away from the setting that defaulted to false — so the shipped configuration carried a prominent compression_enabled: true while no object was ever compressed, and anyone who read the file to find out came away with the opposite of the truth. Removed rather than wired up: compression happens in the backend, on the object, and a second boolean over one feature can only disagree with the first. OBJECTFS_COMPRESSION_ENABLED is kept and repointed at storage.s3.compression.enabled — the variable's name was never wrong, only what it assigned to.

Both keys are removed, not deprecated, so the strict loader fails a file that still sets either and names the key. That follows the precedent of the encryption booleans removed in v0.10.1. A key kept as an ignored field means an operator's compression settings silently stop applying on upgrade, which is the same failure strict decoding was introduced to catch, arrived at by a different route.

The issue's acceptance criteria

Two need restating rather than checking, because the premises moved between filing and now:

Verified by mutation

Each applied to the code, the failing test watched, then reverted:

mutation result
M1 mapping drops enabled caught
M2 compression defaults on caught
M3 env handler assigns nothing caught
M4 old key kept in the schema as an ignored field caught (4 tests)
M5 compression key typo in examples/config.yaml caught (4 tests)
M6 Algorithm hardcoded to "zstd" MISSED, then caught
M7 min_size dropped from the mapping caught
M8 level dropped from the mapping caught

M6 is the finding. The mapping test asserted Algorithm: "zstd" — which is also the default — so a buildS3Config that ignored the configuration entirely passed it. It now asserts lz4, because every value in a mapping test has to differ from the one the field would hold if the mapping were absent. That is precisely the shape of the D12 config-plumbing defect: a field nothing mapped still arriving at a plausible value from somewhere else.

Also here

examples/config.yaml marked all three write_buffer keys "not yet wired", with a comment stating that nothing bounds dirty bytes. max_memory and max_buffers reach vfs.Writer through buildWriterOptions as of #205, and the bound flushes to make room before it refuses a write. flush_interval is genuinely unwired and stays marked. Corrected here because it is a false claim in the block this PR edits.

Gates

  • go build, go vet — clean
  • go test -race ./... — passes
  • golangci-lint run --new-from-merge-base=origin/main — 0 issues
  • coverage gate green; internal/config floor 86 → 88, the two points being the rejection tests that hold the removal rather than the move itself

Closes #157.

`write_buffer.compression` configured the codec the S3 backend applies to a
whole object on its way to the wire. Nothing has ever compressed a write
buffer. The misplacement mattered in both directions: an operator tuning the
write buffer was changing how every object in the bucket was stored, and an
operator asking how objects are stored had no reason to read the write-buffer
section. It now lives under `storage.s3.compression`, next to the backend that
applies it. Defaults are unchanged — off, zstd, level 3, 4KB.

`performance.compression_enabled` is deleted. It defaulted to **true**, was read
by nothing, and sat two sections away from the setting that defaulted to false —
so the shipped configuration carried a prominent `compression_enabled: true`
while no object was ever compressed, and anyone who read the file to find out
came away with the opposite of the truth. Removed rather than wired up:
compression happens in the backend, on the object, and a second boolean over one
feature can only disagree with the first. `OBJECTFS_COMPRESSION_ENABLED` is kept
and repointed at `storage.s3.compression.enabled` — the variable's name was never
wrong, only what it assigned to.

Both keys are **removed, not deprecated**, so the strict loader fails a file that
still sets either and names the key. That follows the precedent of the encryption
booleans removed in v0.10.1. A key kept as an ignored field means an operator's
compression settings silently stop applying on upgrade, which is the same failure
strict decoding was introduced to catch.

#157 also claimed the block defaulted to gzip/6/1KB against the backend's
zstd/3/4KB. That half has since self-corrected — internal/config already
defaulted to zstd/3/4KB, matching s3.NewDefaultConfig on everything but
`Enabled`, which is deliberately false for a mount and true for the Go SDK. Its
fourth criterion, that previously-written gzip objects still read back, is
satisfied by #230 rather than by this change; its claim that "reads are
unaffected — GetObject dispatches on the stored Content-Encoding per object" was
false when filed and became true only with #230.

Verified by mutation, eight ways — each applied to the code, the failing test
watched, then reverted:

  M1  mapping drops enabled                    caught
  M2  compression defaults on                  caught
  M3  env handler assigns nothing               caught
  M4  old key kept in the schema as ignored     caught (4 tests)
  M5  compression key typo in examples/         caught (4 tests)
  M6  algorithm hardcoded to "zstd"             MISSED, then caught
  M7  min_size dropped from the mapping         caught
  M8  level dropped from the mapping            caught

M6 is the finding. The mapping test asserted `Algorithm: "zstd"` — which is also
the default — so a buildS3Config that ignored the configuration entirely passed.
It now asserts `lz4`, because every value in a mapping test has to differ from
the one the field would hold if the mapping were absent. That is precisely the
shape of the D12 config-plumbing defect: a field nothing mapped still arriving at
a plausible value from somewhere else.

Also here, because they were false claims in the same block: examples/config.yaml
marked all three `write_buffer` keys "not yet wired" with a comment saying
nothing bounds dirty bytes. `max_memory` and `max_buffers` reach vfs.Writer via
buildWriterOptions as of #205, and the bound flushes to make room before it
refuses a write. `flush_interval` is genuinely unwired and stays marked.

Gates: go build, go vet clean. go test -race ./... passes. golangci-lint
--new-from-merge-base=origin/main: 0 issues. Coverage gate green;
internal/config 86 → 88, the two points being the rejection tests that hold the
removal rather than the move itself.
ConsensusEngine.Stop read ce.electionTimer unlocked while resetElectionTimer replaced
it from the gossip receiver goroutine, reached from handleNetworkAppendEntries. CI's
test job caught it as a data race in TriggerElection's two peer tests; it reproduces
locally only under -count on a loaded machine.

Neither shutdown signal orders the two. The receiver does not watch the consensus
engine's stopCh, and GossipProtocol.Stop closes the socket without waiting for the
receiver, so a message already in a handler outlives it.

Start's call to resetElectionTimer was the second unlocked instance. Both now hold the
write lock, and resetElectionTimer says in its doc comment that the caller must —
which is what makes the third instance a review question rather than another flake.

The regression test drives handleNetworkAppendEntries concurrently with Stop rather
than over UDP, so the write is guaranteed to overlap the read: -race reports it on
every run without the fix, verified by reverting the lock and watching it fail.
@scttfrdmn
scttfrdmn merged commit 297dc8f into main Aug 3, 2026
23 checks passed
@scttfrdmn
scttfrdmn deleted the fix/157-compression-under-storage-s3 branch August 3, 2026 08:15
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.

C0-4: Separate S3 object compression from write-buffer compression

1 participant