Skip to main content

Go Debugging and Observability

Attach runtime.NewSQLExecutionEvidenceStore() only to a trusted server context. The store retains parameters; use the generated Debug Assist's SafeSQLEvidenceFrom(...) projection before exposing diagnostics.

evidence := runtime.NewSQLExecutionEvidenceStore()
context.WithRuntimeTelemetrySink(evidence)
evidence.EnableQuery()

rows, err := lib.Q.Schools().Limit(20).
Comment("Diagnose the school search").
Purpose("Verify filters, facets, and relation loading").
ExecuteForList(context)
if err != nil { return err }

safe := SafeSQLEvidenceFrom(evidence.Snapshot())

Use EnableAll(), EnableQuery(), EnableMutation(), and Disable(); mode changes clear old entries. Select and mutation output can be disabled independently. The default stderr text sink is operator-only; remove it with WithDiagnosticSQLLogSink(nil).

Run the Facet, aggregate, deep relation, Top-N, and audited save examples from Go advanced data operations. Correlate trace, aliases, parameterized SQL, duration, result count, and affected rows while preserving native errors.

Install telemetry with context.WithRuntimeTelemetry(telemetry). Raw audit and the safe AppAuditEventSink remain separate. Go Request Policy currently covers select, insert, update, delete, and recover; run tenant-negative tests for all of them plus relations, Facets, aggregates, and federation. Use RuntimeReadiness() to verify trusted startup and provider reachability.

Finish with the shared checklist.

Order troubleshooting​

For the full operation and recovery sequence, use the Go mutation recipes: deletion, state changes and version conflicts.

Start with the Go Order tutorial and API usage guide. Diagnose the first native error before changing a dependency or rerunning a suite. Compare the failing runtime, model and fixture against the authority for that operation.

SymptomWhat to inspectNext action
ORDER_OK is printed but the wrong Order is visibleAbsolute database path, model revision and selected fixture.The first-edit fixture has three Orders; pagination and insights use separate nine-/ten-order fixtures. Keep each in its own database and use business keys, not copied numeric IDs.
Empty result or duplicate business identityQuery cardinality and scoped predicates.Keep the expected-one check. An empty result is distinct from a provider exception. A buyer filter alone does not authorize a tenant.
Wrong total or omitted item after editFull scalar/relation loading, item bounds and money validation.Reload the complete bounded collection before calculating totals; a preview is not a full edit graph and omission is not deletion.
Method names or return values disagree with a language translationThe generated Go facade and expression packages have distinct casing and value/presence results.Use the retained Go excerpt or scoped Assist; preserve err and the (value, present) result instead of guessing a Java-shaped call.
NotLoaded panic becomes a successful empty resultA broad recover handler discarded the field path.Preserve the original panic details. The example’s missing helper is a negative-test reporter, not a normal query fallback.
A negative page offset becomes an enormous unsigned valueThe cast to uint64 happened before validation.Reject signed negative bounds first; follow the bounded-page function’s order of operations.
Cancellation reports sql.ErrTxDone from rollbackNative database/sql auto-rollback may have completed before explicit rollback.Preserve the native error and cancelled context. Check actual in-use connections, unchanged data and writer-lock release; that terminal-state error alone does not prove a leak.
Goroutine or connection count growsAn active request, native transaction, pool opener or unreleased owner may be involved.Compare warmed and quiescent observations, not one instantaneous count. Join owned goroutines and close the owned sql.DB; the soak receipt records the fixed sampling delay and original failures.

Order query troubleshooting​

Use Go Order Queries with the matching export/insights fixture and recorded workspace. Diagnose the native plan and result carrier before changing an optimizer, cache or numeric conversion.

SymptomWhat to inspectNext action
Export count is 9 instead of 8Export uses a buyer-only predicate; the ten-order fixture adds an export-buyer EUR control.Use the nine-order export database. Retained-ID and summary recipes deliberately use the ten-order database and a currency predicate.
Empty export tail looks like failureThe ascending export's final offset 9 reports CACHE_MISS, zero rows and exact total 8.Stop on the empty tail normally. For retained IDs an empty tail can instead be an ID_SET_HIT.
ID overflow shows 5 while total is 8Capacity 4, lower-bound scan and exact provider COUNT.Keep observedCount separate from the matching total; do not retain a partial set or present 5 as the exact count.
Grand total equals a page/preview sumParent page size, child preview size and predicates on every aggregate/Facet request.Aggregate the whole filtered set in the provider. In the all-USD fixture it is 8/35350, even though only three parents are visible.
Empty sum or zero buckets are unexpectedEmpty groups, the one-row overall aggregate, and include-all versus matched-only Facets.Preserve overall count 0/sum null; keep zero status buckets only for the requested all-status variant.
Unsigned offsets or capacity values look enormousThe recipe validates signed bounds before uint64 conversion.Keep the native Go parameter types and chain-ending dots from the source; do not translate another language’s offset signature.
Aggregate wrappers are printed or converted incorrectlyExecuteRecords yields TeaQL Values and native status key order_status.Use TryU64() and TryF64(), checking presence. Use nullable handling for the empty overall sum instead of the required helper.
Plan/count is read as a page result or guessed from a namespaceThe native observations live on the context; the store wrapper also retains actual keys/events.Read them after the query; IDSetCount() returns (count, accuracy), not a presence flag. Exact total is the checked SmartList TotalCount, not the observed lower bound.

