奇怪的Cassandra 3.9行为Python中的bool字段没有更新

2024-06-26 05:19:30 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在查询更新时间和bool标志,但它根本不起作用?我不知道该怎么处理这个问题,也不知道该如何处理。我花了数小时使用调试器,但我发现它不起作用

查询:

update task
set start_time = toTimestamp(now()), started = true
where id = d6283a7e-5b5c-11e7-98da-00059a3c7a00;

字段started有时是TrueFalse-但通常是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)

Tags: idtaskstringsettingstimesessionupdatequery