Return-Path: X-Original-To: apmail-cassandra-commits-archive@www.apache.org Delivered-To: apmail-cassandra-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 57E3E176D9 for ; Fri, 4 Sep 2015 19:33:01 +0000 (UTC) Received: (qmail 57767 invoked by uid 500); 4 Sep 2015 19:33:01 -0000 Delivered-To: apmail-cassandra-commits-archive@cassandra.apache.org Received: (qmail 57731 invoked by uid 500); 4 Sep 2015 19:33:01 -0000 Mailing-List: contact commits-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list commits@cassandra.apache.org Received: (qmail 57709 invoked by uid 99); 4 Sep 2015 19:33:01 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Sep 2015 19:33:01 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id E9C7BDFF6B; Fri, 4 Sep 2015 19:33:00 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: blerer@apache.org To: commits@cassandra.apache.org Message-Id: <86961cf8fcfa4c459f37a1ec41e43ed2@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: cassandra git commit: Make cqlsh handle CREATE KEYSPACE timeouts properly Date: Fri, 4 Sep 2015 19:33:00 +0000 (UTC) Repository: cassandra Updated Branches: refs/heads/cassandra-2.1 5ec020490 -> acdbdc28c 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.1 Commit: acdbdc28c4fc449219422a84b10df779e740baef Parents: 5ec0204 Author: Paulo Motta Authored: Fri Sep 4 21:28:25 2015 +0200 Committer: blerer 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