cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ble...@apache.org
Subject [1/3] cassandra git commit: Make cqlsh handle CREATE KEYSPACE timeouts properly
Date Fri, 04 Sep 2015 19:36:12 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.2 25373e994 -> 464ca14aa


Make cqlsh handle CREATE KEYSPACE timeouts properly

patch by Paulo Motta; reviewed by Benjamin Lerer for CASSANDRA-9689


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

Branch: refs/heads/cassandra-2.2
Commit: acdbdc28c4fc449219422a84b10df779e740baef
Parents: 5ec0204
Author: Paulo Motta <pauloricardomg@gmail.com>
Authored: Fri Sep 4 21:28:25 2015 +0200
Committer: blerer <benjamin.lerer@datastax.com>
Committed: Fri Sep 4 21:28:25 2015 +0200

----------------------------------------------------------------------
 bin/cqlsh | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/acdbdc28/bin/cqlsh
----------------------------------------------------------------------
diff --git a/bin/cqlsh b/bin/cqlsh
index 084d586..59496ce 100755
--- a/bin/cqlsh
+++ b/bin/cqlsh
@@ -634,20 +634,9 @@ class Shell(cmd.Cmd):
         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 there is no schema metadata present (due to a schema mismatch), force schema
refresh
         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.refresh_schema_metadata_best_effort()
 
         self.session.default_timeout = client_timeout
         self.session.row_factory = ordered_dict_factory
@@ -690,6 +679,15 @@ class Shell(cmd.Cmd):
         self.statement_error = False
         self.single_statement = single_statement
 
+    def refresh_schema_metadata_best_effort(self):
+        try:
+            self.conn.refresh_schema_metadata(5) #will throw exception if there is a schema
mismatch
+        except Exception:
+            self.printerr("Warning: schema version mismatch detected, which might be caused
by DOWN nodes; if "
+                          "this is not the case, check the schema versions of your nodes
in system.local and "
+                          "system.peers.")
+            self.conn.refresh_schema_metadata(0)
+
     def set_expanded_cql_version(self, ver):
         ver, vertuple = full_cql_version(ver)
         self.cql_version = ver
@@ -1092,6 +1090,10 @@ class Shell(cmd.Cmd):
             try:
                 rows = self.session.execute(statement, trace=self.tracing_enabled)
                 break
+            except cassandra.OperationTimedOut, err:
+                self.refresh_schema_metadata_best_effort()
+                self.printerr(str(err.__class__.__name__) + ": " + str(err))
+                return False
             except CQL_ERRORS, err:
                 self.printerr(str(err.__class__.__name__) + ": " + str(err))
                 return False


Mime
View raw message