pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Fujii Masao <masao.fujii@oss.nttdata.com>
To: zoulx1982@163.com
To: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #16931: source code problem about commit_ts
Date: Thu, 18 Mar 2021 19:19:10 +0900
Message-ID: <d5b98b4b-a3e3-8095-cfb9-aafb5dbe4f7b@oss.nttdata.com> (raw)
In-Reply-To: <16931-620d0f2fdc6108f1@postgresql.org>
References: <16931-620d0f2fdc6108f1@postgresql.org>



On 2021/03/18 13:36, PG Bug reporting form wrote:
> The following bug has been logged on the website:
> 
> Bug reference:      16931
> Logged by:          lx zou
> Email address:      zoulx1982@163.com
> PostgreSQL version: 13.2
> Operating system:   Linux
> Description:
> 
> Hi,
> recently i am reading commit ts code, and i have a problem about it.
> i found commit_ts_redo call TransactionTreeSetCommitTsData with last param
> `write_xlog`  true,
> but RecordTransactionCommitPrepared and RecordTransactionCommit call
> TransactionTreeSetCommitTsData
> with `write_xlog` false, which cause there are never xlog with commit_ts -
> COMMIT_TS_SETTS type.
> thanks for your time.

I guess that TransactionTreeSetCommitTsData(write_xlog=true) is basically
used by some extensions using commit_ts.

IIUC commit_ts_redo() is called during recovery. So it's strange that
commit_ts_redo() calls TransactionTreeSetCommitTsData() with write_xlog=true
because no new WAL can be generated during recovery. Probably this is a bug,
and it should be called with write_xlog=false, instead. Patch attached.

Also one problem is that there is no test for WAL replay of COMMIT_TS_SETTS
for now. Maybe this is why we could not find that bug.

Regards,

-- 
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 48e8d66286..268bdba339 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -1074,7 +1074,7 @@ commit_ts_redo(XLogReaderState *record)
 			subxids = NULL;
 
 		TransactionTreeSetCommitTsData(setts->mainxid, nsubxids, subxids,
-									   setts->timestamp, setts->nodeid, true);
+									   setts->timestamp, setts->nodeid, false);
 		if (subxids)
 			pfree(subxids);
 	}


Attachments:

  [text/plain] bugfix.patch (519B, ../d5b98b4b-a3e3-8095-cfb9-aafb5dbe4f7b@oss.nttdata.com/2-bugfix.patch)
  download | inline diff:
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 48e8d66286..268bdba339 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -1074,7 +1074,7 @@ commit_ts_redo(XLogReaderState *record)
 			subxids = NULL;
 
 		TransactionTreeSetCommitTsData(setts->mainxid, nsubxids, subxids,
-									   setts->timestamp, setts->nodeid, true);
+									   setts->timestamp, setts->nodeid, false);
 		if (subxids)
 			pfree(subxids);
 	}


view thread (12+ messages)  latest in thread

Message-ID: <d5b98b4b-a3e3-8095-cfb9-aafb5dbe4f7b@oss.nttdata.com>
Permalink:  ../d5b98b4b-a3e3-8095-cfb9-aafb5dbe4f7b@oss.nttdata.com/
Also on:    postgresql.org/message-id/d5b98b4b-a3e3-8095-cfb9-aafb5dbe4f7b@oss.nttdata.com

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: masao.fujii@oss.nttdata.com, zoulx1982@163.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #16931: source code problem about commit_ts
  In-Reply-To: <d5b98b4b-a3e3-8095-cfb9-aafb5dbe4f7b@oss.nttdata.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox