Tarantool development patches archive
 help / color / mirror / Atom feed
From: mechanik20051988 via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: tarantool-patches@dev.tarantool.org, vdavydov@tarantool.org,
Subject: [Tarantool-patches] [PATCH v2 2/8] iproto: clear request::header for client requests
Date: Mon,  9 Aug 2021 17:37:56 +0300	[thread overview]
Message-ID: <27dd02321f8ec2f8c7b8bfd160023d63a55fff08.1628519206.git.mechanik20051988@tarantool.org> (raw)
In-Reply-To: <cover.1628519206.git.mechanik20051988@tarantool.org>

From: Vladimir Davydov <vdavydov@tarantool.org>

To apply a client request, we only need to know its type and body. All
the meta information, such as LSN, TSN, or replica id, must be set by
WAL. Currently, however, it isn't necessarily true: iproto leaves a
request header received over iproto as is, and tx will reuse the header
instead of allocating a new one in this case, which is needed to process
replication requests, see txn_add_redo().

Unless a client actually sets one of those meta fields, this causes no
problems. However, if we added transaction support to the replication
protocol, reusing the header would result in broken xlog, because
currently, all requests received over iproto have the is_commit field
set in xrow_header for the lack of TSN, while is_commit must only be set
for the final statement in a transaction. One way to fix it would be
clearing is_commit explicitly in iproto, but ignoring the whole header
received over iproto looks more logical and error-proof.

Needed for #5860
 src/box/iproto.cc | 6 ++++++
 src/box/xrow.h    | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/box/iproto.cc b/src/box/iproto.cc
index 5cc69b77f..dcf60e1be 100644
--- a/src/box/iproto.cc
+++ b/src/box/iproto.cc
@@ -1264,6 +1264,12 @@ iproto_msg_decode(struct iproto_msg *msg, const char **pos, const char *reqend,
 		if (xrow_decode_dml(&msg->header, &msg->dml,
 			goto error;
+		/*
+		 * In contrast to replication requests, for a client request
+		 * the xrow header is set by WAL, which generates LSNs and sets
+		 * replica id. Ignore the header received over network.
+		 */
+		msg->dml.header = NULL;
 		assert(type < sizeof(iproto_thread->dml_route) /
 		cmsg_init(&msg->base, iproto_thread->dml_route[type]);
diff --git a/src/box/xrow.h b/src/box/xrow.h
index 0f2fcf94a..48b8b55f5 100644
--- a/src/box/xrow.h
+++ b/src/box/xrow.h
@@ -163,7 +163,7 @@ struct request {
 	 * Either log row, or network header, or NULL, depending
 	 * on where this packet originated from: the write ahead
-	 * log/snapshot, client request, or a Lua request.
+	 * log/snapshot, repliation, or a client request.
 	struct xrow_header *header;

  parent reply	other threads:[~2021-08-09 14:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1628519206.git.mechanik20051988@tarantool.org>
2021-08-09 14:37 ` [Tarantool-patches] [PATCH v2 1/8] xrow: remove unused call_request::header mechanik20051988 via Tarantool-patches
2021-08-09 14:37 ` mechanik20051988 via Tarantool-patches [this message]
2021-08-09 14:37 ` [Tarantool-patches] [PATCH v2 5/8] iproto: implement streams in iproto mechanik20051988 via Tarantool-patches
2021-08-09 14:37 ` [Tarantool-patches] [PATCH v2 6/8] net.box: add stream support to net.box mechanik20051988 via Tarantool-patches
2021-08-09 14:37 ` [Tarantool-patches] [PATCH v2 7/8] iproto: implement interactive transactions over iproto streams mechanik20051988 via Tarantool-patches
2021-08-09 14:38 ` [Tarantool-patches] [PATCH v2 8/8] net.box: add interactive transaction support in net.box mechanik20051988 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:

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

  git send-email \
    --in-reply-to=27dd02321f8ec2f8c7b8bfd160023d63a55fff08.1628519206.git.mechanik20051988@tarantool.org \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=mechanik20051988@tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --cc=vdavydov@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v2 2/8] iproto: clear request::header for client requests' \


* 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