[Tarantool-patches] [PATCH v2 4/9] box: make clear_synchro_queue() write a PROMOTE entry instead of CONFIRM + ROLLBACK

Serge Petrenko sergepetrenko at tarantool.org
Wed Apr 14 12:12:54 MSK 2021



13.04.2021 17:33, Cyrill Gorcunov пишет:
> On Mon, Apr 12, 2021 at 10:40:17PM +0300, Serge Petrenko wrote:
>>   		} 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 */
>> +			};
> Is there some particular meaning of zeroifying designated assignments?
> I mean why not simply
>
> 			struct synchro_request req = {
> 				.origin_id	= instance_id,
> 				.lsn		= wait_lsn,
> 			};
>
> or you wanted to pay attention that the left of the fields are
> unused? Just curious, I'm fine with current code.

A diff as per changes requested in patch 2.


======================================================

diff --git a/src/box/applier.cc b/src/box/applier.cc
index e8cbbe27a..65a749b62 100644
--- a/src/box/applier.cc
+++ b/src/box/applier.cc
@@ -822,12 +822,15 @@ synchro_entry_new(struct xrow_header *applier_row,
         }

         struct journal_entry *journal_entry = &entry->journal_entry;
-       struct synchro_body_bin *body_bin = &entry->body_bin.base;
         struct xrow_header *row = &entry->row;

         journal_entry->rows[0] = row;

-       xrow_encode_synchro(row, body_bin, req);
+       assert(iproto_type_is_synchro_request(req->type));
+       if (iproto_type_is_promote_request(req->type))
+               xrow_encode_promote(row, &entry->body_bin, req);
+       else
+               xrow_encode_synchro(row, &entry->body_bin.base, req);

         row->lsn = applier_row->lsn;
         row->replica_id = applier_row->replica_id;
diff --git a/src/box/txn_limbo.c b/src/box/txn_limbo.c
index f119c35b6..36c233348 100644
--- a/src/box/txn_limbo.c
+++ b/src/box/txn_limbo.c
@@ -333,8 +333,7 @@ txn_limbo_write_synchro(struct txn_limbo *limbo, 
uint32_t type, int64_t lsn,
          * This is a synchronous commit so we can allocate everything on a
          * stack. Promote body includes synchro body.
          */
-       struct promote_body_bin body;
-       struct synchro_body_bin *base = &body.base;
+       struct promote_body_bin body_bin;

         struct xrow_header row;
         char buf[sizeof(struct journal_entry) +
@@ -343,7 +342,10 @@ txn_limbo_write_synchro(struct txn_limbo *limbo, 
uint32_t type, int64_t lsn,
         struct journal_entry *entry = (struct journal_entry *)buf;
         entry->rows[0] = &row;

-       xrow_encode_synchro(&row, base, &req);
+       if (type == IPROTO_PROMOTE)
+               xrow_encode_promote(&row, &body_bin, &req);
+       else
+               xrow_encode_synchro(&row, &body_bin.base, &req);

         journal_entry_create(entry, 1, xrow_approx_len(&row),
                              txn_limbo_write_cb, fiber());


-- 
Serge Petrenko



More information about the Tarantool-patches mailing list