{"record":{"id":"3b5f17a10592a8eb","repo":"t8y2/dbx","slug":"iotdb-go-client-panicked-while-executing-statement","errorCode":null,"errorMessage":"IoTDB Go client panicked while executing statement: %v","messagePattern":"IoTDB Go client panicked while executing statement: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/iotdb/driver.go","lineNumber":57,"sourceCode":"\t\treturn dataset.Close()\n\t}\n\treturn nil\n}\n\nfunc (s *nativeIoTDBSession) Close() error {\n\treturn s.session.Close()\n}\n\nfunc executeIoTDBStatement(ctx context.Context, session *client.Session, sql string) (dataset *client.SessionDataSet, err error) {\n\tdefer func() {\n\t\tif recovered := recover(); recovered != nil {\n\t\t\tif ctxErr := ctx.Err(); ctxErr != nil {\n\t\t\t\tdataset = nil\n\t\t\t\terr = ctxErr\n\t\t\t\treturn\n\t\t\t}\n\t\t\tdataset = nil\n\t\t\terr = fmt.Errorf(\"IoTDB Go client panicked while executing statement: %v\", recovered)\n\t\t}\n\t}()\n\treturn session.ExecuteStatementWithContext(ctx, sql)\n}\n\ntype connectionConfig struct {\n\tHost                  string\n\tPort                  int\n\tNodeURLs              []string\n\tUsername              string\n\tPassword              string\n\tDatabase              string\n\tDialect               string\n\tFetchSize             int32\n\tTimeZone              string\n\tConnectRetryMax       int\n\tConnectTimeoutMS      int\n\tEnableCompression     bool","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/iotdb/driver.go#L39-L75","documentation":"The driver wraps session.ExecuteStatementWithContext in a recover guard because some IoTDB Go client failures manifest as panics. When a panic occurs, the deferred function converts it into a regular error 'IoTDB Go client panicked while executing statement: %v' so callers get a normal error instead of crashing the process.","triggerScenarios":"Executing a statement through the driver's execute helper when the IoTDB Go client panics internally (nil dataset handling, malformed response, closed session race).","commonSituations":"Server closed the connection mid-query; unsupported data type in the response triggering a client nil-deref; concurrent use of a session from multiple goroutines.","solutions":["Inspect the wrapped panic value in the error message for the root cause","Recreate/refresh the session and retry the statement","Upgrade the IoTDB Go client library to a version with the panic fixed","Avoid sharing the session across goroutines without synchronization"],"exampleFix":"// before\nrows, err := conn.QueryContext(ctx, sql) // process died on panic\n// after\nrows, err := conn.QueryContext(ctx, sql)\nif err != nil && strings.Contains(err.Error(), \"panicked\") {\n    session, err = openSession(cfg) // recover by reopening session\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"rows, err := conn.QueryContext(ctx, sql)\nif err != nil {\n  var retriable bool\n  if strings.Contains(err.Error(), \"IoTDB Go client panicked\") {\n    retriable = true // reopen session before retry\n  }\n  if !retriable {\n    return err\n  }\n  if err := reopenSession(ctx); err != nil { return err }\n  rows, err = conn.QueryContext(ctx, sql)\n}","preventionTips":["Keep the IoTDB Go client library up to date","Serialize access to the session across goroutines","Check ctx cancellation before issuing statements","Monitor for repeated panics as a signal of an incompatible server/client version"],"tags":["panic","iotdb","driver","recovery"],"backgroundTag":"client-library-panic","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}