fix(post-review): H1-H4 + C1 from deep code review#56
Merged
Conversation
- C1 / H1 (mcp/server.go): tools/call concurrency gate refactored to use
an explicit `acquired` flag so the dead `break` inside select{default}
is gone. The semaphore slot is now held until the inner goroutine
finishes — not when the request thread gives up on timeout. Without
this, slow handlers could keep accumulating goroutines past the cap.
Added TestRobustness_TimeoutHoldsSemaphoreSlot to lock in the new
ordering contract.
- H2 (tsdb/aggregator.go): droppedBatches changed to atomic.Int64.
Previously a plain int64 was incremented in flush() (after the unlock)
and read concurrently by DroppedBatches() from telemetry scrape paths.
No test surfaced it because no scrape ran during a flush; live
Prometheus would have.
- H3 (storage): FTS5→LIKE fallback now logs slog.Warn with tenant +
query + error so the operator notices instead of leaving the seatbelt
on. Applied to both SearchLogs and GetLogsV2.
- H4 (storage/partitions_scheduler.go): documented the one-shot
lifecycle. Start-Stop-Start is NOT supported because Stop closes the
internal `done` channel; restarts must construct a fresh scheduler.
Reverted: H5 and H6 from the review conflict with existing test contracts
(TestPipeline_DefaultsApplied requires SoftThreshold zero-value to be
treated as "use default"; TestPipeline_FailedSpansSkipsLogs enforces
"orphan logs are not persisted without their spans"). Kept the existing
behaviour and added comments explaining it so future reviewers don't
re-flag the same items.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
This was referenced Apr 28, 2026
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.



Summary
Addresses real bugs surfaced by the parallel deep code review (superpowers + Codex) of PRs #49-#55.
internal/mcp/server.gobreakinsideselect{default}with an explicitacquiredflaginternal/mcp/server.gointernal/tsdb/aggregator.godroppedBatches→atomic.Int64(was plain int64 racing betweenflush()andDroppedBatches()reader)internal/storage/{repository.go,log_repo.go}slog.Warnso operators see index-layer issues instead of silently degrading to LIKEinternal/storage/partitions_scheduler.godoneonce)Reverted
SoftThreshold == 0clobbered): conflicts withTestPipeline_DefaultsAppliedwhich enforces zero-value → default. The internal-only field has no env-var surface; "operator deliberately set 0" is not a real path.TestPipeline_FailedSpansSkipsLogswhich enforces "orphan logs are not persisted without their spans" as the design contract. Added an explanatory comment so future reviewers don't re-flag.Test plan
go test ./... -race -count=1— full suite greenTestRobustness_TimeoutHoldsSemaphoreSlotlocks in the H1 ordering contractgo vet ./...— cleangolangci-lint run --new-from-rev=origin/main— cleanM/L findings (Submit TOCTOU, aggregator unsync field reads, callback under mutex, isQueueFull scope,
pgLogsRelkinderrors.Is, MCP config clamp,logsPartitionedatomic.Bool, FTS5 trigger perf doc) deferred to a follow-up cleanup PR.🤖 Generated with Claude Code