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,
	v.shpilevoy@tarantool.org
Subject: [Tarantool-patches] [PATCH v4 2/9] iproto: clear request::header for client requests
Date: Thu, 12 Aug 2021 12:50:39 +0300	[thread overview]
Message-ID: <2d2e87ffcd6ea5306eb2242c27ce737c28c5cedb.1628759886.git.mechanik20051988@tarantool.org> (raw)
In-Reply-To: <cover.1628759886.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,
 				    dml_request_key_map(type)))
 			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) /
 		              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;
 	/**
-- 
2.20.1


  parent reply	other threads:[~2021-08-12  9:53 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-12  9:50 [Tarantool-patches] [PATCH v4 0/9] implement iproto streams mechanik20051988 via Tarantool-patches
2021-08-12  9:50 ` [Tarantool-patches] [PATCH v4 1/9] xrow: remove unused call_request::header mechanik20051988 via Tarantool-patches
2021-08-12  9:50 ` mechanik20051988 via Tarantool-patches [this message]
2021-08-12  9:50 ` [Tarantool-patches] [PATCH v4 3/9] iproto: implement stream id in binary iproto protocol mechanik20051988 via Tarantool-patches
2021-08-12  9:50 ` [Tarantool-patches] [PATCH v4 4/9] salad: fix segfault in case when mhash table allocation failure mechanik20051988 via Tarantool-patches
2021-08-12  9:50 ` [Tarantool-patches] [PATCH v4 5/9] iproto: implement streams in iproto mechanik20051988 via Tarantool-patches
2021-08-12  9:50 ` [Tarantool-patches] [PATCH v4 6/9] net.box: add stream support to net.box mechanik20051988 via Tarantool-patches
2021-08-12 17:49   ` Vladislav Shpilevoy via Tarantool-patches
2021-08-12  9:50 ` [Tarantool-patches] [PATCH v4 7/9] iproto: add RAFT prefix for all requests related to 'raft' mechanik20051988 via Tarantool-patches
2021-08-12  9:50 ` [Tarantool-patches] [PATCH v4 8/9] iproto: implement interactive transactions over iproto streams mechanik20051988 via Tarantool-patches
2021-08-12 10:48   ` Vladimir Davydov via Tarantool-patches
2021-08-12  9:50 ` [Tarantool-patches] [PATCH v4 9/9] net.box: add interactive transaction support in net.box mechanik20051988 via Tarantool-patches
2021-08-12 17:52   ` Vladislav Shpilevoy via Tarantool-patches
2021-08-13  7:44     ` Vladimir Davydov via Tarantool-patches
2021-08-12 10:51 ` [Tarantool-patches] [PATCH v4 0/9] implement iproto streams Vladimir Davydov 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=2d2e87ffcd6ea5306eb2242c27ce737c28c5cedb.1628759886.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 v4 2/9] iproto: clear request::header for client requests' \
    /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