Search in sources :

Example 1 with MutationExceededMaxSizeException

use of org.apache.cassandra.db.MutationExceededMaxSizeException in project cassandra by apache.

the class BlockingReadRepairs method createRepairMutation.

/**
 * Create a read repair mutation from the given update, if the mutation is not larger than the maximum
 * mutation size, otherwise return null. Or, if we're configured to be strict, throw an exception.
 */
public static Mutation createRepairMutation(PartitionUpdate update, ConsistencyLevel consistency, InetAddressAndPort destination, boolean suppressException) {
    if (update == null)
        return null;
    DecoratedKey key = update.partitionKey();
    Mutation mutation = new Mutation(update);
    int messagingVersion = MessagingService.instance().versions.get(destination);
    try {
        mutation.validateSize(messagingVersion, 0);
        return mutation;
    } catch (MutationExceededMaxSizeException e) {
        Keyspace keyspace = Keyspace.open(mutation.getKeyspaceName());
        TableMetadata metadata = update.metadata();
        if (DROP_OVERSIZED_READ_REPAIR_MUTATIONS) {
            logger.debug("Encountered an oversized ({}/{}) read repair mutation for table {}, key {}, node {}", e.mutationSize, MAX_MUTATION_SIZE, metadata, metadata.partitionKeyType.getString(key.getKey()), destination);
        } else {
            logger.warn("Encountered an oversized ({}/{}) read repair mutation for table {}, key {}, node {}", e.mutationSize, MAX_MUTATION_SIZE, metadata, metadata.partitionKeyType.getString(key.getKey()), destination);
            if (!suppressException) {
                int blockFor = consistency.blockFor(keyspace.getReplicationStrategy());
                Tracing.trace("Timed out while read-repairing after receiving all {} data and digest responses", blockFor);
                throw new ReadTimeoutException(consistency, blockFor - 1, blockFor, true);
            }
        }
        return null;
    }
}
Also used : TableMetadata(org.apache.cassandra.schema.TableMetadata) MutationExceededMaxSizeException(org.apache.cassandra.db.MutationExceededMaxSizeException) ReadTimeoutException(org.apache.cassandra.exceptions.ReadTimeoutException) DecoratedKey(org.apache.cassandra.db.DecoratedKey) Keyspace(org.apache.cassandra.db.Keyspace) Mutation(org.apache.cassandra.db.Mutation)

Aggregations

DecoratedKey (org.apache.cassandra.db.DecoratedKey)1 Keyspace (org.apache.cassandra.db.Keyspace)1 Mutation (org.apache.cassandra.db.Mutation)1 MutationExceededMaxSizeException (org.apache.cassandra.db.MutationExceededMaxSizeException)1 ReadTimeoutException (org.apache.cassandra.exceptions.ReadTimeoutException)1 TableMetadata (org.apache.cassandra.schema.TableMetadata)1