{"record":{"id":"980ae7d5a05a6981","repo":"weaviate/weaviate","slug":"unexpected-error-node-size-mismatch","errorCode":null,"errorMessage":"unexpected error, node size mismatch","messagePattern":"unexpected error, node size mismatch","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"adapters/repos/db/lsmkv/commitlogger.go","lineNumber":349,"sourceCode":"\n\tcl.n.Add(int64(1 + 1 + 4 + len(nodeBytes) + checksumSize))\n\n\treturn nil\n}\n\nfunc (cl *commitLogger) put(node segmentReplaceNode) error {\n\tif cl.paused {\n\t\treturn nil\n\t}\n\n\tcl.bufNode.Reset()\n\n\tki, err := node.KeyIndexAndWriteTo(cl.bufNode)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(cl.bufNode.Bytes()) != ki.ValueEnd-ki.ValueStart {\n\t\treturn fmt.Errorf(\"unexpected error, node size mismatch\")\n\t}\n\n\treturn cl.writeEntry(CommitTypeReplace, cl.bufNode.Bytes())\n}\n\nfunc (cl *commitLogger) append(node segmentCollectionNode) error {\n\tif cl.paused {\n\t\treturn nil\n\t}\n\n\tcl.bufNode.Reset()\n\n\tki, err := node.KeyIndexAndWriteTo(cl.bufNode)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(cl.bufNode.Bytes()) != ki.ValueEnd-ki.ValueStart {\n\t\treturn fmt.Errorf(\"unexpected error, node size mismatch\")","sourceCodeStart":331,"sourceCodeEnd":367,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/adapters/repos/db/lsmkv/commitlogger.go#L331-L367","documentation":"Before appending a replace-type node to the write-ahead log, the commit logger verifies that the serialized node buffer length equals the value range written into the key index (ki.ValueEnd-ki.ValueStart). A mismatch means the serializer wrote a different number of bytes than it recorded in the index, i.e. an internal serialization invariant was violated. The entry is rejected instead of writing a WAL record that later parsing could not decode.","triggerScenarios":"Calling commitlogger.Put with a segmentReplaceNode whose KeyIndexAndWriteTo serializes bytes inconsistent with its reported value range — a bug in the node serializer or a bufNode reused with stale contents.","commonSituations":"Encountered during development of lsmkv changes or on corrupted in-memory node state; practically never caused by user configuration.","solutions":["Retry the operation; if transient it indicates a race — check for concurrent writes to the same bucket","Upgrade to the latest Weaviate version, as this guards against serializer bugs fixed upstream","Capture the WAL file and report a bug with the object/key involved","Verify the bucket's WAL files are not corrupted (truncated WAL can desync buffered state)"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"err := bucket.Put(ctx, []byte(key), value)\nif err != nil {\n    if strings.Contains(err.Error(), \"node size mismatch\") {\n        // serialization invariant violated: do not spin; escalate\n        return fmt.Errorf(\"wal serializer invariant violated, please report: %w\", err)\n    }\n    return err\n}","preventionTips":["Run a single writer per bucket — never share buckets across goroutines/threads","Keep Weaviate upgraded to pick up serializer fixes","Do not hand-edit or truncate WAL files","Watch logs for repeated mismatches and report with the WAL file attached"],"tags":["lsmkv","wal","serialization","invariant"],"backgroundTag":"wal-node-size-mismatch","analyzedSha":"75aa4b6d11f8818305aafd4440b4e32794f7ca04","analyzedAt":"2026-09-04T14:58:20.392Z","contentChangedAt":"2026-09-04T14:58:20.392Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}