{"record":{"id":"0fcaad5cacf9034e","repo":"t8y2/dbx","slug":"connection-runtime-is-not-initialized","errorCode":null,"errorMessage":"connection runtime is not initialized","messagePattern":"connection runtime is not initialized","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/vastbase-go/runtime_pool.go","lineNumber":144,"sourceCode":"\tif validator == nil {\n\t\treturn nil\n\t}\n\treturn validator.Close()\n}\n\nfunc (connectionRuntime *connectionRuntime) database() *sql.DB {\n\tconnectionRuntime.mu.Lock()\n\tdefer connectionRuntime.mu.Unlock()\n\treturn connectionRuntime.validator\n}\n\nfunc (connectionRuntime *connectionRuntime) queryListTables(query, schema string) (*sql.Rows, error) {\n\tconnectionRuntime.mu.Lock()\n\tstatement := connectionRuntime.listTablesStatement\n\tif statement == nil {\n\t\tif connectionRuntime.validator == nil {\n\t\t\tconnectionRuntime.mu.Unlock()\n\t\t\treturn nil, errors.New(\"connection runtime is not initialized\")\n\t\t}\n\t\tprepared, err := connectionRuntime.validator.Prepare(query)\n\t\tif err != nil {\n\t\t\tconnectionRuntime.mu.Unlock()\n\t\t\treturn nil, err\n\t\t}\n\t\tconnectionRuntime.listTablesStatement = prepared\n\t\tstatement = prepared\n\t}\n\tconnectionRuntime.mu.Unlock()\n\treturn statement.Query(schema)\n}\n\nfunc (s *server) acquireOperationPermit(method string) (func(), error) {\n\tif s.connectionRuntime == nil {\n\t\treturn func() {}, nil\n\t}\n\tmetadata := isMetadataOperation(method) || strings.EqualFold(strings.TrimSpace(s.params.SessionRole), \"metadata\")","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/vastbase-go/runtime_pool.go#L126-L162","documentation":"connectionRuntime.queryListTables returns this when the runtime's prepared listTables statement is absent AND its validator *sql.DB is nil — i.e. the connection runtime was never initialized (or already shut down after the grace period). Raised in the cachedListTablesQuery path.","triggerScenarios":"cachedListTablesQuery -> queryListTables before the runtime's initialize/prepare ran; after runtime shutdown closed the validator and cleared listTablesStatement; a race where a table-list request lands during teardown.","commonSituations":"Requesting table lists during agent startup before the runtime warms up; requesting after connectionRuntimeGracePeriod (30s) expired and the runtime was torn down; a closed DB connection while cached metadata is still referenced.","solutions":["Reconnect/reinitialize the connection runtime (trigger the agent's connect path) before listing tables","Check that the runtime's validator DB was successfully opened at startup","Guard client code against issuing table-list calls during agent shutdown windows"],"exampleFix":"// before\nrows, err := agent.ListTables(ctx, schema) // runtime may be uninitialized\n// after\nif err := agent.EnsureRuntimeInitialized(ctx); err != nil { return err }\nrows, err := agent.ListTables(ctx, schema)","handlingStrategy":"fallback","validationCode":"if runtime == nil || runtime.Validator() == nil { return errors.New(\"runtime not ready; reconnect\") }","typeGuard":"func runtimeReady(rt *connectionRuntime) bool { rt.mu.Lock(); defer rt.mu.Unlock(); return rt.validator != nil }","tryCatchPattern":"rows, err := cachedListTablesQuery(q, schema)\nif err != nil && strings.Contains(err.Error(), \"not initialized\") {\n    if ierr := initRuntime(ctx); ierr != nil { return ierr }\n    rows, err = cachedListTablesQuery(q, schema)\n}","preventionTips":["Initialize the runtime during connect before serving list-tables requests","Re-init after grace-period shutdown; do not serve from a torn-down runtime","Add readiness probes so requests wait for warm-up"],"tags":["initialization","runtime","lifecycle"],"backgroundTag":"runtime-not-initialized","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}