def short_read_delete_test(self): """ Test short reads ultimately leaving no columns alive [#4000] """ cluster = self.cluster # Disable hinted handoff and set batch commit log so this doesn't # interfere with the test cluster.set_configuration_options(values={'hinted_handoff_enabled': False}) cluster.set_batch_commitlog(enabled=True) cluster.populate(2).start(wait_other_notice=True) node1, node2 = cluster.nodelist() session = self.patient_cql_connection(node1) self.create_ks(session, 'ks', 3) self.create_cf(session, 'cf', read_repair=0.0) # insert 2 columns in one row insert_columns(self, session, 0, 2) # Delete the row while first node is dead node1.flush() node1.stop(wait_other_notice=True) session = self.patient_cql_connection(node2, 'ks') query = SimpleStatement('DELETE FROM cf WHERE key=\'k0\'', consistency_level=ConsistencyLevel.ONE) session.execute(query) node1.start(wait_other_notice=True) # Query first column session = self.patient_cql_connection(node1, 'ks') assert_none(session, "SELECT c, v FROM cf WHERE key=\'k0\' LIMIT 1", cl=ConsistencyLevel.QUORUM)
def short_read_delete_test(self): """ Test short reads ultimately leaving no columns alive [#4000] """ cluster = self.cluster # Disable hinted handoff and set batch commit log so this doesn't # interfer with the test cluster.set_configuration_options(values={"hinted_handoff_enabled": False}, batch_commitlog=True) cluster.populate(2).start(wait_other_notice=True) node1, node2 = cluster.nodelist() session = self.patient_cql_connection(node1) self.create_ks(session, "ks", 3) self.create_cf(session, "cf", read_repair=0.0) # insert 2 columns in one row insert_columns(self, session, 0, 2) # Delete the row while first node is dead node1.flush() node1.stop(wait_other_notice=True) session = self.patient_cql_connection(node2, "ks") query = SimpleStatement("DELETE FROM cf WHERE key='k0'", consistency_level=ConsistencyLevel.ONE) session.execute(query) node1.start(wait_other_notice=True) # Query first column session = self.patient_cql_connection(node1, "ks") query = SimpleStatement("SELECT c, v FROM cf WHERE key='k0' LIMIT 1", consistency_level=ConsistencyLevel.QUORUM) res = session.execute(query) assert len(res) == 0, res
def short_read_reversed_test(self): cluster = self.cluster # Disable hinted handoff and set batch commit log so this doesn't # interfer with the test cluster.set_configuration_options(values={ 'hinted_handoff_enabled' : False}, batch_commitlog=True) cluster.populate(3).start(wait_other_notice=True) [node1, node2, node3] = cluster.nodelist() cursor = self.patient_cql_connection(node1) self.create_ks(cursor, 'ks', 3) self.create_cf(cursor, 'cf', read_repair=0.0) # insert 9 columns in one row insert_columns(self, cursor, 0, 9) # Deleting 3 last columns with a different node dead each time self.stop_delete_and_restart(1, 6) self.stop_delete_and_restart(2, 7) self.stop_delete_and_restart(3, 8) # Query 3 firsts columns cursor = self.patient_cql_connection(node1, 'ks') query = SimpleStatement('SELECT c, v FROM cf WHERE key=\'k0\' ORDER BY c DESC LIMIT 3', consistency_level=ConsistencyLevel.QUORUM) rows = cursor.execute(query) res = rows assert len(res) == 3, 'Expecting 3 values, got %d (%s)' % (len(res), str(res)) # value 6, 7 and 8 have been deleted for i in xrange(0, 3): assert res[i][1] == 'value%d' % (5-i), 'Expecting value%d, got %s (%s)' % (5-i, res[i][1], str(res))
def short_read_reversed_test(self): cluster = self.cluster # Disable hinted handoff and set batch commit log so this doesn't # interfer with the test cluster.set_configuration_options( values={'hinted_handoff_enabled': False}, batch_commitlog=True) cluster.populate(3).start() [node1, node2, node3] = cluster.nodelist() time.sleep(.5) cursor = self.patient_cql_connection(node1).cursor() self.create_ks(cursor, 'ks', 3) self.create_cf(cursor, 'cf', read_repair=0.0) # insert 9 columns in one row insert_columns(self, cursor, 0, 9) cursor.close() # Deleting 3 last columns with a different node dead each time self.stop_delete_and_restart(1, 6) self.stop_delete_and_restart(2, 7) self.stop_delete_and_restart(3, 8) # Query 3 firsts columns cursor = self.patient_cql_connection(node1, 'ks').cursor() if self.cluster.version() >= "1.2": cursor.execute( 'SELECT c, v FROM cf WHERE key=\'k0\' ORDER BY c DESC LIMIT 3', consistency_level="QUORUM") res = cursor.fetchall() assert len(res) == 3, 'Expecting 3 values, got %d (%s)' % ( len(res), str(res)) # value 6, 7 and 8 have been deleted for i in xrange(0, 3): assert res[i][1] == 'value%d' % ( 5 - i), 'Expecting value%d, got %s (%s)' % ( 5 - i, res[i][1], str(res)) else: cursor.execute( 'SELECT FIRST 3 REVERSED * FROM cf USING CONSISTENCY QUORUM WHERE key=k0' ) assert cursor.rowcount == 1 res = cursor.fetchone() # the key is returned assert len(res) == 3, 'Expecting 3 values, got %d (%s)' % ( len(res), str(res)) # value 6, 7 and 8 have been deleted for i in xrange(0, 3): assert res[i] == 'value%d' % ( 5 - i), 'Expecting value%d, got %s (%s)' % (5 - i, res[i], str(res))
def short_read_delete_test(self): """ Test short reads ultimately leaving no columns alive [#4000] """ cluster = self.cluster # Disable hinted handoff and set batch commit log so this doesn't # interfer with the test cluster.set_configuration_options( values={'hinted_handoff_enabled': False}, batch_commitlog=True) cluster.populate(2).start() [node1, node2] = cluster.nodelist() time.sleep(.5) cursor = self.patient_cql_connection(node1).cursor() self.create_ks(cursor, 'ks', 3) self.create_cf(cursor, 'cf', read_repair=0.0) # insert 2 columns in one row insert_columns(self, cursor, 0, 2) cursor.close() # Delete the row while first node is dead node1.flush() node1.stop(wait_other_notice=True) cursor = self.patient_cql_connection(node2, 'ks').cursor() if self.cluster.version() >= "1.2": cursor.execute('DELETE FROM cf WHERE key=\'k0\'', consistency_level="ONE") else: cursor.execute('DELETE FROM cf USING CONSISTENCY ONE WHERE key=k0') cursor.close() node1.start(wait_other_notice=True) time.sleep(.5) # Query first column cursor = self.patient_cql_connection(node1, 'ks').cursor() if self.cluster.version() >= "1.2": cursor.execute('SELECT c, v FROM cf WHERE key=\'k0\' LIMIT 1', consistency_level="QUORUM") res = cursor.fetchone() assert cursor.rowcount == 0, res else: cursor.execute( 'SELECT FIRST 1 * FROM cf USING CONSISTENCY QUORUM WHERE key=k0' ) assert cursor.rowcount == 1 res = cursor.fetchone() assert len(res) == 0, 'Expecting no value, got %d (%s)' % ( len(res), str(res))
def short_read_test(self): """ @jira_ticket CASSANDRA-9460 """ cluster = self.cluster # Disable hinted handoff and set batch commit log so this doesn't # interfer with the test cluster.set_configuration_options( values={'hinted_handoff_enabled': False}, batch_commitlog=True) cluster.populate(3).start(wait_other_notice=True) node1, node2, node3 = cluster.nodelist() session = self.patient_cql_connection(node1) self.create_ks(session, 'ks', 3) self.create_cf(session, 'cf', read_repair=0.0) # Repeat this test 10 times to make it more easy to spot a null pointer exception caused by a race, see CASSANDRA-9460 for k in xrange(10): # insert 9 columns in one row insert_columns(self, session, 0, 9) # Deleting 3 first columns with a different node dead each time self.stop_delete_and_restart(1, 0) self.stop_delete_and_restart(2, 1) self.stop_delete_and_restart(3, 2) # Query 3 firsts columns session = self.patient_cql_connection(node1, 'ks') query = SimpleStatement( 'SELECT c, v FROM cf WHERE key=\'k0\' LIMIT 3', consistency_level=ConsistencyLevel.QUORUM) rows = list(session.execute(query)) res = rows assert len(res) == 3, 'Expecting 3 values, got %d (%s)' % ( len(res), str(res)) # value 0, 1 and 2 have been deleted for i in xrange(1, 4): assert res[i - 1][1] == 'value%d' % ( i + 2), 'Expecting value%d, got %s (%s)' % ( i + 2, res[i - 1][1], str(res)) truncate_statement = SimpleStatement( 'TRUNCATE cf', consistency_level=ConsistencyLevel.QUORUM) session.execute(truncate_statement)
def short_read_test(self): """ @jira_ticket CASSANDRA-9460 """ cluster = self.cluster # Disable hinted handoff and set batch commit log so this doesn't # interfer with the test cluster.set_configuration_options(values={"hinted_handoff_enabled": False}, batch_commitlog=True) cluster.populate(3).start(wait_other_notice=True) node1, node2, node3 = cluster.nodelist() session = self.patient_cql_connection(node1) self.create_ks(session, "ks", 3) self.create_cf(session, "cf", read_repair=0.0) # Repeat this test 10 times to make it more easy to spot a null pointer exception caused by a race, see CASSANDRA-9460 for k in xrange(10): # insert 9 columns in one row insert_columns(self, session, 0, 9) # Deleting 3 first columns with a different node dead each time self.stop_delete_and_restart(1, 0) self.stop_delete_and_restart(2, 1) self.stop_delete_and_restart(3, 2) # Query 3 firsts columns session = self.patient_cql_connection(node1, "ks") query = SimpleStatement( "SELECT c, v FROM cf WHERE key='k0' LIMIT 3", consistency_level=ConsistencyLevel.QUORUM ) rows = session.execute(query) res = rows assert len(res) == 3, "Expecting 3 values, got %d (%s)" % (len(res), str(res)) # value 0, 1 and 2 have been deleted for i in xrange(1, 4): assert res[i - 1][1] == "value%d" % (i + 2), "Expecting value%d, got %s (%s)" % ( i + 2, res[i - 1][1], str(res), ) truncate_statement = SimpleStatement("TRUNCATE cf", consistency_level=ConsistencyLevel.QUORUM) session.execute(truncate_statement)
def short_read_test(self): cluster = self.cluster # Disable hinted handoff and set batch commit log so this doesn't # interfer with the test cluster.set_configuration_options(values={"hinted_handoff_enabled": False}, batch_commitlog=True) cluster.populate(3).start() [node1, node2, node3] = cluster.nodelist() time.sleep(0.5) cursor = self.patient_cql_connection(node1).cursor() self.create_ks(cursor, "ks", 3) self.create_cf(cursor, "cf", read_repair=0.0) # insert 9 columns in one row insert_columns(self, cursor, 0, 9) cursor.close() # Deleting 3 first columns with a different node dead each time self.stop_delete_and_restart(1, 0) self.stop_delete_and_restart(2, 1) self.stop_delete_and_restart(3, 2) # Query 3 firsts columns cursor = self.patient_cql_connection(node1, "ks").cursor() if self.cluster.version() >= "1.2": cursor.execute("SELECT c, v FROM cf WHERE key='k0' LIMIT 3", consistency_level="QUORUM") res = cursor.fetchall() assert len(res) == 3, "Expecting 3 values, got %d (%s)" % (len(res), str(res)) # value 0, 1 and 2 have been deleted for i in xrange(1, 4): assert res[i - 1][1] == "value%d" % (i + 2), "Expecting value%d, got %s (%s)" % ( i + 2, res[i - 1][1], str(res), ) else: cursor.execute("SELECT FIRST 3 * FROM cf USING CONSISTENCY QUORUM WHERE key=k0") assert cursor.rowcount == 1 res = cursor.fetchone() # the key is returned assert len(res) == 3, "Expecting 3 values, got %d (%s)" % (len(res), str(res)) # value 0, 1 and 2 have been deleted for i in xrange(1, 4): assert res[i] == "value%d" % (i + 2), "Expecting value%d, got %s (%s)" % (i + 2, res[i], str(res))
def wide_row_test(self): """ Test wide row slices """ cluster = self.cluster cluster.populate(3).start() node1, node2, node3 = cluster.nodelist() cursor = self.patient_cql_connection(node1) self.create_ks(cursor, 'ks', 1) self.create_cf(cursor, 'cf') key = 'wide' for x in xrange(1, 5001): tools.insert_columns(self, cursor, key, 100, offset=x-1) for size in (10, 100, 1000): for x in xrange(1, (50001 - size) / size): tools.query_columns(self, cursor, key, size, offset=x*size-1)
def wide_row_test(self): """ Test wide row slices """ cluster = self.cluster cluster.populate(3).start() node1, node2, node3 = cluster.nodelist() session = self.patient_cql_connection(node1) self.create_ks(session, 'ks', 1) self.create_cf(session, 'cf') key = 'wide' for x in xrange(1, 5001): tools.insert_columns(self, session, key, 100, offset=x - 1) for size in (10, 100, 1000): for x in xrange(1, (50001 - size) / size): tools.query_columns(self, session, key, size, offset=x * size - 1)
def short_read_delete_test(self): """ Test short reads ultimately leaving no columns alive [#4000] """ cluster = self.cluster # Disable hinted handoff and set batch commit log so this doesn't # interfer with the test cluster.set_configuration_options(values={"hinted_handoff_enabled": False}, batch_commitlog=True) cluster.populate(2).start() [node1, node2] = cluster.nodelist() time.sleep(0.5) cursor = self.patient_cql_connection(node1).cursor() self.create_ks(cursor, "ks", 3) self.create_cf(cursor, "cf", read_repair=0.0) # insert 2 columns in one row insert_columns(self, cursor, 0, 2) cursor.close() # Delete the row while first node is dead node1.flush() node1.stop(wait_other_notice=True) cursor = self.patient_cql_connection(node2, "ks").cursor() if self.cluster.version() >= "1.2": cursor.execute("DELETE FROM cf WHERE key='k0'", consistency_level="ONE") else: cursor.execute("DELETE FROM cf USING CONSISTENCY ONE WHERE key=k0") cursor.close() node1.start(wait_other_notice=True) time.sleep(0.5) # Query first column cursor = self.patient_cql_connection(node1, "ks").cursor() if self.cluster.version() >= "1.2": cursor.execute("SELECT c, v FROM cf WHERE key='k0' LIMIT 1", consistency_level="QUORUM") res = cursor.fetchone() assert cursor.rowcount == 0, res else: cursor.execute("SELECT FIRST 1 * FROM cf USING CONSISTENCY QUORUM WHERE key=k0") assert cursor.rowcount == 1 res = cursor.fetchone() assert len(res) == 0, "Expecting no value, got %d (%s)" % (len(res), str(res))
def short_read_reversed_test(self): cluster = self.cluster # Disable hinted handoff and set batch commit log so this doesn't # interfer with the test cluster.set_configuration_options(values={ 'hinted_handoff_enabled' : False}, batch_commitlog=True) cluster.populate(3).start() [node1, node2, node3] = cluster.nodelist() time.sleep(.5) cursor = self.cql_connection(node1).cursor() self.create_ks(cursor, 'ks', 3) self.create_cf(cursor, 'cf', read_repair=0.0) # insert 9 columns in one row insert_columns(self, cursor, 0, 9) cursor.close() # Deleting 3 last columns with a different node dead each time self.stop_delete_and_restart(1, 6) self.stop_delete_and_restart(2, 7) self.stop_delete_and_restart(3, 8) # Query 3 firsts columns cursor = self.cql_connection(node1, 'ks').cursor() if self.cluster.version() >= "1.2": cursor.execute('SELECT c, v FROM cf WHERE key=\'k0\' ORDER BY c DESC LIMIT 3', consistency_level="QUORUM") res = cursor.fetchall() assert len(res) == 3, 'Expecting 3 values, got %d (%s)' % (len(res), str(res)) # value 6, 7 and 8 have been deleted for i in xrange(0, 3): assert res[i][1] == 'value%d' % (5-i), 'Expecting value%d, got %s (%s)' % (5-i, res[i][1], str(res)) else: cursor.execute('SELECT FIRST 3 REVERSED * FROM cf USING CONSISTENCY QUORUM WHERE key=k0') assert cursor.rowcount == 1 res = cursor.fetchone() # the key is returned assert len(res) == 3, 'Expecting 3 values, got %d (%s)' % (len(res), str(res)) # value 6, 7 and 8 have been deleted for i in xrange(0, 3): assert res[i] == 'value%d' % (5-i), 'Expecting value%d, got %s (%s)' % (5-i, res[i], str(res))
def short_read_reversed_test(self): """ @jira_ticket CASSANDRA-9460 """ cluster = self.cluster # Disable hinted handoff and set batch commit log so this doesn't # interfere with the test cluster.set_configuration_options(values={'hinted_handoff_enabled': False}, batch_commitlog=True) cluster.populate(3).start(wait_other_notice=True) node1, node2, node3 = cluster.nodelist() session = self.patient_cql_connection(node1) self.create_ks(session, 'ks', 3) self.create_cf(session, 'cf', read_repair=0.0) # Repeat this test 10 times to make it more easy to spot a null pointer exception caused by a race, see CASSANDRA-9460 for k in xrange(10): # insert 9 columns in one row insert_columns(self, session, 0, 9) # Deleting 3 last columns with a different node dead each time self.stop_delete_and_restart(1, 6) self.stop_delete_and_restart(2, 7) self.stop_delete_and_restart(3, 8) # Query 3 firsts columns session = self.patient_cql_connection(node1, 'ks') query = SimpleStatement('SELECT c, v FROM cf WHERE key=\'k0\' ORDER BY c DESC LIMIT 3', consistency_level=ConsistencyLevel.QUORUM) rows = list(session.execute(query)) res = rows assert len(res) == 3, 'Expecting 3 values, got %d (%s)' % (len(res), str(res)) # value 6, 7 and 8 have been deleted for i in xrange(0, 3): assert res[i][1] == 'value%d' % (5 - i), 'Expecting value%d, got %s (%s)' % (5 - i, res[i][1], str(res)) truncate_statement = SimpleStatement('TRUNCATE cf', consistency_level=ConsistencyLevel.QUORUM) session.execute(truncate_statement)
def short_read_test(self): """ @jira_ticket CASSANDRA-9460 """ cluster = self.cluster # Disable hinted handoff and set batch commit log so this doesn't # interfer with the test cluster.set_configuration_options(values={'hinted_handoff_enabled': False}) cluster.set_batch_commitlog(enabled=True) cluster.populate(3).start(wait_other_notice=True) node1, node2, node3 = cluster.nodelist() session = self.patient_cql_connection(node1) self.create_ks(session, 'ks', 3) self.create_cf(session, 'cf', read_repair=0.0) normal_key = 'normal' reversed_key = 'reversed' # Repeat this test 10 times to make it more easy to spot a null pointer exception caused by a race, see CASSANDRA-9460 for k in xrange(10): # insert 9 columns in two rows insert_columns(self, session, normal_key, 9) insert_columns(self, session, reversed_key, 9) # Delete 3 first columns (and 3 last columns, for the reversed version) with a different node dead each time for node, column_number_to_delete in zip(range(1, 4), range(3)): self.stop_node(node) self.delete(node, normal_key, column_number_to_delete) self.delete(node, reversed_key, 8 - column_number_to_delete) self.restart_node(node) # Query 3 firsts columns in normal order session = self.patient_cql_connection(node1, 'ks') query = SimpleStatement( 'SELECT c, v FROM cf WHERE key=\'k{}\' LIMIT 3'.format(normal_key), consistency_level=ConsistencyLevel.QUORUM) rows = list(session.execute(query)) res = rows assert_length_equal(res, 3) # value 0, 1 and 2 have been deleted for i in xrange(1, 4): self.assertEqual('value{}'.format(i + 2), res[i - 1][1]) # Query 3 firsts columns in reverse order session = self.patient_cql_connection(node1, 'ks') query = SimpleStatement( 'SELECT c, v FROM cf WHERE key=\'k{}\' ORDER BY c DESC LIMIT 3'.format(reversed_key), consistency_level=ConsistencyLevel.QUORUM) rows = list(session.execute(query)) res = rows assert_length_equal(res, 3) # value 6, 7 and 8 have been deleted for i in xrange(0, 3): self.assertEqual('value{}'.format(5 - i), res[i][1]) session.execute('TRUNCATE cf')