From ed623da76d08da4921db6f37d48ce28eecb033df Mon Sep 17 00:00:00 2001 From: Gary Dusbabek Date: Thu, 1 Jul 2010 16:51:37 +0000 Subject: [PATCH] handle schema loading when a node has had all keyspaces dropped. Patch by gdusbabek, reviewed by jbellis. CASSANDRA-1203. git-svn-id: https://svn.apache.org/repos/asf/cassandra/trunk@959722 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/cassandra/config/DatabaseDescriptor.java | 9 ++++++++- src/java/org/apache/cassandra/db/DefsTable.java | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java index ba70d712d3..1a4a4c21d4 100644 --- a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java +++ b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java @@ -438,8 +438,15 @@ public class DatabaseDescriptor Table.open(def.name); } - // since we loaded definitions from local storage, log a warning if definitions exist in yaml. + // happens when someone manually deletes all tables and restarts. + if (tableDefs.size() == 0) + { + logger.warn("No schema definitions were found in local storage."); + // set defsVersion so that migrations leading up to emptiness aren't replayed. + defsVersion = uuid; + } + // since we loaded definitions from local storage, log a warning if definitions exist in yaml. if (conf.keyspaces != null && conf.keyspaces.size() > 0) logger.warn("Schema definitions were defined both locally and in " + STORAGE_CONF_FILE + ". Definitions in " + STORAGE_CONF_FILE + " were ignored."); diff --git a/src/java/org/apache/cassandra/db/DefsTable.java b/src/java/org/apache/cassandra/db/DefsTable.java index bd649c05ec..1360ff30ca 100644 --- a/src/java/org/apache/cassandra/db/DefsTable.java +++ b/src/java/org/apache/cassandra/db/DefsTable.java @@ -72,6 +72,9 @@ public class DefsTable Collection tables = new ArrayList(); for (IColumn col : cf.getSortedColumns()) { + // don't allow deleted columns. + if (col instanceof DeletedColumn) + continue; KSMetaData ks = KSMetaData.deserialize(new ByteArrayInputStream(col.value())); tables.add(ks); }