use of org.apache.cassandra.db.filter.TombstoneOverwhelmingException in project cassandra by apache.
the class MessageDeliveryTask method handleFailure.
private void handleFailure(Throwable t) {
if (message.doCallbackOnFailure()) {
MessageOut response = new MessageOut(MessagingService.Verb.INTERNAL_RESPONSE).withParameter(MessagingService.FAILURE_RESPONSE_PARAM, MessagingService.ONE_BYTE);
if (t instanceof TombstoneOverwhelmingException) {
try (DataOutputBuffer out = new DataOutputBuffer()) {
out.writeShort(RequestFailureReason.READ_TOO_MANY_TOMBSTONES.code);
response = response.withParameter(MessagingService.FAILURE_REASON_PARAM, out.getData());
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}
MessagingService.instance().sendReply(response, id, message.from);
}
}
use of org.apache.cassandra.db.filter.TombstoneOverwhelmingException in project cassandra by apache.
the class TombstonesTest method testBeyondThresholdSelect.
@Test
public void testBeyondThresholdSelect() throws Throwable {
String tableName = createTable("CREATE TABLE %s (a text, b text, c text, PRIMARY KEY (a, b));");
ColumnFamilyStore cfs = Keyspace.open(KEYSPACE).getColumnFamilyStore(tableName);
long oldFailures = cfs.metric.tombstoneFailures.getCount();
long oldWarnings = cfs.metric.tombstoneWarnings.getCount();
// insert exactly the amount of tombstones that *SHOULD* trigger an exception
for (int i = 0; i < FAILURE_THRESHOLD + 1; i++) execute("INSERT INTO %s (a, b, c) VALUES ('key', 'column" + i + "', null);");
try {
execute("SELECT * FROM %s WHERE a = 'key';");
fail("SELECT with tombstones beyond the threshold should have failed, but hasn't");
} catch (Throwable e) {
String error = "Expected exception instanceof TombstoneOverwhelmingException instead got " + System.lineSeparator() + Throwables.getStackTraceAsString(e);
assertTrue(error, e instanceof TombstoneOverwhelmingException);
assertEquals(oldWarnings, cfs.metric.tombstoneWarnings.getCount());
assertEquals(oldFailures + 1, cfs.metric.tombstoneFailures.getCount());
}
}
use of org.apache.cassandra.db.filter.TombstoneOverwhelmingException in project cassandra by apache.
the class TombstonesTest method testExpiredTombstones.
@Test
public void testExpiredTombstones() throws Throwable {
String tableName = createTable("CREATE TABLE %s (a text, b text, c text, PRIMARY KEY (a, b)) WITH gc_grace_seconds = 1;");
ColumnFamilyStore cfs = Keyspace.open(KEYSPACE).getColumnFamilyStore(tableName);
long oldFailures = cfs.metric.tombstoneFailures.getCount();
long oldWarnings = cfs.metric.tombstoneWarnings.getCount();
for (int i = 0; i < FAILURE_THRESHOLD + 1; i++) execute("INSERT INTO %s (a, b, c) VALUES ('key', 'column" + i + "', null);");
// not yet past gc grace - must throw a TOE
try {
execute("SELECT * FROM %s WHERE a = 'key';");
fail("SELECT with tombstones beyond the threshold should have failed, but hasn't");
} catch (Throwable e) {
assertTrue(e instanceof TombstoneOverwhelmingException);
assertEquals(++oldFailures, cfs.metric.tombstoneFailures.getCount());
assertEquals(oldWarnings, cfs.metric.tombstoneWarnings.getCount());
}
// sleep past gc grace
TimeUnit.SECONDS.sleep(2);
// past gc grace - must not throw a TOE now
try {
execute("SELECT * FROM %s WHERE a = 'key';");
assertEquals(oldFailures, cfs.metric.tombstoneFailures.getCount());
assertEquals(oldWarnings, cfs.metric.tombstoneWarnings.getCount());
} catch (Throwable e) {
fail("SELECT with expired tombstones beyond the threshold should not have failed, but has: " + e);
}
}
Aggregations