{"record":{"id":"e4b1f591579b4800","repo":"sipeed/picoclaw","slug":"get-conversation-for-s-w","errorCode":null,"errorMessage":"get conversation for %s: %w","messagePattern":"get conversation for (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/membench/ingest.go","lineNumber":71,"sourceCode":"\t\tfor _, turn := range turns {\n\t\t\tcontent := turn.Speaker + \": \" + turn.Text\n\t\t\tmsgs = append(msgs, seahorse.Message{\n\t\t\t\tRole:       \"user\",\n\t\t\t\tContent:    content,\n\t\t\t\tTokenCount: len(turn.Text) / 4,\n\t\t\t})\n\t\t}\n\n\t\t// Ingest all turns for this sample\n\t\t_, err := engine.Ingest(ctx, sessionKey, msgs)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"ingest sample %s: %w\", sample.SampleID, err)\n\t\t}\n\n\t\t// Get the conversation ID for scoped retrieval\n\t\tconv, err := store.GetConversationBySessionKey(ctx, sessionKey)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"get conversation for %s: %w\", sample.SampleID, err)\n\t\t}\n\t\tif conv == nil {\n\t\t\treturn nil, fmt.Errorf(\"conversation not found for %s after ingest\", sample.SampleID)\n\t\t}\n\t\tconvMap[sample.SampleID] = conv.ConversationID\n\t\tlog.Printf(\"Ingested sample %s: %d turns, convID=%d\", sample.SampleID, len(turns), conv.ConversationID)\n\t}\n\n\tlog.Printf(\"Seahorse ingestion complete: %d samples, %d conversations\", len(samples), len(convMap))\n\treturn &SeahorseIngestResult{\n\t\tEngine:  engine,\n\t\tConvMap: convMap,\n\t}, nil\n}\n","sourceCodeStart":53,"sourceCodeEnd":86,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/cmd/membench/ingest.go#L53-L86","documentation":"Store().GetConversationBySessionKey returned a non-nil error right after a successful Ingest for the same sample. The lookup maps sessionKey \"locomo-<sampleID>\" to the internal conversation ID used for scoped retrieval; if the underlying query fails (DB error, context cancelled), the wrap 'get conversation for <id>' propagates and ingestion aborts.","triggerScenarios":"Sqlite read error immediately after the write (I/O error, DB closed concurrently); ctx cancelled between Ingest and the lookup; store handle invalidated by engine shutdown in another goroutine.","commonSituations":"Timeout budget that expires mid-sample; tests closing the engine while ingestion runs; flaky network-backed sqlite (NFS) where a fresh read races the write.","solutions":["Check whether ctx is already cancelled and widen the deadline if so","Verify nothing else closes the engine/DB during ingestion (single owner)","Retry the single lookup once after a short sleep — it usually succeeds since Ingest reported OK","Move the DB to local disk to remove network-fs read flakiness"],"exampleFix":"// before\nconv, err := store.GetConversationBySessionKey(ctx, sessionKey)\nif err != nil {\n    return nil, fmt.Errorf(\"get conversation for %s: %w\", sample.SampleID, err)\n}\n\n// after\nconv, err := store.GetConversationBySessionKey(ctx, sessionKey)\nif err != nil && ctx.Err() == nil {\n    time.Sleep(200 * time.Millisecond)\n    conv, err = store.GetConversationBySessionKey(ctx, sessionKey)\n}\nif err != nil {\n    return nil, fmt.Errorf(\"get conversation for %s: %w\", sample.SampleID, err)\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"conv, err := store.GetConversationBySessionKey(ctx, sessionKey)\nif err != nil {\n    if ctx.Err() != nil {\n        return nil, ctx.Err()\n    }\n    time.Sleep(200 * time.Millisecond) // fresh-write visibility\n    conv, err = store.GetConversationBySessionKey(ctx, sessionKey)\n    if err != nil {\n        return nil, fmt.Errorf(\"get conversation for %s: %w\", sample.SampleID, err)\n    }\n}","preventionTips":["Don't close/shutdown the engine while an ingestion loop is mid-sample","Budget ctx deadline per-sample, not just per-run, so late samples aren't cut off","Local disk for the store avoids post-write read flakiness","Distinguish DB errors from cancellation before retrying"],"tags":["go","database","ingestion","benchmark"],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}