Repository navigation
fix: compression is configured where the compression happens - #244
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #157.
write_buffer.compressionconfigured 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 understorage.s3.compression, next to the backend that applies it. Defaults are unchanged — off, zstd, level 3, 4KB.performance.compression_enabledis 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 prominentcompression_enabled: truewhile 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_ENABLEDis kept and repointed atstorage.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:
Storage.S3.Compressionexists and defaults to zstd / level 3 / 4KBbuildS3Config()yields zstd/3/4KB — but not "not gzip/6/1KB": that half self-corrected before this PR.internal/configalready defaulted to zstd/3/4KB, matchings3.NewDefaultConfigon everything exceptEnabled, which is deliberately false for a mount and true for the Go SDKChanging— vacuous now:WriteBuffer.Compressionno longer affects the S3 object compression configWriteBuffer.Compressiondoes not exist, and a file setting it fails to loadGetObjectdispatches on the storedContent-Encodingper object" was false when filed and became true only with A mount can only read the one compression algorithm it is configured for, so changing algorithm orphans existing objects #230go test -race ./internal/adapter/... ./internal/config/...passesVerified by mutation
Each applied to the code, the failing test watched, then reverted:
enabledexamples/config.yamlAlgorithmhardcoded to"zstd"min_sizedropped from the mappingleveldropped from the mappingM6 is the finding. The mapping test asserted
Algorithm: "zstd"— which is also the default — so abuildS3Configthat ignored the configuration entirely passed it. It now assertslz4, 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.yamlmarked all threewrite_bufferkeys "not yet wired", with a comment stating that nothing bounds dirty bytes.max_memoryandmax_buffersreachvfs.WriterthroughbuildWriterOptionsas of #205, and the bound flushes to make room before it refuses a write.flush_intervalis genuinely unwired and stays marked. Corrected here because it is a false claim in the block this PR edits.Gates
go build,go vet— cleango test -race ./...— passesgolangci-lint run --new-from-merge-base=origin/main— 0 issuesinternal/configfloor 86 → 88, the two points being the rejection tests that hold the removal rather than the move itself