cqlsh: handle schema mismatch on startup

Patch by Tyler Hobbs; reviewed by Aleksey Yeschenko for CASSANDRA-8512
This commit is contained in:
Tyler Hobbs 2015-01-02 12:14:24 -06:00
parent 4e1e92b310
commit aeb7d3f2ee
2 changed files with 22 additions and 4 deletions

View File

@ -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)

View File

@ -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