我正在查询更新时间和bool标志,但它根本不起作用?我不知道如何处理这个问题或如何处理。我花了几个小时调试,但我发现它不起作用。
查询:
update task
set start_time = toTimestamp(now()), started = true
where id = d6283a7e-5b5c-11e7-98da-00059a3c7a00;
字段started
有时是True
或False
- 但通常是False
- 不明白为什么?
完整代码:
@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)
答案 0 :(得分:1)
这是使用这些一致性设置的意外行为。
如果您遇到不可用的错误,并且您的群集使用DowngradingConsistencyRetryPolicy
或类似的东西进行配置,则有一种可能性。