{"record":{"id":"cb0cfb03aa0f86f4","repo":"microsoft/FASTER","slug":"checksum-failed-for-read","errorCode":null,"errorMessage":"Checksum failed for read","messagePattern":"Checksum failed for read","errorType":"exception","errorClass":"FasterException","httpStatus":null,"severity":"critical","filePath":"cs/src/core/FasterLog/FasterLog.cs","lineNumber":2638,"sourceCode":"                }\n                ctx.completedRead.Release();\n            }\n        }\n\n        private (byte[], int) GetRecordAndFree(SectorAlignedMemory record)\n        {\n            if (record == null)\n                return (null, 0);\n\n            byte[] result;\n            int length;\n            unsafe\n            {\n                var ptr = record.GetValidPointer();\n                length = GetLength(ptr);\n                if (!VerifyChecksum(ptr, length))\n                {\n                    throw new FasterException(\"Checksum failed for read\");\n                }\n                result = getMemory != null ? getMemory(length) : new byte[length];\n                fixed (byte* bp = result)\n                {\n                    Buffer.MemoryCopy(ptr + headerSize, bp, length, length);\n                }\n            }\n            record.Return();\n            return (result, length);\n        }\n\n        private (IMemoryOwner<byte>, int) GetRecordAsMemoryOwnerAndFree(SectorAlignedMemory record, MemoryPool<byte> memoryPool)\n        {\n            if (record == null)\n                return (null, 0);\n\n            IMemoryOwner<byte> result;\n            int length;","sourceCodeStart":2620,"sourceCodeEnd":2656,"githubUrl":"https://github.com/microsoft/FASTER/blob/321d872eabda6a0345c8bd76419f89723ed864ae/cs/src/core/FasterLog/FasterLog.cs#L2620-L2656","documentation":"When reading a record into a byte[] (Read/ReadAsync with byte allocation), FasterLog verifies the record's stored checksum. VerifyChecksum failing means the on-disk bytes no longer match the checksum written with the record - corruption on the log device or a torn/partial write. Thrown at FasterLog.cs:2638.","triggerScenarios":"Calling FasterLog.Read / ReadAsync (byte[] overload) at an address whose record bytes were corrupted on the LogDevice - failed disk write, bit rot, external modification of the device file, or reading a partially flushed record.","commonSituations":"Hardware/disk failures, copying or truncating the log device file externally, buggy custom device implementations (e.g. in-memory or sharded devices not persisting all bytes), or reading past what was safely committed after a crash.","solutions":["Verify the LogDevice contents were not externally modified; restore from a known-good copy/backup.","Scan the log to find the last valid record and truncate/reposition iteration before the corrupt address.","Test the storage hardware/disk for errors and check for partial writes from a crash; use a device layer with proper flush/fsync.","If using a custom IDevice implementation, verify it persists the full record including headers and checksums."],"exampleFix":"// before\nvar (result, _, _) = log.Read(corruptAddress); // throws on checksum failure\n// after\ntry\n{\n    var (result, _, _) = log.Read(address);\n}\ncatch (FasterException) // checksum/corruption\n{\n    // fall back to last known-good address or rebuild log from backup\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { var (result, _, _) = log.Read(address); } catch (FasterException ex) when (ex.Message.Contains(\"Checksum failed\")) { // quarantine address, alert, restore from backup, or scan for last valid record\n}","preventionTips":["Use reliable storage and devices that fsync before commit acknowledgment.","Back up log device files; never edit them externally.","Monitor for hardware errors and test crash-recovery regularly.","Validate custom IDevice implementations under crash/failure injection."],"tags":["fasterlog","checksum","corruption","csharp"],"backgroundTag":"checksum-mismatch","analyzedSha":"321d872eabda6a0345c8bd76419f89723ed864ae","analyzedAt":"2026-09-15T22:18:00.693Z","contentChangedAt":"2026-09-15T22:18:00.693Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}