Repository navigation
Conversation
3 of 8 tasks
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can enable the Remediation agent and Qodo fixes findings in a dedicated fix PR Powered by Qodo |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1141 +/- ##
==========================================
+ Coverage 86.63% 86.76% +0.13%
==========================================
Files 44 44
Lines 18987 19006 +19
Branches 2963 2965 +2
==========================================
+ Hits 16449 16491 +42
+ Misses 1864 1844 -20
+ Partials 674 671 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Author
|
The same bug is in the Apache driver. I confirmed it with the same unit test on trunk (3.30.1) and sent the fix there: apache#1308. (drafted with Claude Code) |
With protocol v5 framing, _process_segment_buffer() returned without rewinding the io buffer when fewer than 6 bytes (one segment header plus its CRC24) had arrived. process_io_buffer() then called reset_io_buffer(), which keeps only the bytes after the current position, and the position was at the end, so those 1-5 header bytes were dropped. The next read was parsed from the wrong offset and the connection was defuncted with "CRC mismatch on header". It needs a socket read to end inside a segment header, so it shows up rarely and mostly with the asyncio reactor, which processes the buffer after every 4 KB read. It was seen in CI against Cassandra 5.0 during a large schema refresh. Rewind in that branch too, like the "header but incomplete payload" branch already does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fruch
force-pushed
the
fix-v5-partial-segment-header
branch
from
October 25, 2026 07:19
90f8d45 to
201b324
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With protocol v5, a read that ends 1-5 bytes into a segment header loses those bytes, and the connection is then defuncted with
CRC mismatch on header.Cause
Connection._process_segment_buffer()has three cases:seek(0)and wait for more.process_io_buffer()then callsreset_io_buffer(), which keeps only the bytes after the current position. In case 3 the position is at the end, so the partial header is discarded. The next read is parsed from the wrong offset and its header fails the CRC24 check.The fix adds the missing
seek(0)to case 3.How it was found
The new Cassandra CI job in #1135 failed once on Cassandra 5.0 + asyncio, in
test_pool_management, during a large schema refresh:It needs a socket read to end inside a header, so it's rare. It's more likely with the asyncio reactor, which processes the buffer after every 4 KB read, than with libev, which reads until the socket is empty. It doesn't affect Scylla, which negotiates down to v4, but it affects default-configured clients on Cassandra 4.0+.
The same code is in apache/cassandra-python-driver.
Testing
test_v5_segment_header_split_across_readsfeeds two segments split at every offset from 0 to 7 bytes into the second header. On master, offsets 1-5 fail. With the fix, all pass.test_pool_managementon v5 failed 10/10 runs without the fix and passed 10/10 with it.🤖 Generated with Claude Code