Repository navigation
Description
Summary
Adapter.buildS3Config() maps 6 fields onto a s3.Config with roughly 30, and NewBackend
does not default the two most consequential of the rest. Net effect on every real mount:
v0.10.0's parallel range GET feature never fires, the batch operations deadlock, and the HTTP
connection pool is capped at 2 idle connections per host.
Background
internal/adapter/adapter.go buildS3Config never sets ParallelReadThreshold,
ReadChunkSize, ParallelReadConcurrency, or PoolSize. NewBackend in
internal/storage/s3/backend.go defaults four fields but not those:
defaults := NewDefaultConfig()
if cfg.MultipartThreshold == 0 { cfg.MultipartThreshold = defaults.MultipartThreshold }
if cfg.MultipartChunkSize == 0 { cfg.MultipartChunkSize = defaults.MultipartChunkSize }
if cfg.MultipartConcurrency == 0 { cfg.MultipartConcurrency = defaults.MultipartConcurrency }
if cfg.ReadChunkSize == 0 { cfg.ReadChunkSize = defaults.ReadChunkSize }ParallelReadThreshold and PoolSize are absent, so both stay zero. Three symptoms:
1. The parallel read path is dead. GetObject gates on a positive threshold:
threshold := b.config.ParallelReadThreshold
if threshold > 0 && (b.compressor == nil || !b.compressor.Enabled()) {Zero means the fast path is never taken on a mount, only when a caller builds a config via
NewDefaultConfig directly.
2. GetObjects and PutObjects deadlock. Both do:
semaphore := make(chan struct{}, b.config.PoolSize)With PoolSize == 0 that is an unbuffered channel, so the first send blocks forever with
no receiver. Reproduced standalone.
3. Connection pooling is throttled. internal/storage/s3/client.go sets
MaxIdleConnsPerHost: cfg.PoolSize; zero falls back to Go's default of 2.
Note NewConnectionPool in internal/storage/s3/pool.go does not break, because it
already defends itself — if maxSize <= 0 { maxSize = 8 }. That is the convention to copy.
There is also already a ParallelReadConfig in internal/config/config.go, with defaults
Enabled: true, Threshold: "64MB", ChunkSize: "16MB" — and nothing reads it. Wire
that existing config through; do not introduce new fields.
Implementation
- Map
ParallelReadandPerformance.ConnectionPoolSizefrom the loaded config through
buildS3Config, honoringParallelRead.Enabled(false should set the threshold to 0). - Add
ParallelReadThresholdandPoolSizeto the zero-value defaulting block in
NewBackend. - Make both semaphore constructions defensive, following the
NewConnectionPoolpattern,
so a zero can never reintroduce the deadlock. - Reuse the existing
parseSizehelper for the string sizes rather than adding another.
Also log once at startup when compression is enabled that the parallel read path is disabled
by design — a compressed object cannot be range-GET'd piecewise, so the two features are
mutually exclusive. Today that interaction is silent and looks like the feature is broken.
Acceptance Criteria
-
buildS3Config()returns non-zeroPoolSize,ParallelReadThreshold, andReadChunkSize -
ParallelRead.Enabled: falseyields a zero threshold (feature off, no deadlock) -
NewBackenddefaultsParallelReadThresholdandPoolSizewhen passed zero -
GetObjectsandPutObjectscomplete with a zero-value config instead of hanging - Reading an object above the threshold with compression disabled issues multiple range GETs
- The compression/parallel-read interaction is logged once at startup
-
go test -race -timeout 30s ./internal/storage/s3/... ./internal/adapter/...passes
The explicit -timeout 30s matters: a regression here hangs rather than fails, and the
timeout is what turns that back into a visible test failure.
Dependencies
None. Should land together with the compression-config split issue, since both rewrite
buildS3Config and would otherwise conflict.
Activity
scttfrdmn commentedon Aug 2, 2026
Fixed in v0.10.1 (
3ed615c).buildS3Confignow maps field-by-field, with a table test asserting its output values rather than recomputing the mapping. Two of the omissions were not merely inert:PoolSize: 0reachedGetObjects/PutObjectsasmake(chan struct{}, 0), an unbuffered semaphore whose first send never returns, so every batch operation on a stock mount hung rather than failed; andParallelReadThreshold: 0closed thethreshold > 0gate, making v0.10.0's headline feature dead code in production.fix: the cluster.redis block selects the cache a mount actually uses (#…