cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tylerho...@apache.org
Subject [1/2] cassandra git commit: cqlsh: handle schema mismatch on startup
Date Fri, 02 Jan 2015 18:15:21 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 0ba9c4775 -> 1dcf66b09


cqlsh: handle schema mismatch on startup

Patch by Tyler Hobbs; reviewed by Aleksey Yeschenko for CASSANDRA-8512


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/aeb7d3f2
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/aeb7d3f2
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/aeb7d3f2

Branch: refs/heads/trunk
Commit: aeb7d3f2eefcd5aa452012c048341deb814cf0b0
Parents: 4e1e92b
Author: Tyler Hobbs <tyler@datastax.com>
Authored: Fri Jan 2 12:14:24 2015 -0600
Committer: Tyler Hobbs <tyler@datastax.com>
Committed: Fri Jan 2 12:14:24 2015 -0600

----------------------------------------------------------------------
 CHANGES.txt |  1 +
 bin/cqlsh   | 25 +++++++++++++++++++++----
 2 files changed, 22 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/aeb7d3f2/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index c222224..1c1bfe2 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.1.3
+ * (cqlsh) Handle a schema mismatch being detected on startup (CASSANDRA-8512)
  * Properly calculate expected write size during compaction (CASSANDRA-8532)
  * Invalidate affected prepared statements when a table's columns
    are altered (CASSANDRA-7910)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/aeb7d3f2/bin/cqlsh
----------------------------------------------------------------------
diff --git a/bin/cqlsh b/bin/cqlsh
index a714f48..363a4f6 100755
--- a/bin/cqlsh
+++ b/bin/cqlsh
@@ -562,15 +562,32 @@ class Shell(cmd.Cmd):
             self.session = self.conn.connect(keyspace)
         else:
             self.session = self.conn.connect()
+
+        self.color = color
+        self.display_time_format = display_time_format
+        self.display_float_precision = display_float_precision
+
+        # Workaround for CASSANDRA-8521 until PYTHON-205 is resolved.
+        # If there is no schema metadata present (due to a schema mismatch),
+        # get rid of the code that checks for a schema mismatch and force
+        # the schema metadata to be built.
+        if not self.conn.metadata.keyspaces:
+            self.printerr("Warning: schema version mismatch detected; check the schema versions
of your "
+                          "nodes in system.local and system.peers.")
+            original_method = self.conn.control_connection._get_schema_mismatches
+            try:
+                self.conn.control_connection._get_schema_mismatches = lambda *args, **kwargs:
None
+                future = self.conn.submit_schema_refresh()
+                future.result(timeout=10)
+            finally:
+                self.conn.control_connection._get_schema_mismatches = original_method
+
         self.session.default_timeout = client_timeout
         self.session.row_factory = ordered_dict_factory
         self.get_connection_versions()
 
         self.current_keyspace = keyspace
 
-        self.color = color
-        self.display_time_format = display_time_format
-        self.display_float_precision = display_float_precision
         self.max_trace_wait = max_trace_wait
         self.session.max_trace_wait = max_trace_wait
         if encoding is None:
@@ -980,7 +997,7 @@ class Shell(cmd.Cmd):
                 rows = self.session.execute(statement, trace=self.tracing_enabled)
                 break
             except CQL_ERRORS, err:
-                self.printerr(str(err))
+                self.printerr(str(err.__class__.__name__) + ": " + str(err))
                 return False
             except Exception, err:
                 import traceback


Mime
View raw message