Skip to content

C0-3: Plumb parallel-read and pool-size settings through buildS3Config #156

Closed

Description

@scttfrdmn

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

  1. Map ParallelRead and Performance.ConnectionPoolSize from the loaded config through
    buildS3Config, honoring ParallelRead.Enabled (false should set the threshold to 0).
  2. Add ParallelReadThreshold and PoolSize to the zero-value defaulting block in
    NewBackend.
  3. Make both semaphore constructions defensive, following the NewConnectionPool pattern,
    so a zero can never reintroduce the deadlock.
  4. Reuse the existing parseSize helper 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-zero PoolSize, ParallelReadThreshold, and ReadChunkSize
  • ParallelRead.Enabled: false yields a zero threshold (feature off, no deadlock)
  • NewBackend defaults ParallelReadThreshold and PoolSize when passed zero
  • GetObjects and PutObjects complete 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

  1. added
    type: bug
    priority: high
    area: config
    on Jul 29, 2026
  2. scttfrdmn commented on Aug 2, 2026

    @scttfrdmn
    OwnerAuthor

    Fixed in v0.10.1 (3ed615c). buildS3Config now 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: 0 reached GetObjects/PutObjects as make(chan struct{}, 0), an unbuffered semaphore whose first send never returns, so every batch operation on a stock mount hung rather than failed; and ParallelReadThreshold: 0 closed the threshold > 0 gate, making v0.10.0's headline feature dead code in production.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: configpriority: hightype: bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions