Skip to content

Commit

Permalink
if isn't agreed cqlsh won't be returning failure
Browse files Browse the repository at this point in the history
So far if a query is executed during schema changes that takes
more then 5sec to be resolved, cqlsh would print a warning
and change the return status to failure.

if it's just a warning, we shouldn't be failure the command.
especily since after this warning we are waiting without a timeout
for schema to be resolved.

Fixes: #34
  • Loading branch information
fruch committed Oct 10, 2023
1 parent 426fa0e commit ffd28ae
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions bin/cqlsh.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def find_zip(libprefix):
from cqlshlib import cql3handling, pylexotron, sslhandling, cqlshhandling, authproviderhandling
from cqlshlib.copyutil import ExportTask, ImportTask
from cqlshlib.displaying import (ANSI_RESET, BLUE, COLUMN_NAME_COLORS, CYAN,
RED, WHITE, FormattedValue, colorme)
RED, YELLOW, WHITE, FormattedValue, colorme)
from cqlshlib.formatting import (DEFAULT_DATE_FORMAT, DEFAULT_NANOTIME_FORMAT,
DEFAULT_TIMESTAMP_FORMAT, CqlType, DateTimeFormat,
format_by_type)
Expand Down Expand Up @@ -1110,8 +1110,8 @@ def perform_simple_statement(self, statement):
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; check the schema versions of your "
"nodes in system.local and system.peers.")
self.printwarn("Warning: schema version mismatch detected; check the schema versions of your "
"nodes in system.local and system.peers.")
self.conn.refresh_schema_metadata(-1)

if result is None:
Expand Down Expand Up @@ -2290,6 +2290,13 @@ def printerr(self, text, color=RED, newline=True, shownum=None):
text = '%s:%d:%s' % (self.stdin.name, self.lineno, text)
self.writeresult(text, color, newline=newline, out=sys.stderr)

def printwarn(self, text, color=YELLOW, newline=True, shownum=None):
if shownum is None:
shownum = self.show_line_nums
if shownum:
text = '%s:%d:%s' % (self.stdin.name, self.lineno, text)
self.writeresult(text, color, newline=newline, out=sys.stderr)

def stop_coverage(self):
if self.coverage and self.cov is not None:
self.cov.stop()
Expand Down

0 comments on commit ffd28ae

Please sign in to comment.