Tarantool development patches archive
 help / color / mirror / Atom feed
From: Serge Petrenko via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: v.shpilevoy@tarantool.org, tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH v2 1/9] wal: enrich row's meta information with sync replication flags
Date: Tue, 13 Apr 2021 16:51:52 +0300	[thread overview]
Message-ID: <90b3cd45-b633-e7e1-8547-0e04aebcf522@tarantool.org> (raw)
In-Reply-To: <YHWFjFlTfbvAqVoi@grain>



13.04.2021 14:50, Cyrill Gorcunov пишет:
> On Mon, Apr 12, 2021 at 10:40:14PM +0300, Serge Petrenko wrote:
>> Introduce two new flags to xrow_header: `wait_ack` and `wait_sync`.
>> These flags are set for rows belonging to synchronous transactions in
>> addition to `is_commit`.
>>
>> The new flags help to define whether the rows belong to a synchronous
>> transaction or not without parsing them all and checking whether any of
>> the rows touches a synchronous space.
>>
>> This will be used in applier once it is taught to filter synchronous
>> transactions based on whether they are coming from a raft leader or not.
>>
>> P.S. These flags will also be useful once we allow to turn any transaction
>> synchronous. Once this is done, the flags in row header will be the only
>> source of information on whether the transaction is synchronous or not.
>>
>> Prerequisite #5445
> Serge, here is a one addition: lets verify bitfields order. While their
> use indeed is suitable we should eliminate ourself from unpredicted results.
> The test is for c++ and probably we need one for plain c compiler as well?

Thanks for the help! I've added your tests with some changes.
What do you think?

===========================
diff --git a/test/unit/xrow.cc b/test/unit/xrow.cc
index ea1ee1767..3d7d8bee1 100644
--- a/test/unit/xrow.cc
+++ b/test/unit/xrow.cc
@@ -297,12 +297,49 @@ test_request_str()
      check_plan();
  }

+/**
+ * The compiler doesn't have to preserve bitfields order,
+ * still we rely on it for convenience sake.
+ */
+static void
+test_xrow_opt_field()
+{
+    plan(6);
+
+    struct xrow_header header;
+
+    memset(&header, 0, sizeof(header));
+
+    header.is_commit = true;
+    is(header.opt_flags, IPROTO_FLAG_COMMIT, "header.is_commit -> COMMIT");
+    header.is_commit = false;
+
+    header.wait_sync = true;
+    is(header.opt_flags, IPROTO_FLAG_WAIT_SYNC, "header.wait_sync -> 
WAIT_SYNC");
+    header.wait_sync = false;
+
+    header.wait_ack = true;
+    is(header.opt_flags, IPROTO_FLAG_WAIT_ACK, "header.wait_ack -> 
WAIT_ACK");
+    header.wait_ack = false;
+
+    header.opt_flags = IPROTO_FLAG_COMMIT;
+    ok(header.is_commit && !header.wait_sync && !header.wait_ack, 
"COMMIT -> header.is_commit");
+
+    header.opt_flags = IPROTO_FLAG_WAIT_SYNC;
+    ok(!header.is_commit && header.wait_sync && !header.wait_ack, 
"WAIT_SYNC -> header.wait_sync");
+
+    header.opt_flags = IPROTO_FLAG_WAIT_ACK;
+    ok(!header.is_commit && !header.wait_sync && header.wait_ack, 
"WAIT_ACK -> header.wait_ack");
+
+    check_plan();
+}
+
  int
  main(void)
  {
      memory_init();
      fiber_init(fiber_c_invoke);
-    plan(3);
+    plan(4);

      random_init();

@@ -310,6 +347,7 @@ main(void)
      test_greeting();
      test_xrow_header_encode_decode();
      test_request_str();
+    test_xrow_opt_field();

      random_free();
      fiber_free();
diff --git a/test/unit/xrow.result b/test/unit/xrow.result
index e06ba5261..3b705d5ba 100644
--- a/test/unit/xrow.result
+++ b/test/unit/xrow.result
@@ -1,4 +1,4 @@
-1..3
+1..4
      1..40
      ok 1 - round trip
      ok 2 - roundtrip.version_id
@@ -159,3 +159,11 @@ ok 2 - subtests
      1..1
      ok 1 - request_str
  ok 3 - subtests
+    1..6
+    ok 1 - header.is_commit -> COMMIT
+    ok 2 - header.wait_sync -> WAIT_SYNC
+    ok 3 - header.wait_ack -> WAIT_ACK
+    ok 4 - COMMIT -> header.is_commit
+    ok 5 - WAIT_SYNC -> header.wait_sync
+    ok 6 - WAIT_ACK -> header.wait_ack
+ok 4 - subtests

-- 
Serge Petrenko


  reply	other threads:[~2021-04-13 13:51 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-12 19:40 [Tarantool-patches] [PATCH v2 0/9] raft: introduce manual elections and fix a bug with re-applying rolled back transactions Serge Petrenko via Tarantool-patches
2021-04-12 19:40 ` [Tarantool-patches] [PATCH v2 1/9] wal: enrich row's meta information with sync replication flags Serge Petrenko via Tarantool-patches
2021-04-13 11:50   ` Cyrill Gorcunov via Tarantool-patches
2021-04-13 13:51     ` Serge Petrenko via Tarantool-patches [this message]
2021-04-13 14:16       ` Cyrill Gorcunov via Tarantool-patches
2021-04-13 13:09   ` Cyrill Gorcunov via Tarantool-patches
2021-04-13 13:29     ` Serge Petrenko via Tarantool-patches
2021-04-12 19:40 ` [Tarantool-patches] [PATCH v2 2/9] xrow: introduce a PROMOTE entry Serge Petrenko via Tarantool-patches
2021-04-13 14:15   ` Cyrill Gorcunov via Tarantool-patches
2021-04-14  9:12     ` Serge Petrenko via Tarantool-patches
2021-04-14 10:00       ` Cyrill Gorcunov via Tarantool-patches
2021-04-12 19:40 ` [Tarantool-patches] [PATCH v2 3/9] box: actualise iproto_key_type array Serge Petrenko via Tarantool-patches
2021-04-12 19:40 ` [Tarantool-patches] [PATCH v2 4/9] box: make clear_synchro_queue() write a PROMOTE entry instead of CONFIRM + ROLLBACK Serge Petrenko via Tarantool-patches
2021-04-13 14:33   ` Cyrill Gorcunov via Tarantool-patches
2021-04-14  8:23     ` Serge Petrenko via Tarantool-patches
2021-04-14  8:34       ` Cyrill Gorcunov via Tarantool-patches
2021-04-14  9:12     ` Serge Petrenko via Tarantool-patches
2021-04-12 19:40 ` [Tarantool-patches] [PATCH v2 5/9] box: write PROMOTE even for empty limbo Serge Petrenko via Tarantool-patches
2021-04-12 19:40 ` [Tarantool-patches] [PATCH v2 6/9] raft: keep track of greatest known term and filter replication sources based on that Serge Petrenko via Tarantool-patches
2021-04-12 19:40 ` [Tarantool-patches] [PATCH v2 7/9] replication: introduce a new election mode: "manual" Serge Petrenko via Tarantool-patches
2021-04-12 19:40 ` [Tarantool-patches] [PATCH v2 8/9] Support manual elections in `box.ctl.clear_synchro_queue()` Serge Petrenko via Tarantool-patches
2021-04-12 19:40 ` [Tarantool-patches] [PATCH v2 9/9] box.ctl: rename clear_synchro_queue to promote Serge Petrenko via Tarantool-patches
2021-04-13 14:42 ` [Tarantool-patches] [PATCH v2 0/9] raft: introduce manual elections and fix a bug with re-applying rolled back transactions Cyrill Gorcunov via Tarantool-patches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=90b3cd45-b633-e7e1-8547-0e04aebcf522@tarantool.org \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=gorcunov@gmail.com \
    --cc=sergepetrenko@tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v2 1/9] wal: enrich row'\''s meta information with sync replication flags' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox