[Tarantool-patches] [PATCH 13/16] tx: introduce txm_story

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Thu Jul 16 01:02:05 MSK 2020


>>> +}
>>> +
>>> +static struct txm_story *
>>> +txm_story_new_add_stmt(struct tuple *tuple, struct txn_stmt *stmt)
>> 2. Probably would be better to use the existing terms: old_tuple and new_tuple.
>> So the functions would be txm_story_add_new_stmt and txm_story_add_old_stmt. The
>> same in all the other places. 'add_stmt' -> 'new_stmt'. 'del_stmt' -> 'old_stmt'.
> I thought about it. I fear in terms of txm_story, when we speak about
> lifetime of a tuple it would be weird. add_stmt - is the statement that
> added the tuple. But what is new_stmt? new_psn?

Ok, lets leave it as is.

>>
>>> +{
>>> +    struct txm_story *res = txm_story_new(tuple, stmt->space->index_count);
>>> +    if (res == NULL)
>>> +        return NULL;
>>> +    res->add_stmt = stmt;
>>> +    assert(stmt->add_story == NULL);
>>> +    stmt->add_story = res;
>>> +    return res;
>>> +}
>>> +
>>> +static struct txm_story *
>>> +txm_story_new_del_stmt(struct tuple *tuple, struct txn_stmt *stmt)
>>> +{
>>> +    struct txm_story *res = txm_story_new(tuple, stmt->space->index_count);
>>> +    if (res == NULL)
>>> +        return NULL;
>>> +    res->del_stmt = stmt;
>>> +    assert(stmt->del_story == NULL);
>>> +    stmt->del_story = res;
>>> +    return res;
>>> +}
>>> +
>>> +void
>>> +txm_history_prepare_stmt(struct txn_stmt *stmt)
>>> +{
>>> +    assert(stmt->txn->psn != 0);
>>> +
>>> +    /* Move story to the past to prepared stories. */
>>> +
>>> +    struct txm_story *story = stmt->add_story;
>>> +    uint32_t index_count = story == NULL ? 0 : story->index_count;
>>> +    for (uint32_t i = 0; i < index_count; ) {
>>> ...
>>> ...
>>> ...
>>> +    }
>>> +    if (stmt->add_story != NULL)
>> 3. According to a check in the beginning of the function stmt can
>> be NULL. But then this will crash.
> No, index_count is initialized as 0 in that case and we will not enter the loop.

This check is out of the loop. So you will stumble into it.


More information about the Tarantool-patches mailing list