【问题标题】:Strange Cassandra 3.9 behaviour no update on bool field in Python奇怪的 Cassandra 3.9 行为没有更新 Python 中的 bool 字段
【发布时间】:2017-11-30 20:47:54
【问题描述】:

我正在查询更新时间和布尔标志,但它根本不起作用?我不知道如何处理这个问题或如何处理。我花了几个小时在调试器上,但我发现它不起作用。

查询:

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)

【问题讨论】:

    标签: python cassandra datastax


    【解决方案1】:

    对于这些一致性设置,这是出乎意料的行为。

    如果您遇到 Unavailable 错误,并且您的集群是使用 DowngradingConsistencyRetryPolicy 或类似名称配置的,一种可能性是。

    【讨论】:

    • 需要检查一下。
    猜你喜欢
    • 2016-11-15
    • 1970-01-01
    • 2016-11-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多