Read the plan immediately after its request; a namespace string or stale observation from another request is not proof of reuse. The existing query cases record actual provider SQL, keys, builds/hits, elapsed expiry/invalidation events and unchanged database snapshots. Use that evidence first. Fixed-data reads do not supply a concurrent-write snapshot or a distributed-cache guarantee. All original runtime pending-release and generator-deployment qualifications remain.

Order isolation troubleshooting​

Use Go Order Isolation with the v1.1 model/library and fresh eight-order database. Inspect the facade boundary and actual provider predicates before broadening access or changing a cache namespace.

Symptom / codeWhat to inspectNext action
Wrong model or missing tenant-key APIv1.0 core/query workspace versus the v1.1 isolation library, manifest and database.Use the retained regenerated isolation set; this is a fresh-database tutorial, not a live migration. Do not hand-edit generated files.
UNAUTHENTICATED / FORGED_SCOPEServer-owned session resolution and identity/policy fields in business JSON.Keep client fields out of the session tuple; the fixture key is not a production credential.
INVALID_TRUSTED_SCOPEZero/multiple tenant roots for the resolved key.Fail closed and repair provisioning; never choose an arbitrary root.
Foreign ID gives NOT_FOUNDRoot + buyer predicates and parent-owned item resolution.Preserve the common missing/foreign response; do not make a public unscoped lookup to distinguish them.
INVALID_BOUNDS, FORBIDDEN_FIELD, FORBIDDEN_OPERATIONNative numeric type, exact patch keys and read-only actor.Use integer 1–2 and the exact note/label patch. Do not coerce identity, strip extra fields or partially save.
List is scoped but summary/cache is notSame trusted predicates on every aggregate and retained request.Expect count 2/7700 cents; cache a,b,c,a must BUILD,BUILD,BUILD,HIT on one context with distinct scope identities.
Child edit reads a partial graph or changes unrelated versionsThree-child sentinel, two-child supported bound and native save path.Detail/edit overflow returns ITEM_LIMIT; preserve scoped complete-state loading and compare unrelated rows.
Numeric IDs, scope or records follow another language’s shapeJSON numbers enter as float64; native relation is WithCommercePlatformIs; aggregate fields return checked Value conversions.Validate before uint64 casts, preserve error handling and (value, present) conversion checks; keep the scalar note reload.
Audit actor or HTTP authorization is assumed from response metadataThe example tuple is separate from native context principal and transport authentication.Wire real authenticated membership/principal mapping at the service boundary. JSON actor metadata and an audit reason do not prove that integration.

The isolation receipt checks the named console requests with SQL and SQLite snapshots. It does not certify arbitrary raw Q/database access, exhaustive hostile JSON, production migration or authorization revocation during a save. Keep runtime and generator release marks from the API scope guide.

Read the evidence in order​

QuestionExisting authority
Query shape, null state, edit, page or analytic resultCore Order receipt, this language’s native source, and the selected fixture.
Stale winner or atomic child failureConcurrent writes and the stored unchanged/authoritative database snapshots. Busy/locked and timeout errors do not qualify as version conflicts.
Request cancellation, provider statement failure or real COMMIT failureLifecycle evidence. Preserve the native error and verify rollback before retry.
Transaction, connection or task ownership after drain/closeFinite soak evidence. Separate active leases from idle owned connections and verify the final native close/lifetime end.
Published package differs from a recorded workspace PASSRelease qualifications. Keep the pending-release marker and exact runtime source/package identity.

Collect the failing phase, native error type/message, model and fixture revision, resolved runtime/package identity, and parameterized SQL shape/affected rows. Keep raw parameters and rendered SQL in the trusted operator boundary. Runtime telemetry sampling is not proof that an audit event was delivered or a transaction committed.

Reuse the existing failure and successful recovery evidence first. If a specific claim still has no authority, isolate that one operation on a disposable database and record the minimal result. Keep that reproduction scoped to the failing operation. Preserve School, every historical Order receipt, all six lifecycle/soak workspace pending-release qualifications, and the generator repairs pending deployment.

This language’s recorded advanced Order result remains WORKSPACE PASS — RELEASE PENDING.