cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cristian Marinescu (JIRA)" <>
Subject [jira] [Created] (CASSANDRA-8280) Cassandra crashing on inserting data over 64K into indexed strings
Date Mon, 10 Nov 2014 08:36:33 GMT
Cristian Marinescu created CASSANDRA-8280:

             Summary: Cassandra crashing on inserting data over 64K into indexed strings
                 Key: CASSANDRA-8280
             Project: Cassandra
          Issue Type: Bug
          Components: Core
         Environment: Debian 7, Cassandra 2.1.1, java 1.7.0_60
            Reporter: Cristian Marinescu
            Priority: Critical

An attemtp to instert 65536 bytes in a field that is a primary index throws (correctly?) the
cassandra.InvalidRequest exception. However, inserting the same data *in a indexed field that
is not a primary index* works just fine. 

However, Cassandra will crash on next commit and never recover. So I rated it as Critical
as it can be used for DoS attacks.

Reproduce: see the snippet below:
import uuid
from cassandra import ConsistencyLevel
from cassandra import InvalidRequest
from cassandra.cluster import Cluster
from cassandra.auth import PlainTextAuthProvider
from cassandra.policies import ConstantReconnectionPolicy
from cassandra.cqltypes import UUID
# CREATE KEYSPACE cs WITH replication = {'class': 'SimpleStrategy', 'replication_factor':
# USE cs;
# CREATE TABLE test3 (name text, value uuid, sentinel text, PRIMARY KEY (name));
# CREATE INDEX test3_sentinels ON test3(sentinel);             
class CassandraDemo(object):
    def __init__(self):
        ips = [""]
        ap = PlainTextAuthProvider(username="cs", password="cs")
        reconnection_policy = ConstantReconnectionPolicy(20.0, max_attempts=1000000)
        cluster = Cluster(ips, auth_provider=ap, protocol_version=3, reconnection_policy=reconnection_policy)
        self.session = cluster.connect("cs")
    def exec_query(self, query, args):
        prepared_statement = self.session.prepare(query)
        prepared_statement.consistency_level = ConsistencyLevel.LOCAL_QUORUM
        self.session.execute(prepared_statement, args)
    def bug(self):
        k1 = UUID( str(uuid.uuid4()) )       
        long_string = "X" * 65536
        query = "INSERT INTO test3 (name, value, sentinel) VALUES (?, ?, ?);"
        args = ("foo", k1, long_string)
        self.exec_query(query, args)
        self.session.execute("DROP KEYSPACE IF EXISTS cs_test", timeout=30)
        self.session.execute("CREATE KEYSPACE cs_test WITH replication = {'class': 'SimpleStrategy',
'replication_factor': 1}")
c = CassandraDemo()

#first run

#second run, Cassandra crashes with java.lang.AssertionError

And here is the cassandra log:
ERROR [MemtableFlushWriter:3] 2014-11-06 16:44:49,263 - Exception
in thread Thread[MemtableFlushWriter:3,5,main]
java.lang.AssertionError: 65536
        at org.apache.cassandra.utils.ByteBufferUtil.writeWithShortLength(
        at org.apache.cassandra.db.ColumnIndex$Builder.maybeWriteRowHeader(
        at org.apache.cassandra.db.ColumnIndex$Builder.add( ~[apache-cassandra-2.1.1.jar:2.1.1]
        at org.apache.cassandra.db.ColumnIndex$ ~[apache-cassandra-2.1.1.jar:2.1.1]
        at ~[apache-cassandra-2.1.1.jar:2.1.1]
        at org.apache.cassandra.db.Memtable$FlushRunnable.writeSortedContents(
        at org.apache.cassandra.db.Memtable$FlushRunnable.runWith( ~[apache-cassandra-2.1.1.jar:2.1.1]
        at ~[apache-cassandra-2.1.1.jar:2.1.1]
        at org.apache.cassandra.db.ColumnFamilyStore$
        at java.util.concurrent.ThreadPoolExecutor.runWorker(
        at java.util.concurrent.ThreadPoolExecutor$
        at ~[na:1.7.0_60]

This message was sent by Atlassian JIRA

View raw message