cassandra-pr mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aweisberg <...@git.apache.org>
Subject [GitHub] cassandra pull request #228: Add option to sanity check tombstones on reads/...
Date Thu, 31 May 2018 15:52:48 GMT
Github user aweisberg commented on a diff in the pull request:

    https://github.com/apache/cassandra/pull/228#discussion_r192148593
  
    --- Diff: src/java/org/apache/cassandra/db/UnfilteredValidation.java ---
    @@ -0,0 +1,109 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.cassandra.db;
    +
    +import java.util.concurrent.TimeUnit;
    +
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import org.apache.cassandra.config.Config;
    +import org.apache.cassandra.config.DatabaseDescriptor;
    +import org.apache.cassandra.db.rows.Unfiltered;
    +
    +import org.apache.cassandra.io.sstable.CorruptSSTableException;
    +import org.apache.cassandra.io.sstable.format.SSTableReader;
    +import org.apache.cassandra.schema.TableMetadata;
    +import org.apache.cassandra.serializers.MarshalException;
    +import org.apache.cassandra.utils.NoSpamLogger;
    +
    +
    +/**
    + * Handles unfiltered validation - if configured, it checks if the provided unfiltered
has
    + * invalid deletions (if the local deletion time is negative or if the ttl is negative)
and
    + * then either logs or throws an exception if so.
    + */
    +public class UnfilteredValidation
    +{
    +    private static final Logger logger = LoggerFactory.getLogger(UnfilteredValidation.class);
    +    private static final NoSpamLogger nospam1m = NoSpamLogger.getLogger(logger, 1, TimeUnit.MINUTES);
    +
    +    public static void maybeValidateUnfiltered(Unfiltered unfiltered, TableMetadata metadata,
DecoratedKey key, SSTableReader sstable)
    +    {
    +        Config.CorruptedTombstoneStrategy strat = DatabaseDescriptor.getCorruptedTombstoneStrategy();
    +        if (strat != Config.CorruptedTombstoneStrategy.disabled && unfiltered
!= null && !unfiltered.isEmpty())
    +        {
    +            boolean hasInvalidDeletions = false;
    +            try
    +            {
    +                hasInvalidDeletions = unfiltered.hasInvalidDeletions();
    +            }
    +            catch (Throwable t) // make sure no unknown exceptions fail the read/compaction
    +            {
    +                nospam1m.error("Could not check if Unfiltered in {} had any invalid deletions",
sstable, t);
    --- End diff --
    
    The exception at the end won't get formatted in. NoSpamLogger only supports the varargs
signature and it can't tell if you have an exception at the end.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


Mime
View raw message