relax path length requirement for sstable files when upgrading on non-Windows platforms patch by jbellis; reviewed by slebresne for CASSANDRA-4110
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/e9917c47 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/e9917c47 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/e9917c47 Branch: refs/heads/cassandra-1.1.0 Commit: e9917c4794d9647792239efe24d4846f8163ab1e Parents: 83371eb Author: Jonathan Ellis <[email protected]> Authored: Tue Apr 3 11:13:44 2012 -0500 Committer: Jonathan Ellis <[email protected]> Committed: Tue Apr 3 11:13:44 2012 -0500 ---------------------------------------------------------------------- CHANGES.txt | 5 +++- src/java/org/apache/cassandra/db/Directories.java | 20 +++++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/e9917c47/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 7fceeee..4af75a3 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -4,7 +4,10 @@ * fix KEYS index from skipping results (CASSANDRA-3996) * Remove sliced_buffer_size_in_kb dead option (CASSANDRA-4076) * make loadNewSStable preserve sstable version (CASSANDRA-4077) - * Respect 1.0 cache settings as much as possible when upgrading (CASSANDRA-4088) + * Respect 1.0 cache settings as much as possible when upgrading + (CASSANDRA-4088) + * relax path length requirement for sstable files when upgrading on + non-Windows platforms (CASSANDRA-4110) 1.1-beta2 http://git-wip-us.apache.org/repos/asf/cassandra/blob/e9917c47/src/java/org/apache/cassandra/db/Directories.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/db/Directories.java b/src/java/org/apache/cassandra/db/Directories.java index d2c98c8..1441fd2 100644 --- a/src/java/org/apache/cassandra/db/Directories.java +++ b/src/java/org/apache/cassandra/db/Directories.java @@ -416,7 +416,7 @@ public class Directories // This is a brand new node. return false; - // Check whether the migration migth create too long a filename + // Check whether the migration might create too long a filename int longestLocation = -1; try { @@ -428,18 +428,32 @@ public class Directories throw new IOError(e); } + // Check that migration won't error out halfway through from too-long paths. For Windows, we need to check + // total path length <= 255 (see http://msdn.microsoft.com/en-us/library/aa365247.aspx and discussion on CASSANDRA-2749); + // elsewhere, we just need to make sure filename is <= 255. for (KSMetaData ksm : Schema.instance.getTableDefinitions()) { String ksname = ksm.name; for (Map.Entry<String, CFMetaData> entry : ksm.cfMetaData().entrySet()) { String cfname = entry.getKey(); - // max path is roughly (guess-estimate) <location>/ksname/cfname/snapshots/1324314347102-somename/ksname-cfname-tmp-hb-1024-Statistics.db - if (longestLocation + (ksname.length() + cfname.length()) * 2 + 62 > 256) + + // max path is roughly (guess-estimate) <location>/ksname/cfname/snapshots/1324314347102-somename/ksname-cfname-tmp-hb-65536-Statistics.db + if (System.getProperty("os.name").startsWith("Windows") + && longestLocation + (ksname.length() + cfname.length()) * 2 + 63 > 255) + { throw new RuntimeException("Starting with 1.1, keyspace names and column family names must be less than 32 characters long. " + ksname + "/" + cfname + " doesn't respect that restriction. Please rename your keyspace/column families to respect that restriction before updating."); + } + + if (ksm.name.length() + cfname.length() + 28 > 255) + { + throw new RuntimeException("Starting with 1.1, the keyspace name is included in data filenames. For " + + ksm.name + "/" + cfname + ", this puts you over the largest possible filename of 255 characters"); + } } } + return true; }
