{"record":{"id":"a92e571664aa4283","repo":"apache/cassandra","slug":"commit-log-sync-marker-s-current-file-position-d","errorCode":null,"errorMessage":"commit log sync marker's current file position %d is greater than next file position %d","messagePattern":"commit log sync marker's current file position (.+?) is greater than next file position (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/commitlog/CommitLogSegment.java","lineNumber":410,"sourceCode":"            if (!CommitLog.handleCommitError(\"Failed to sync CDC Index: \" + desc.cdcIndexFileName(), e))\n                throw new RuntimeException(e);\n        }\n    }\n\n    /**\n     * Create a sync marker to delineate sections of the commit log, typically created on each sync of the file.\n     * The sync marker consists of a file pointer to where the next sync marker should be (effectively declaring the length\n     * of this section), as well as a CRC value.\n     *\n     * @param buffer buffer in which to write out the sync marker.\n     * @param offset Offset into the {@code buffer} at which to write the sync marker.\n     * @param filePos The current position in the target file where the sync marker will be written (most likely different from the buffer position).\n     * @param nextMarker The file position of where the next sync marker should be.\n     */\n    protected static void writeSyncMarker(long id, ByteBuffer buffer, int offset, int filePos, int nextMarker)\n    {\n        if (filePos > nextMarker)\n            throw new IllegalArgumentException(String.format(\"commit log sync marker's current file position %d is greater than next file position %d\", filePos, nextMarker));\n        CRC32 crc = new CRC32();\n        updateChecksumInt(crc, (int) (id & 0xFFFFFFFFL));\n        updateChecksumInt(crc, (int) (id >>> 32));\n        updateChecksumInt(crc, filePos);\n        buffer.putInt(offset, nextMarker);\n        buffer.putInt(offset + 4, (int) crc.getValue());\n    }\n\n    abstract void write(int lastSyncedOffset, int nextMarker);\n\n    abstract void flush(int startMarker, int nextMarker);\n\n    public boolean isStillAllocating()\n    {\n        return allocatePosition.get() < endOfBuffer;\n    }\n\n    /**","sourceCodeStart":392,"sourceCodeEnd":428,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/commitlog/CommitLogSegment.java#L392-L428","documentation":"writeSyncMarker asserts an ordering invariant when stamping a sync marker into the commit log buffer: the file position where the marker is written must not exceed the position of the next marker. Throwing IllegalArgumentException means the segment's offset bookkeeping (lastMarkerOffset/allocatePosition arithmetic) is inconsistent — an internal bug, not operator error.","triggerScenarios":"CommitLogSegment.writeSyncMarker called with filePos > nextMarker, arising from corrupted marker-offset tracking under concurrent allocation or from a patched/subclassed segment implementation.","commonSituations":"Bugs in commit log allocation racing with periodic sync; custom or experimental patches to CommitLogSegment; memory corruption or faulty low-level tooling rewriting buffers.","solutions":["Report to the Cassandra project with logs/stack trace — this is an internal invariant failure.","Remove any custom patches to CommitLogSegment/CommitLogAllocator and retest on unmodified code.","Upgrade to the latest release where sync-marker races have been addressed.","Recover data by replaying intact segments; discard the corrupt segment."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    CommitLogSegment.writeSyncMarker(id, buffer, offset, filePos, nextMarker);\n} catch (IllegalArgumentException e) {\n    logger.error(\"Sync marker invariant violated (internal bug): {}\", e.getMessage());\n    throw e;\n}","preventionTips":["Do not patch or subclass CommitLogSegment offset arithmetic","Keep marker-offset bookkeeping inside the synchronized segment paths","File a JIRA with logs if this fires on unmodified Cassandra"],"tags":["commitlog","sync-marker","internal","crc"],"backgroundTag":"internal-invariant-violation","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}