fix(post-review): M/L cleanup from deep code review#57
Merged
Conversation
Five small follow-ups from the second-pass review of PRs #49–#55: - tsdb: fire cardinality-overflow callback AFTER releasing the Aggregator mutex. The callback is currently a Prometheus increment (atomic) but holding mu across an external function call is a footgun for any future hook. Capture the tenant under lock; invoke after Unlock. - storage: use errors.Is(err, sql.ErrNoRows) in pgLogsRelkind instead of strings.Contains(err.Error(), "no rows"). Robust against driver wrapping. - storage: convert Repository.logsPartitioned from plain bool to atomic.Bool. Removes the memory-model fragility of "the writer ran first" — read by retention.go from a separate goroutine. - config: reject negative MCP_MAX_CONCURRENT / MCP_CALL_TIMEOUT_MS / MCP_CACHE_TTL_MS at Validate(). 0 stays the documented "disable" sentinel; negatives are typos that should fail loud. - mcp: upgrade SetCallLimit doc to flag it startup-only — runtime resize leaks a slot in the old channel. Skipped (with rationale, not silently dropped): - M1 Submit TOCTOU on closed pipeline — cosmetic only, current ordering is documented. - M2 ring/onIngest setter races — would require API change to fix properly; benign during normal startup-only usage. - M4 FTS5 trigger throughput — needs a bulk-rebuild path, not a one-line tweak. - M5 isQueueFull scope — hypothetical concern with no observed symptom; revisit only if metrics show drift. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
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
Second wave of follow-ups from the deep code review of PRs #49–#55. PR1 (#56) shipped the High/Critical fixes; this PR cleans up the Medium/Low items that survived prioritization.
Changes
Aggregator.Ingestnow releasesmubefore firing the cardinality-overflow callback. Today the callback is a Prometheus increment (atomic, fast), but holding the lock across an external function call is a footgun for any future hook that touches I/O. Pattern: capture target tenant under the lock, invoke afterUnlock.pgLogsRelkinduseserrors.Is(err, sql.ErrNoRows)instead ofstrings.Contains(err.Error(), \"no rows\"). Robust against driver wrapping or message changes.Repository.logsPartitionedis nowatomic.Bool. The plain bool worked because the writer ran duringNewRepositorybefore any reader goroutine started, but the contract was brittle and no test would have caught a torn read on weakly-ordered architectures.Validate()rejects negativeMCP_MAX_CONCURRENT/MCP_CALL_TIMEOUT_MS/MCP_CACHE_TTL_MS.0remains the documented "disable" sentinel; negatives are typos that should fail loud at startup, not silently clamp.SetCallLimitdoc upgraded to flag the function as startup-only — runtime resize would leak a slot in the old channel.Skipped (with rationale)
Test plan
go vet ./...cleango build ./...succeedsgo test ./... -race -count=1— 404 tests pass across 27 packagesTestAggregator_*suite passes under-race)TestConfig_Validate*)🤖 Generated with Claude Code