cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ignace Desimpel (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CASSANDRA-6677) Commitlog replay makes dropped and recreated keyspace and column family rows reappear
Date Fri, 07 Feb 2014 13:26:19 GMT

    [ https://issues.apache.org/jira/browse/CASSANDRA-6677?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13894499#comment-13894499
] 

Ignace Desimpel commented on CASSANDRA-6677:
--------------------------------------------

Sample code (uses cql-thrift). Same result with thrift only.

static void testCreateDropCreateRebootCQLA(String sHostName, int iPort) throws Exception{
		CqlResult oCqlResult;
		Charset UTF8 = Charset.forName("UTF8");
		Cassandra.Client oCassClt = makeConnectionNoKs(sHostName, iPort);		
		
		//Start from scratch or drop it here again
		String sDropColKs = "DROP KEYSPACE k1";
		try{
			oCqlResult = oCassClt.execute_cql3_query(ByteBuffer.wrap(sDropColKs.getBytes(UTF8)), Compression.NONE,
ConsistencyLevel.QUORUM);
		}catch(Throwable tt){}
		
		String sCreateKs = "CREATE KEYSPACE k1 WITH replication = {'class': 'SimpleStrategy', 'replication_factor'
: 1} ";		
		oCqlResult = oCassClt.execute_cql3_query(ByteBuffer.wrap(sCreateKs.getBytes(UTF8)), Compression.NONE,
ConsistencyLevel.QUORUM);

		oCassClt.set_keyspace("k1");
		String sCreateColFam = "CREATE COLUMNFAMILY c1 ( c1name text PRIMARY KEY)"; 
		oCqlResult = oCassClt.execute_cql3_query(ByteBuffer.wrap(sCreateColFam.getBytes(UTF8)),
Compression.NONE, ConsistencyLevel.QUORUM);
		
		String sInsertOne = "INSERT INTO c1 ( c1name ) VALUES ( 'c1value') "; 
		oCqlResult = oCassClt.execute_cql3_query(ByteBuffer.wrap(sInsertOne.getBytes(UTF8)), Compression.NONE,
ConsistencyLevel.QUORUM);
		
		String sSelectOne = "SELECT c1name FROM c1"; 
		oCqlResult = oCassClt.execute_cql3_query(ByteBuffer.wrap(sSelectOne.getBytes(UTF8)), Compression.NONE,
ConsistencyLevel.QUORUM);
		
		assert oCqlResult.getRows().size() == 1 : "There should be one row : count = " + oCqlResult.getRows().size();
		assert new String(oCqlResult.getRows().get(0).getColumns().get(0).getValue(), UTF8).equals("c1value")

			: "And the value is " + new String(oCqlResult.getRows().get(0).getColumns().get(0).getValue(),
UTF8);

		//Drop the keyspace 
		oCqlResult = oCassClt.execute_cql3_query(ByteBuffer.wrap(sDropColKs.getBytes(UTF8)), Compression.NONE,
ConsistencyLevel.QUORUM);
		
		//Redo the keyspace creation and column family
		oCqlResult = oCassClt.execute_cql3_query(ByteBuffer.wrap(sCreateKs.getBytes(UTF8)), Compression.NONE,
ConsistencyLevel.QUORUM);
		oCqlResult = oCassClt.execute_cql3_query(ByteBuffer.wrap(sCreateColFam.getBytes(UTF8)),
Compression.NONE, ConsistencyLevel.QUORUM);
		
		//Redo the select : should return ZERO rows since new keyspace was dropped
		oCqlResult = oCassClt.execute_cql3_query(ByteBuffer.wrap(sSelectOne.getBytes(UTF8)), Compression.NONE,
ConsistencyLevel.QUORUM);
		assert oCqlResult.getRows().size() == 0 : "There must be NO rows. Commitlog replay misses
droppping and re-adding keysapce and makes row reappear";
		
		//Now restart the cassandra database and execute : testCreateDropCreateRebootCQLB 
		System.exit(0);
	}
	
	static void testCreateDropCreateRebootCQLB(String sHostName, int iPort) throws Exception{
		CqlResult oCqlResult;
		Cassandra.Client oCassClt = makeConnectionNoKs(sHostName, iPort);
		oCassClt.set_keyspace("k1");
		
		String sSelectOne = "SELECT c1name FROM c1"; 
		oCqlResult = oCassClt.execute_cql3_query(ByteBuffer.wrap(sSelectOne.getBytes(Encoding.UTF8)),
Compression.NONE, ConsistencyLevel.QUORUM);
		
		assert oCqlResult.getRows().size() == 0 : "Keyspace was dropped after inserting the one
row. There shouldn't be a row. Count = " + oCqlResult.getRows().size();		
		System.out.println("Alldone");
	}

> Commitlog replay makes dropped and recreated keyspace and column family rows reappear
> -------------------------------------------------------------------------------------
>
>                 Key: CASSANDRA-6677
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-6677
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Core
>            Reporter: Ignace Desimpel
>            Priority: Minor
>             Fix For: 2.0.4
>
>
> A row can reappear after reboot of the database if the keyspace was dropped and recreated
and then rebooted.
> Thus before reboot : Create keyspaceX  + Create ColumnFamilyY + Insert row R + Drop keyspaceX
 + Create keyspaceX  + Create ColumnFamilyY . This will result in no rows.
> After reboot, the row R reappears !
> Guess this will apply to all cassandra versions?
> I will attach some sample test code.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Mime
View raw message