[Tarantool-patches] [PATCH 4/4] box/txn: fix nil dereference in txn_rollback

Konstantin Osipov kostja.osipov at gmail.com
Mon Feb 17 20:19:40 MSK 2020


* Cyrill Gorcunov <gorcunov at gmail.com> [20/02/17 20:08]:
> In case if we get failed in allocation of new
> journal entry the txn_rollback will try to
> derefernce nil pointer

This is lgtm (apart from typos in the comment), however, 
I think this patch is incomplete, since wal_write() still calls
rollback on failure to queue the task to cbus. 

Could you please remove txn_rollback() from wal_write in scope of
this series?

I mean this part: 

fail:
        entry->res = -1;
        journal_entry_complete(entry);
        return -1;
}

(remove jounral_entry_complete() from here).

I think once you remove journal_entry_complete (which basically
calls rollback), you will be able to remove this ugly
"cleanr-then-restore" of txn as well:


> +	/*
> +	 * Queue the entry for processing in journal
> +	 * engine. The semantics of complete_cb implies
> +	 * that fiber's txn (kept in storage) is nil
> +	 * becase WAL is a separet thread, for this
> +	 * sake we zap it here.
> +	 *
> +	 * Still this is messy since the caller runs
> +	 * txn_rollback if something bad happened. Thus
> +	 * restore the former txn on error path.
> +	 */
> +	fiber_set_txn(fiber(), NULL);
>  	if (journal_write(req) < 0) {
> +		fiber_set_txn(fiber(), txn);
>  		diag_set(ClientError, ER_WAL_IO);
>  		diag_log();
>  		return -1;

-- 
Konstantin Osipov, Moscow, Russia
https://scylladb.com


More information about the Tarantool-patches mailing list