You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by krummas <gi...@git.apache.org> on 2018/06/01 11:01:58 UTC
[GitHub] cassandra pull request #228: Add option to sanity check tombstones on reads/...
Github user krummas commented on a diff in the pull request:
https://github.com/apache/cassandra/pull/228#discussion_r192363136
--- 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 --
looks like NoSpamLogger just passes the objects down to the underlying logger, and with slf4j the stack trace will be printed if there is an exception as the last item in that array: https://www.slf4j.org/faq.html#paramException
---
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org