Tarantool development patches archive
 help / color / mirror / Atom feed
From: Serge Petrenko via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: v.shpilevoy@tarantool.org, gorcunov@gmail.com
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH 1/9] wal: enrich row's meta information with sync replication flags
Date: Mon, 12 Apr 2021 22:21:29 +0300	[thread overview]
Message-ID: <0a7cc1ab-35e8-172d-ed42-02ffe535d2b5@tarantool.org> (raw)
In-Reply-To: <69fd9b54dcaf92116e08d3319a66c080ad578cea.1618163409.git.sergepetrenko@tarantool.org>



11.04.2021 20:55, Serge Petrenko пишет:
> 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

Force-pushed a test:


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


diff --git a/test/unit/xrow.cc b/test/unit/xrow.cc
index 9fd154719..ea1ee1767 100644
--- a/test/unit/xrow.cc
+++ b/test/unit/xrow.cc
@@ -204,7 +204,9 @@ test_greeting()
  void
  test_xrow_header_encode_decode()
  {
-    plan(10);
+    /* Test all possible 3-bit combinations. */
+    const int bit_comb_count = 1 << 3;
+    plan(1 + bit_comb_count);
      struct xrow_header header;
      char buffer[2048];
      char *pos = mp_encode_uint(buffer, 300);
@@ -217,27 +219,47 @@ test_xrow_header_encode_decode()
      header.tm = 123.456;
      header.bodycnt = 0;
      header.tsn = header.lsn;
-    header.is_commit = true;
      uint64_t sync = 100500;
-    struct iovec vec[1];
-    is(1, xrow_header_encode(&header, sync, vec, 200), "encode");
-    int fixheader_len = 200;
-    pos = (char *)vec[0].iov_base + fixheader_len;
-    is(mp_decode_map((const char **)&pos), 5, "header map size");
-
-    struct xrow_header decoded_header;
-    const char *begin = (const char *)vec[0].iov_base;
-    begin += fixheader_len;
-    const char *end = (const char *)vec[0].iov_base;
-    end += vec[0].iov_len;
-    is(xrow_header_decode(&decoded_header, &begin, end, true), 0,
-       "header decode");
-    is(header.type, decoded_header.type, "decoded type");
-    is(header.replica_id, decoded_header.replica_id, "decoded replica_id");
-    is(header.lsn, decoded_header.lsn, "decoded lsn");
-    is(header.tm, decoded_header.tm, "decoded tm");
-    is(decoded_header.sync, sync, "decoded sync");
-    is(decoded_header.bodycnt, 0, "decoded bodycnt");
+    for (int opt_idx = 0; opt_idx < bit_comb_count; opt_idx++) {
+        plan(12);
+        header.is_commit = opt_idx & 0x01;
+        header.wait_sync = opt_idx >> 1 & 0x01;
+        header.wait_ack = opt_idx >> 2 & 0x01;
+        struct iovec vec[1];
+        is(1, xrow_header_encode(&header, sync, vec, 200), "encode");
+        int fixheader_len = 200;
+        pos = (char *)vec[0].iov_base + fixheader_len;
+        uint32_t exp_map_size = 5;
+        /*
+         * header.is_commit flag isn't encoded, since this row looks
+         * like a single-statement transaction.
+         */
+        if (header.wait_sync || header.wait_ack)
+            exp_map_size += 1;
+        /* tsn is encoded explicitly in this case. */
+        if (!header.is_commit)
+            exp_map_size += 1;
+        uint32_t size = mp_decode_map((const char **)&pos);
+        is(size, exp_map_size, "header map size");
+
+        struct xrow_header decoded_header;
+        const char *begin = (const char *)vec[0].iov_base;
+        begin += fixheader_len;
+        const char *end = (const char *)vec[0].iov_base;
+        end += vec[0].iov_len;
+        is(xrow_header_decode(&decoded_header, &begin, end, true), 0,
+           "header decode");
+        is(header.is_commit, decoded_header.is_commit, "decoded 
is_commit");
+        is(header.wait_sync, decoded_header.wait_sync, "decoded 
wait_sync");
+        is(header.wait_ack, decoded_header.wait_ack, "decoded wait_ack");
+        is(header.type, decoded_header.type, "decoded type");
+        is(header.replica_id, decoded_header.replica_id, "decoded 
replica_id");
+        is(header.lsn, decoded_header.lsn, "decoded lsn");
+        is(header.tm, decoded_header.tm, "decoded tm");
+        is(decoded_header.sync, sync, "decoded sync");
+        is(decoded_header.bodycnt, 0, "decoded bodycnt");
+        check_plan();
+    }

      check_plan();
  }
diff --git a/test/unit/xrow.result b/test/unit/xrow.result
index 5ee92ad7b..e06ba5261 100644
--- a/test/unit/xrow.result
+++ b/test/unit/xrow.result
@@ -41,17 +41,120 @@
      ok 39 - invalid 10
      ok 40 - invalid 11
  ok 1 - subtests
-    1..10
+    1..9
      ok 1 - bad msgpack end
-    ok 2 - encode
-    ok 3 - header map size
-    ok 4 - header decode
-    ok 5 - decoded type
-    ok 6 - decoded replica_id
-    ok 7 - decoded lsn
-    ok 8 - decoded tm
-    ok 9 - decoded sync
-    ok 10 - decoded bodycnt
+        1..12
+        ok 1 - encode
+        ok 2 - header map size
+        ok 3 - header decode
+        ok 4 - decoded is_commit
+        ok 5 - decoded wait_sync
+        ok 6 - decoded wait_ack
+        ok 7 - decoded type
+        ok 8 - decoded replica_id
+        ok 9 - decoded lsn
+        ok 10 - decoded tm
+        ok 11 - decoded sync
+        ok 12 - decoded bodycnt
+    ok 2 - subtests
+        1..12
+        ok 1 - encode
+        ok 2 - header map size
+        ok 3 - header decode
+        ok 4 - decoded is_commit
+        ok 5 - decoded wait_sync
+        ok 6 - decoded wait_ack
+        ok 7 - decoded type
+        ok 8 - decoded replica_id
+        ok 9 - decoded lsn
+        ok 10 - decoded tm
+        ok 11 - decoded sync
+        ok 12 - decoded bodycnt
+    ok 3 - subtests
+        1..12
+        ok 1 - encode
+        ok 2 - header map size
+        ok 3 - header decode
+        ok 4 - decoded is_commit
+        ok 5 - decoded wait_sync
+        ok 6 - decoded wait_ack
+        ok 7 - decoded type
+        ok 8 - decoded replica_id
+        ok 9 - decoded lsn
+        ok 10 - decoded tm
+        ok 11 - decoded sync
+        ok 12 - decoded bodycnt
+    ok 4 - subtests
+        1..12
+        ok 1 - encode
+        ok 2 - header map size
+        ok 3 - header decode
+        ok 4 - decoded is_commit
+        ok 5 - decoded wait_sync
+        ok 6 - decoded wait_ack
+        ok 7 - decoded type
+        ok 8 - decoded replica_id
+        ok 9 - decoded lsn
+        ok 10 - decoded tm
+        ok 11 - decoded sync
+        ok 12 - decoded bodycnt
+    ok 5 - subtests
+        1..12
+        ok 1 - encode
+        ok 2 - header map size
+        ok 3 - header decode
+        ok 4 - decoded is_commit
+        ok 5 - decoded wait_sync
+        ok 6 - decoded wait_ack
+        ok 7 - decoded type
+        ok 8 - decoded replica_id
+        ok 9 - decoded lsn
+        ok 10 - decoded tm
+        ok 11 - decoded sync
+        ok 12 - decoded bodycnt
+    ok 6 - subtests
+        1..12
+        ok 1 - encode
+        ok 2 - header map size
+        ok 3 - header decode
+        ok 4 - decoded is_commit
+        ok 5 - decoded wait_sync
+        ok 6 - decoded wait_ack
+        ok 7 - decoded type
+        ok 8 - decoded replica_id
+        ok 9 - decoded lsn
+        ok 10 - decoded tm
+        ok 11 - decoded sync
+        ok 12 - decoded bodycnt
+    ok 7 - subtests
+        1..12
+        ok 1 - encode
+        ok 2 - header map size
+        ok 3 - header decode
+        ok 4 - decoded is_commit
+        ok 5 - decoded wait_sync
+        ok 6 - decoded wait_ack
+        ok 7 - decoded type
+        ok 8 - decoded replica_id
+        ok 9 - decoded lsn
+        ok 10 - decoded tm
+        ok 11 - decoded sync
+        ok 12 - decoded bodycnt
+    ok 8 - subtests
+        1..12
+        ok 1 - encode
+        ok 2 - header map size
+        ok 3 - header decode
+        ok 4 - decoded is_commit
+        ok 5 - decoded wait_sync
+        ok 6 - decoded wait_ack
+        ok 7 - decoded type
+        ok 8 - decoded replica_id
+        ok 9 - decoded lsn
+        ok 10 - decoded tm
+        ok 11 - decoded sync
+        ok 12 - decoded bodycnt
+    ok 9 - subtests
  ok 2 - subtests
      1..1
      ok 1 - request_str


-- 
Serge Petrenko


  parent reply	other threads:[~2021-04-12 19:21 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-11 17:55 [Tarantool-patches] [PATCH 0/9] raft: introduce manual elections and fix a bug with re-applying rolled back transactions Serge Petrenko via Tarantool-patches
2021-04-11 17:55 ` [Tarantool-patches] [PATCH 1/9] wal: enrich row's meta information with sync replication flags Serge Petrenko via Tarantool-patches
2021-04-12 13:06   ` Cyrill Gorcunov via Tarantool-patches
2021-04-13 13:26     ` Serge Petrenko via Tarantool-patches
2021-04-12 19:21   ` Serge Petrenko via Tarantool-patches [this message]
2021-04-11 17:55 ` [Tarantool-patches] [PATCH 2/9] xrow: introduce a PROMOTE entry Serge Petrenko via Tarantool-patches
2021-04-11 17:55 ` [Tarantool-patches] [PATCH 3/9] box: actualise iproto_key_type array Serge Petrenko via Tarantool-patches
2021-04-11 17:55 ` [Tarantool-patches] [PATCH 4/9] box: make clear_synchro_queue() write a PROMOTE entry instead of CONFIRM + ROLLBACK Serge Petrenko via Tarantool-patches
2021-04-11 17:56 ` [Tarantool-patches] [PATCH 5/9] box: write PROMOTE even for empty limbo Serge Petrenko via Tarantool-patches
2021-04-11 17:56 ` [Tarantool-patches] [PATCH 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:23   ` Serge Petrenko via Tarantool-patches
2021-04-11 17:56 ` [Tarantool-patches] [PATCH 7/9] replication: introduce a new election mode: "manual" Serge Petrenko via Tarantool-patches
2021-04-11 17:56 ` [Tarantool-patches] [PATCH 8/9] Support manual elections in `box.ctl.clear_synchro_queue()` Serge Petrenko via Tarantool-patches
2021-04-12 19:23   ` Serge Petrenko via Tarantool-patches
2021-04-11 17:56 ` [Tarantool-patches] [PATCH 9/9] box.ctl: rename clear_synchro_queue to promote Serge Petrenko via Tarantool-patches
2021-04-12 19:24   ` Serge Petrenko 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=0a7cc1ab-35e8-172d-ed42-02ffe535d2b5@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 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