[Tarantool-patches] [PATCH v3 04/10] box: make clear_synchro_queue() write a PROMOTE entry instead of CONFIRM + ROLLBACK

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Fri Apr 16 02:20:17 MSK 2021


Thanks for working on this!

See 2 comments below.

> diff --git a/src/box/box.cc b/src/box/box.cc
> index 70b325180..9adb6ba46 100644
> --- a/src/box/box.cc
> +++ b/src/box/box.cc
> @@ -1556,7 +1556,19 @@ box_clear_synchro_queue(bool try_wait)
>  				 "new synchronous transactions appeared");
>  			rc = -1;
>  		} else {
> -			txn_limbo_force_empty(&txn_limbo, wait_lsn);
> +			/*
> +			 * Term parameter is unused now, We'll pass
> +			 * box_raft()->term there later.
> +			 */
> +			txn_limbo_write_promote(&txn_limbo, wait_lsn, 0);
> +			struct synchro_request req = {
> +				.type = 0, /* unused */
> +				.replica_id = 0, /* unused */
> +				.origin_id = instance_id,
> +				.lsn = wait_lsn,
> +				.term = 0, /* unused */

1. Aren't the unused fields nullified anyway according to
the standard?

> +			};
> +			txn_limbo_read_promote(&txn_limbo, &req);
>  			assert(txn_limbo_is_empty(&txn_limbo));
>  		}
>  	}
> diff --git a/src/box/txn_limbo.c b/src/box/txn_limbo.c
> index d29722ef7..bfe0ad302 100644
> --- a/src/box/txn_limbo.c
> +++ b/src/box/txn_limbo.c
> @@ -464,6 +470,32 @@ txn_limbo_read_rollback(struct txn_limbo *limbo, int64_t lsn)
>  		box_update_ro_summary();
>  }
>  
> +void
> +txn_limbo_write_promote(struct txn_limbo *limbo, int64_t lsn, uint64_t term)
> +{
> +	limbo->confirmed_lsn = lsn;
> +	/*
> +	 * We make sure that promote is only written once everything this
> +	 * instance has may be confirmed.
> +	 */
> +	struct txn_limbo_entry *e = txn_limbo_last_synchro_entry(limbo);
> +	assert(e == NULL || e->lsn <= lsn);
> +	(void) e;
> +	txn_limbo_write_synchro(limbo, IPROTO_PROMOTE, lsn, term);
> +	limbo->is_in_rollback = false;

2. How is it possible that there was a rollback in progress at
the same time?


More information about the Tarantool-patches mailing list