cassandra-pr mailing list archives

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

    https://github.com/apache/cassandra/pull/228#discussion_r192011336
  
    --- Diff: src/java/org/apache/cassandra/db/UnfilteredValidation.java ---
    @@ -0,0 +1,60 @@
    +/*
    + * 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.schema.TableMetadata;
    +import org.apache.cassandra.serializers.MarshalException;
    +import org.apache.cassandra.utils.NoSpamLogger;
    +
    +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, String filename)
    +    {
    +        Config.CorruptedTombstoneStrategy strat = DatabaseDescriptor.getCorruptedTombstoneStrategy();
    +        if (strat != Config.CorruptedTombstoneStrategy.disabled && unfiltered
!= null && !unfiltered.isEmpty() && unfiltered.hasInvalidDeletions())
    +            handleInvalid(metadata, key, filename, unfiltered.toString(metadata, true));
    +    }
    +
    +    public static void handleInvalid(TableMetadata metadata, DecoratedKey key, String
filename, String invalidContent)
    +    {
    +        Config.CorruptedTombstoneStrategy strat = DatabaseDescriptor.getCorruptedTombstoneStrategy();
    +        String msg = String.format("Key %s in %s.%s is invalid in %s: %s",
    +                                   metadata.partitionKeyType.getString(key.getKey()),
    +                                   metadata.keyspace,
    +                                   metadata.name,
    +                                   filename,
    +                                   invalidContent);
    +        if (strat == Config.CorruptedTombstoneStrategy.exception)
    +            throw new MarshalException(msg);
    +        else if (strat == Config.CorruptedTombstoneStrategy.warn)
    +            nospam1m.warn(msg);
    --- End diff --
    
    My thinking here was that if the operator consider these to be errors, they would enable
exceptions, if not they just think they are warnings and then the log level should be warn,
I have no strong feelings about this though


---

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


Mime
View raw message