Skip to content

Instantly share code, notes, and snippets.

@sotodel
sotodel / network-strace.out
Last active March 5, 2017 23:18
A sample output of an strace showing how the CQL frame is broken
[pid 32673] 15:17:34.824119 sendmsg(8, {msg_name(0)=NULL, msg_iov(1)=[{"\4\0\0\0\t\0\0\0A\0\0\0=INSERT INTO test.protocol_error (pkey, content) VALUES (?, ?)", 74}], msg_controllen=0, msg_flags=0}, 0) = 74
[pid 32673] 15:17:34.824663 recvfrom(8, "\204\0\0\0\10\0\0\0U\0\0\0\4\0\20\2545\250\260\34\26152:{i\261\204\266\3759\0\0\0\1\0\0\0\2\0\0\0\1\0\0\0\4test\0\16protocol_error\0\4pkey\0\t\0\7content\0\r\0\0\0\4\0\0\0\0", 2280, 0, NULL, NULL) = 94
[pid 32675] 15:17:34.841148 sendmsg(8, {msg_name(0)=NULL, msg_iov(2)=[{"\4\0\0\0\n\0\0]x\0\20\2545\250\260\34\26152:{i\261\204\266\3759\0\n\5\0\2\0\0\0\4\0\0\0\0\0\0]Q0_1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16_17_18_19_20_21_"..., 16384}, {"3490_3491_3492_3493_3494_3495_3496_3497_3498_3499_3500_3501_3502_3503_3504_3505_3506_3507_3508_3509_"..., 7553}], msg_controllen=0, msg_flags=0}, 0) = 23937
[pid 32673] 15:17:34.842480 recvfrom(8, "\204\0\0\0\10\0\0\0\4\0\0\0\1", 2280, 0, NULL, NULL) = 13
[pid 32674] 15:17:34.844107 sendmsg(8, {msg_name(0)=NULL, msg_iov(2)=[{"\4\0\0\1
@sotodel
sotodel / cql-tcpdump-magic-protocol-version.out
Last active March 5, 2017 18:50
Snapshot of where the protocol breaks
10:18:34.295415 IP (tos 0x0, ttl 64, id 4765, offset 0, flags [DF], proto TCP (6), length 16436)
mountainjust-vm0.corp.yahoo.com.38383 > mountainjust-vm0.corp.yahoo.com.9042: Flags [P.], cksum 0x7a37 (incorrect -> 0x5244), seq 40427:56811, ack 117, win 4, options [nop,nop,TS val 79452253 ecr 79452252], length 16384
0x0000: 4500 4034 129d 4000 4006 ae16 0a49 92bf E.@4..@.@....I..
0x0010: 0a49 92bf 95ef 2352 025f e887 22a4 ffd7 .I....#R._.."...
0x0020: 8018 0004 7a37 0000 0101 080a 04bc 585d ....z7........X]
0x0030: 04bc 585c 0400 0001 0a00 005d 7800 10ac ..X\.......]x...
0x0040: 35a8 b01c b135 323a 7b69 b184 b6fd 3900 5....52:{i....9.
0x0050: 0a05 0002 0000 0004 0000 0002 0000 5d51 ..............]Q
0x0060: 305f 315f 325f 335f 345f 355f 365f 375f 0_1_2_3_4_5_6_7_
0x0070: 385f 395f 3130 5f31 315f 3132 5f31 335f 8_9_10_11_12_13_
@sotodel
sotodel / cql-tcpdump-error-response.out
Created March 5, 2017 17:33
Cassandra's response to a truncated frame
10:18:34.299739 IP (tos 0x0, ttl 64, id 42867, offset 0, flags [DF], proto TCP (6), length 136)
mountainjust-vm0.corp.yahoo.com.9042 > mountainjust-vm0.corp.yahoo.com.38383: Flags [P.], cksum 0x3a8b (incorrect -> 0xbe3a), seq 239:323, ack 88301, win 193, options [nop,nop,TS val 79452257 ecr 79452254], length 84
0x0000: 4500 0088 a773 4000 4006 58ec 0a49 92bf E....s@.@.X..I..
0x0010: 0a49 92bf 2352 95ef 22a5 0051 0260 a389 .I..#R.."..Q.`..
0x0020: 8018 00c1 3a8b 0000 0101 080a 04bc 5861 ....:.........Xa
0x0030: 04bc 585e 8400 0000 0000 0000 4b00 0000 ..X^........K...
0x0040: 0a00 4549 6e76 616c 6964 206f 7220 756e ..EInvalid.or.un
0x0050: 7375 7070 6f72 7465 6420 7072 6f74 6f63 supported.protoc
0x0060: 6f6c 2076 6572 7369 6f6e 2028 3935 293b ol.version.(95);
0x0070: 2068 6967 6865 7374 2073 7570 706f 7274 .highest.support
@sotodel
sotodel / cql-tcpdump-bad-frame.out
Last active March 10, 2017 04:48
A sample broken CQL frame
10:18:34.254330 IP (tos 0x0, ttl 64, id 4764, offset 0, flags [DF], proto TCP (6), length 16436)
mountainjust-vm0.corp.yahoo.com.38383 > mountainjust-vm0.corp.yahoo.com.9042: Flags [.], cksum 0x7a37 (incorrect -> 0x92a5), seq 24043:40427, ack 117, win 4, options [nop,nop,TS val 79452211 ecr 79452207], length 16384
0x0000: 4500 4034 129c 4000 4006 ae17 0a49 92bf E.@4..@.@....I..
0x0010: 0a49 92bf 95ef 2352 025f a887 22a4 ffd7 .I....#R._.."...
0x0020: 8010 0004 7a37 0000 0101 080a 04bc 5833 ....z7........X3
0x0030: 04bc 582f 0400 0000 0a00 005d 7800 10ac ..X/.......]x...
0x0040: 35a8 b01c b135 323a 7b69 b184 b6fd 3900 5....52:{i....9.
0x0050: 0a05 0002 0000 0004 0000 0001 0000 5d51 ..............]Q
0x0060: 305f 315f 325f 335f 345f 355f 365f 375f 0_1_2_3_4_5_6_7_
0x0070: 385f 395f 3130 5f31 315f 3132 5f31 335f 8_9_10_11_12_13_
@sotodel
sotodel / cql-tcpdump-full-frame.out
Last active March 10, 2017 03:42
Sample single frame output of "tcpdump -i lo ‘port 9042’ -vv -X"
10:18:34.248245 IP (tos 0x0, ttl 64, id 4762, offset 0, flags [DF], proto TCP (6), length 16436)
mountainjust-vm0.corp.yahoo.com.38383 > mountainjust-vm0.corp.yahoo.com.9042: Flags [.], cksum 0x7a37 (incorrect -> 0xf050), seq 106:16490, ack 104, win 4, options [nop,nop,TS val 79452205 ecr 79452185], length 16384
0x0000: 4500 4034 129a 4000 4006 ae19 0a49 92bf E.@4..@.@....I..
0x0010: 0a49 92bf 95ef 2352 025f 4b06 22a4 ffca .I....#R._K."...
0x0020: 8010 0004 7a37 0000 0101 080a 04bc 582d ....z7........X-
0x0030: 04bc 5819 0400 0000 0a00 005d 7800 10ac ..X........]x...
0x0040: 35a8 b01c b135 323a 7b69 b184 b6fd 3900 5....52:{i....9.
0x0050: 0a05 0002 0000 0004 0000 0000 0000 5d51 ..............]Q
0x0060: 305f 315f 325f 335f 345f 355f 365f 375f 0_1_2_3_4_5_6_7_
0x0070: 385f 395f 3130 5f31 315f 3132 5f31 335f 8_9_10_11_12_13_
@sotodel
sotodel / ProtocolVersionError.cs
Last active March 5, 2017 16:00
A small driver program to reproduce the "Invalid or unsupported protocol version" exception
class ProtocolVersionError
{
public static void Main (string[] args)
{
var socketOptions = new SocketOptions ().SetSendBufferSize (2048).SetReceiveBufferSize (256); // lowest acceptable values
var poolingOptions = new PoolingOptions ().SetMaxConnectionsPerHost (HostDistance.Local, 1).SetCoreConnectionsPerHost (HostDistance.Local, 1);
var session = Cluster.Builder ().AddContactPoint ("localhost").WithSocketOptions (socketOptions).WithPoolingOptions (poolingOptions).Build ().Connect ();
var preparedStatement = session.Prepare ("INSERT INTO test.protocol_error (pkey, content) VALUES (?, ?)");
string text = string.Join ("_", Enumerable.Range (0, 5000));
for (int key = 0; key < 1000; key++) {
@sotodel
sotodel / cassandra-stack-trace
Last active March 5, 2017 21:42
Stack trace corresponding to the protocol version error
WARN [epollEventLoopGroup-2-3] 2017-03-05 13:41:54,163 Slf4JLogger.java:151 - An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
io.netty.handler.codec.DecoderException: org.apache.cassandra.transport.ProtocolException: Invalid or unsupported protocol version (95); highest supported is 4
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:442) ~[netty-all-4.0.44.Final.jar:4.0.44.Final]
at io.netty.handler.codec.ByteToMessageDecoder.channelInputClosed(ByteToMessageDecoder.java:375) ~[netty-all-4.0.44.Final.jar:4.0.44.Final]
at io.netty.handler.codec.ByteToMessageDecoder.channelInputClosed(ByteToMessageDecoder.java:342) ~[netty-all-4.0.44.Final.jar:4.0.44.Final]
at io.netty.handler.codec.ByteToMessageDecoder.channelInactive(ByteToMessageDecoder.java:325) ~[netty-all-4.0.44.Final.jar:4.0.44.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInact
@sotodel
sotodel / native_protocol_v4_schema
Created February 24, 2017 01:41
The layout of a CQL frame
0 8 16 24 32 40
+---------+---------+---------+---------+---------+
| version | flags | stream | opcode |
+---------+---------+---------+---------+---------+
| length |
+---------+---------+---------+---------+
| |
. ... body ... .
. .
+----------------------------------------