refactor(trace): retire span recording pipeline - #25841
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
08ed69d to
62c1c60
Compare
|
Final scope expansion and self-review completed at The PR now retires the Span recording implementation instead of only disabling it by default. Review-relevant boundaries:
Final validation passed locally (race, focused/dependent tests, vet, full build) and on machine 50 with explicit Detailed final implementation, all three validation rounds, and before/after evidence: #25839 (comment) |
gouhongshen
left a comment
There was a problem hiding this comment.
Blocking finding
WithHungThreshold is not only a Span-recording option; it currently provides a real cancellation deadline. Before this PR, MOTracer.Start applied the option and newMOHungSpan wrapped the returned context with context.WithTimeoutCause(..., threshold, moerr.CauseNewMOHungSpan).
There are production call sites that consume that returned context:
pkg/util/metric/mometric/cron_task.go:253-255passes it tosqlExecutor().Query, relying on the 1-minute bound.pkg/frontend/routine.go:268later checksroutineCtx.Done()at line 345, relying on the 30-minute hung-request guard.
After this change, NoopTracer.Start returns the original context and never applies WithHungThreshold, so both deadlines disappear. A hung storage-size query/request can therefore outlive the previous bound and change shutdown/cancellation behavior. Please preserve this timeout semantics with an explicit context-timeout helper or at the call sites before making the Span runtime a no-op.
Other reviewed areas (retained StatementInfo/log/error registration, schema compatibility, CN/TN TraceSpan response path, and collector shutdown ownership) did not reveal an additional blocker.
Validation: go test -race ./pkg/util/trace -count=1 and go vet ./pkg/util/trace pass. The broader affected-package test command was blocked by missing local CGo headers (xxhash.h, roaring.h, usearch.h).
|
@gouhongshen @XuPeng-SH The P1 finding is valid and fixed in The fix preserves correlation without restoring the retired Span pipeline:
Added regression coverage for the four requested boundaries:
The branch was rebased onto
I also re-reviewed the full diff for retained StatementInfo/log/error collection, collector shutdown ownership, deadline/cancellation behavior, wire/schema compatibility, and resource/wait lifecycle. No additional blocker was found. Please re-review the updated head. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Re-reviewed the complete diff at 7748b5706e. The previous blockers are closed:
- the former
WithHungThresholdbusiness side effects are now explicit 1-minute and 30-minute contexts at the two real consumers; the DDL-only profiling call did not propagate its returned context and is correctly removed; - enabled observability now uses a stateless non-recording tracer that preserves root/child/new-root IDs, frontend connection correlation, log/error extraction, and MORPC propagation; fully disabled tracing and
NoopTracer.Startremain no-op/zero-allocation; - Span recording, profile hooks, controlled-span maps/locks, queue/export paths, and runtime re-enable behavior remain retired; StatementInfo, log/error export, CU, schema, and wire compatibility remain intact;
- shared collector shutdown has explicit ownership and a bounded cancellation path.
Performance was checked independently because there are 73 production trace.Start call sites, including SQL/fileservice hot paths. On the same machine, a focused latest-head non-recording Start+End benchmark measured about 55 ns/op, 256 B/op, 3 allocs/op versus about 178 ns/op, 384 B/op, 3 allocs/op for the main-branch MOTracer Start+End path. The new path therefore does not increase allocation count and removes the global controlled-span mutex and recording/export work.
Fresh reviewer validation passed:
- CGo-aware race tests:
./pkg/util/trace/... - CGo-aware race test: frontend generated routine context
- CGo-aware race test: MORPC generated-context codec round trip
git diff --check
GitHub Ubuntu UT, arm64 SCA, pessimistic multi-CN BVT, proxy BVT, and standalone pessimistic BVT are green; coverage is still running and should remain a merge gate. No remaining code blocker found.
gouhongshen
left a comment
There was a problem hiding this comment.
Codex automated review
No correctness regressions found in the PR diff. Verified trace-context propagation, collector shutdown ownership, retained telemetry registration, timeout preservation, and compatibility paths. pkg/util/trace tests, vet, and build passed; CGo-dependent focused packages could not run because this checkout lacks cgo/libmo.dylib and third-party headers.
Merge Queue Status
This pull request spent 25 minutes 13 seconds in the queue, with no time running CI. Waiting for
All conditions
ReasonThe merge conditions cannot be satisfied due to failing checks Failing checks:
HintYou may have to fix your CI before adding the pull request to the queue again. Requeued — the merge queue status continues in this comment ↓. |
BVT failure: root cause confirmed and fixedThe failure in Evidence chain:
Fixed in Regression coverage now verifies the complete failing path: an Validation after the fix:
Fresh CI is running at https://github.com/matrixorigin/matrixone/actions/runs/29671757688; the same |
Merge Queue Status
This pull request spent 1 hour 40 minutes 39 seconds in the queue, including 1 hour 47 seconds running CI. Required conditions to merge
|
What type of PR is this?
Which issue(s) this PR fixes:
issue #25839
What this PR does / why we need it:
MO no longer consumes internal Span records, but every hot-path
trace.Startstill entered the Span recording implementation and queried global controlled-span state. Under concurrency, that query appeared prominently in mutex-delay profiles.This PR retires the Span recording pipeline while preserving the observability data and trace-context contracts that MO still uses:
MOTracer,MOSpan,MOHungSpan, the Span batch processor/exporter, controlled-span maps, timers, profile hooks, and Span-only tests;disable-spantotruein code, independent of deployment configuration files;NoopTracer;NonRecordingTracerwhen observability is enabled, generating and propagating TraceID/SpanID without recording, profiling, queuing, or exporting Spans;mo_ctlTraceSpan requests return the deterministic responsespan tracing is no longer supported;This is deliberately not a deletion of MO observability:
StatementInfoexport, statement status/error fields, and CU accounting are unchanged;MOErrorHolderexport remain enabled and retain per-request TraceID/SpanID correlation;SpanContext, context helpers, and the 24-byte MORPC wire layout are retained;span_infoschema/view definitions remain for upgrade compatibility, but no new Span rows are recorded;Preserved non-recording behavior
Three behaviors were independent of Span export and are preserved explicitly:
WithHungThresholdpreviously introduced real context deadlines. The 1-minute storage-usage query deadline and 30-minute frontend cleanup guard are now explicitcontext.WithTimeoutCausescopes, with the originalmoerr.CauseNewMOHungSpancause and former cancellation lifetime.trace.Generatepreviously created per-connection IDs. The non-recording tracer preserves root/child/new-root ID semantics and context propagation while ordinaryNoopTracer.Startremains zero-allocation.mo_ctlcontrolled diagnostic kinds (statement,remoteFSOperation,localFSOperation, andtnRPCHandle) were disabled by default. They remain default-off and preserve the parent context; the removed runtime enable/disable state, mutex, and map are not restored.Regression tests prove that enabled
Generatereturns non-zero, distinct root IDs; the context reaches frontend routines, structured log rows, and error rows; MORPC encode/decode preserves the IDs; formerly controlled diagnostic starts do not overwrite the parent log context; and the fully disabled/ordinary no-op paths remain no-op.Compatibility and behavior change
This intentionally removes the diagnostic Span opt-in.
disable-span=false,enable-span-profile,long-span-time, andenable-trace-debugare still accepted to avoid configuration breakage, but cannot restore Span recording or Span-triggered profiles.StatementInforetains its existing statement, transaction, session, error, and CU fields. No fake Span rows or placeholder IDs are injected. Logs and errors use real non-recording correlation IDs generated for their request context.BVT regression closure
The failed
Matrixone Utils CI / Coveragejob on headcb5e3217cewas caused by this PR, not by an unrelatedmainchange. The initialNonRecordingTracerapplied every requested kind, so a formerly default-off diagnostic start could change a log row'sspan_kindtolocalFSOperation,remoteFSOperation, ortnRPCHandle.MOZapLog.FillRowpersists that kind verbatim, whilezz_statement_query_type/query_stmt.sqlaccepts onlyinternal,statement,session, orremote, producing the observedexpected 1, actual 0.Commit
6dc3383ce0restores the old default behavior with a private static four-kind filter. It does not broaden the BVT allowlist, restore controlled-span shared state, or affect StatementInfo/CU/log/error collection. A regression test follows a controlled LocalFS start throughReportZapand raw-log row filling and verifies that the parentinternalkind is retained.Performance evidence
A controlled ABBA comparison on the same machine, configuration, data, workload, and concurrency (128 clients, 10 measured iterations per side) measured:
IsMOCtledSpanmutex-delay attribution: 43.77% / 40.58%IsMOCtledSpanfocus: no samplesThese percentages are mutex blocking-delay attribution, not CPU percentages. The result proves removal of that contention path; it does not show that Span was the primary CPU bottleneck or guarantee a 2.61% gain for every workload. Physical deletion has the same no-recording hot-path intent as the measured disabled candidate, so no additional performance gain is claimed for deletion itself. The lightweight context generator adds only ID/context propagation and does not restore the removed locks or exporter pipeline.
Validation
Validated at final head
6dc3383ce0:./pkg/util/trace/...,./pkg/fileservice,./pkg/frontend,./pkg/sql/compile,./pkg/common/log, and./pkg/common/morpc;./pkg/util/trace/...,./pkg/fileservice,./pkg/frontend, and./pkg/common/morpc;go vetfor the affected dependency chain;make build;git diff --check;NonRecordingTracer/ID-generation symbols but no executableMOTracer,MOSpan,MOHungSpan, controlled-span-state, or Span batch-processor symbols.Machine
10.222.1.50validation of the retired recording runtime:disable-span=falseconfiguration; Span recording still could not be re-enabled;system.error_info;span_inforemained unchanged at 3 -> 3;span tracing is no longer supported;IsMOCtledSpan,MOTracer,MOSpan, andMOHungSpan: no samples;trace.shutdown.complete;The final diff is limited to the trace runtime/configuration, its TraceSpan compatibility endpoint, explicit preservation of the two former hung-context deadlines, non-recording trace-context correlation, and preservation of the former default-off controlled kinds. SQL execution, storage, fileservice,
StatementInfo, and CU calculation semantics are not changed.