Reputation: 10128
I am doing query to update time and bool flag but it not works at all? I have no idea what to do with this problem or how to handle. I spend hours with debugger but I see that it not works.
Query:
update task
set start_time = toTimestamp(now()), started = true
where id = d6283a7e-5b5c-11e7-98da-00059a3c7a00;
Field started
is sometimes True
or False
- but often False
- no idea why?
Full code:
@classmethod
def _db_start_task(cls, task_id, parent_task_id, farm_settings):
assert isinstance(task_id, uuid.UUID)
assert isinstance(farm_settings, FarmSettings)
logger = logging.getLogger(__name__)
session = cls._get_session(farm_settings)
query_string = '''\
update task
set start_time = toTimestamp(now()), started = true
where id = %(task_id)s;''' % {
'task_id': task_id
}
logger.debug('Query string is: %s.' % query_string)
update = SimpleStatement(query_string=query_string,
consistency_level=ConsistencyLevel.QUORUM,
serial_consistency_level=ConsistencyLevel.SERIAL)
warnings.warn('Statement execution problems is not handled.', UserWarning)
update_result = session.execute(update, trace=True)
warnings.warn('Debug code to remove start.', UserWarning)
select = SimpleStatement(query_string='select start_time, started from task where id = %(task_id)s'
% { 'task_id': task_id },
consistency_level=ConsistencyLevel.QUORUM,
serial_consistency_level=ConsistencyLevel.SERIAL)
result_set = session.execute(select)
if result_set[0].started == False:
logger.critical('Undefined behavior.')
warnings.warn('Debug code to remove end.', UserWarning)
if parent_task_id is not None:
cls._db_count_started_children_tasks(parent_task_id, farm_settings)
Upvotes: 0
Views: 27
Reputation: 7365
That is unexpected behavior with those consistency settings.
One possibility would be if you're encountering Unavailable errors, and your Cluster is configured using a DowngradingConsistencyRetryPolicy
or something like it.
Upvotes: 1