[Tarantool-patches] [PATCH 9/9] box: enrich ER_READONLY with new details

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Sun Nov 7 19:45:04 MSK 2021


On 06.11.2021 20:30, Cyrill Gorcunov via Tarantool-patches wrote:
> On Sat, Nov 06, 2021 at 12:56:40AM +0100, Vladislav Shpilevoy via Tarantool-patches wrote:
>> +	if (raft_is_ro(raft)) {
>> +		error_field_set_str(e, "reason", "election");
>> +		error_field_set_str(e, "state", raft_state_str(raft->state));
>> +		error_field_set_uint(e, "term", raft->volatile_term);
>> +		uint32_t id = raft->leader;
>> +		if (id != REPLICA_ID_NIL) {
>> +			error_field_set_uint(e, "leader_id", id);
>> +			struct replica *r = replica_by_id(id);
> 
> Why do we need an additional variable here instead of raft->leader?
> To shrink code left?
> 
>> +	} else if (txn_limbo_is_ro(&txn_limbo)) {
>> +		error_field_set_str(e, "reason", "synchro");
>> +		uint32_t id = txn_limbo.owner_id;
>> +		error_field_set_uint(e, "queue_owner_id", id);
>> +		error_field_set_uint(e, "term", raft->volatile_term);
>> +		struct replica *r = replica_by_id(id);
> 
> And here too. Just wondering.

I like to avoid '->' when it is used for the same member
more than once.

Also it shrinks the code a bit, yes.


More information about the Tarantool-patches mailing list