Tarantool development patches archive
 help / color / mirror / Atom feed
From: Cyrill Gorcunov via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Serge Petrenko <sergepetrenko@tarantool.org>
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 14:50:36 +0300	[thread overview]
Message-ID: <YHWFjFlTfbvAqVoi@grain> (raw)
In-Reply-To: <0d29b025b7213b5c9596715d849b4b371e1fef32.1618256019.git.sergepetrenko@tarantool.org>

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?

The patch is on top of your series.
---
From 8de9e03d5bf7ed5fd88d6d903bd7abef7a32286a Mon Sep 17 00:00:00 2001
From: Cyrill Gorcunov <gorcunov@gmail.com>
Date: Tue, 13 Apr 2021 14:47:40 +0300
Subject: [PATCH] test/unit: xrow -- verify bitfields order

Part-of #5445

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
 test/unit/xrow.cc     | 31 ++++++++++++++++++++++++++++++-
 test/unit/xrow.result |  7 ++++++-
 2 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/test/unit/xrow.cc b/test/unit/xrow.cc
index ea1ee1767..047f3330d 100644
--- a/test/unit/xrow.cc
+++ b/test/unit/xrow.cc
@@ -297,12 +297,40 @@ 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(3);
+
+	struct xrow_header header;
+
+	memset(&header, 0, sizeof(header));
+
+	header.is_commit = 1;
+	ok(header.opt_flags == IPROTO_FLAG_COMMIT, "header.is_commit");
+	header.is_commit = 0;
+
+	header.wait_sync = 1;
+	ok(header.opt_flags == IPROTO_FLAG_WAIT_SYNC, "header.wait_sync");
+	header.wait_sync = 0;
+
+	header.wait_ack = 1;
+	ok(header.opt_flags == IPROTO_FLAG_WAIT_ACK, "header.wait_ack");
+	header.wait_ack = 0;
+
+	check_plan();
+}
+
 int
 main(void)
 {
 	memory_init();
 	fiber_init(fiber_c_invoke);
-	plan(3);
+	plan(4);
 
 	random_init();
 
@@ -310,6 +338,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..bd8a475fc 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,8 @@ ok 2 - subtests
     1..1
     ok 1 - request_str
 ok 3 - subtests
+    1..3
+    ok 1 - header.is_commit
+    ok 2 - header.wait_sync
+    ok 3 - header.wait_ack
+ok 4 - subtests
-- 
2.30.2


  reply	other threads:[~2021-04-13 11:50 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 [this message]
2021-04-13 13:51     ` Serge Petrenko via Tarantool-patches
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=YHWFjFlTfbvAqVoi@grain \
    --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