Skip to content

Fix HLC monotonicity, nil guards, and config parsing in S3 adapter#402

Merged
bootjp merged 2 commits intofeature/s3-implfrom
copilot/sub-pr-396
Mar 22, 2026
Merged

Fix HLC monotonicity, nil guards, and config parsing in S3 adapter#402
bootjp merged 2 commits intofeature/s3-implfrom
copilot/sub-pr-396

Conversation

Copy link
Contributor

Copilot AI commented Mar 22, 2026

Four correctness and safety issues flagged in review on the S3 adapter PR.

Changes

  • kv/coordinator.godispatchTxn was not observing a caller-provided commitTS on the HLC, allowing subsequent clock.Next() calls to return timestamps smaller than a used commitTS. Added c.clock.Observe(commitTS) in the non-zero branch.

  • adapter/s3.goS3Server.Run() would panic if httpServer or listen were nil (possible when server is constructed without a listener). Added early nil-return errors for both fields.

  • cmd/server/demo.go (coordinator nil check) – setupS3 accepted *kv.Coordinate and stored it into interfaces without a nil check. A nil pointer stored in an interface is non-nil and panics on method call. Added an explicit coordinator != nil guard.

  • cmd/server/demo.go (raftS3MapStr parsing) – Used strings.Split(part, "=") which silently drops malformed entries and breaks on values containing =. Replaced with strings.SplitN(strings.TrimSpace(part), "=", 2) and returns an error for any entry not matching addr=s3addr.

// Before: silently skips bad entries
kv := strings.Split(part, "=")
if len(kv) == kvParts {
    leaderS3[raft.ServerAddress(kv[0])] = kv[1]
}

// After: returns error on malformed input, handles '=' in value
kv := strings.SplitN(strings.TrimSpace(part), "=", kvParts)
if len(kv) != kvParts {
    return nil, fmt.Errorf("invalid raft-s3 map entry %q: expected format addr=s3addr", part)
}
leaderS3[raft.ServerAddress(strings.TrimSpace(kv[0]))] = strings.TrimSpace(kv[1])

📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

Copilot AI changed the title [WIP] Add S3 adapter to elastickv Fix HLC monotonicity, nil guards, and config parsing in S3 adapter Mar 22, 2026
Copilot AI requested a review from bootjp March 22, 2026 12:19
@bootjp bootjp marked this pull request as ready for review March 22, 2026 12:53
@bootjp bootjp merged commit 9c629f7 into feature/s3-impl Mar 22, 2026
4 checks passed
@bootjp bootjp deleted the copilot/sub-pr-396 branch March 22, 2026 12:53
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.

2 participants