[Tarantool-patches] [PATCH v2 1/9] wal: enrich row's meta information with sync replication flags
Cyrill Gorcunov
gorcunov at gmail.com
Tue Apr 13 14:50:36 MSK 2021
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 at 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 at 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
More information about the Tarantool-patches
mailing list