pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: 赵其桂 <zhaoqg45023@hundsun.com>
To: pgsql-hackers@lists.postgresql.org <pgsql-hackers@lists.postgresql.org>
Cc: 402142054@qq.com <402142054@qq.com>
Subject: BUG #17663:Connect to the database through jdbc, call the stored procedure containing the rollback statement,the database triggers an assertion, and the database is in recovery mode.
Date: Tue, 1 Nov 2022 12:57:00 +0000
Message-ID: <1667307420050.56657@hundsun.com> (raw)

Dear developer:
The patch submitted addresses #17663 in the pgsql-bugs@lists.postgresql.org list.
Problem: Add the parameters --enable-debug and --enable-cassert when the database is compiled. Driven by jdbc, the stored procedure containing rollbck is called, and an assertion occurs.
Cause of the problem: Driven by jdbc, in the function BuildCachedPlan, the CachedPlan memory context is generated to save the execution plan (plan) of the input SQL. If the stored procedure contains rollback, call the function ReleaseCachedPlan to release the CachedPlan memory context. Therefore, before the function pgss_store collects statistical information, it is necessary to retain the stmt_location and stmt_len data required in pstmt, which will not be released by the cCachedPlan memory context, resulting in random values for the parameters required by the function pgss_store.?

From 4d02406b92339c561aa3b5deca96ca875473655a Mon Sep 17 00:00:00 2001
From: oracle <oracle@localhost.localdomain>
Date: Tue, 1 Nov 2022 20:14:14 +0800
Subject: [PATCH] fix BUG #17663: Connect to the database through jdbc, call
 the stored procedure containing the rollback statement, the database triggers
 an assertion, and the database is in recovery mode

---
 contrib/pg_stat_statements/pg_stat_statements.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/contrib/pg_stat_statements/pg_stat_statements.c b/contrib/pg_stat_statements/pg_stat_statements.c
index 0beb56a..3330f35 100644
--- a/contrib/pg_stat_statements/pg_stat_statements.c
+++ b/contrib/pg_stat_statements/pg_stat_statements.c
@@ -1083,6 +1083,8 @@ pgss_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
 {
 	Node	   *parsetree = pstmt->utilityStmt;
 	uint64		saved_queryId = pstmt->queryId;
+	int	   stmt_location = pstmt->stmt_location;
+	int	   stmt_len = pstmt->stmt_len;
 
 	/*
 	 * Force utility statements to get queryId zero.  We do this even in cases
@@ -1172,8 +1174,8 @@ pgss_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
 
 		pgss_store(queryString,
 				   saved_queryId,
-				   pstmt->stmt_location,
-				   pstmt->stmt_len,
+				   stmt_location,
+				   stmt_len,
 				   PGSS_EXEC,
 				   INSTR_TIME_GET_MILLISEC(duration),
 				   rows,
-- 
1.8.3.1



Attachments:

  [text/plain] 0001-fix-BUG-17663-Connect-to-the-database-through-jdbc-c.patch (1.4K, ../1667307420050.56657@hundsun.com/2-0001-fix-BUG-17663-Connect-to-the-database-through-jdbc-c.patch)
  download | inline diff:
From 4d02406b92339c561aa3b5deca96ca875473655a Mon Sep 17 00:00:00 2001
From: oracle <oracle@localhost.localdomain>
Date: Tue, 1 Nov 2022 20:14:14 +0800
Subject: [PATCH] fix BUG #17663: Connect to the database through jdbc, call
 the stored procedure containing the rollback statement, the database triggers
 an assertion, and the database is in recovery mode

---
 contrib/pg_stat_statements/pg_stat_statements.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/contrib/pg_stat_statements/pg_stat_statements.c b/contrib/pg_stat_statements/pg_stat_statements.c
index 0beb56a..3330f35 100644
--- a/contrib/pg_stat_statements/pg_stat_statements.c
+++ b/contrib/pg_stat_statements/pg_stat_statements.c
@@ -1083,6 +1083,8 @@ pgss_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
 {
 	Node	   *parsetree = pstmt->utilityStmt;
 	uint64		saved_queryId = pstmt->queryId;
+	int	   stmt_location = pstmt->stmt_location;
+	int	   stmt_len = pstmt->stmt_len;
 
 	/*
 	 * Force utility statements to get queryId zero.  We do this even in cases
@@ -1172,8 +1174,8 @@ pgss_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
 
 		pgss_store(queryString,
 				   saved_queryId,
-				   pstmt->stmt_location,
-				   pstmt->stmt_len,
+				   stmt_location,
+				   stmt_len,
 				   PGSS_EXEC,
 				   INSTR_TIME_GET_MILLISEC(duration),
 				   rows,
-- 
1.8.3.1



view thread (2+ messages)  latest in thread

Message-ID: <1667307420050.56657@hundsun.com>
Permalink:  ../1667307420050.56657@hundsun.com/
Also on:    postgresql.org/message-id/1667307420050.56657@hundsun.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-hackers@postgresql.org
  Cc: zhaoqg45023@hundsun.com, pgsql-hackers@lists.postgresql.org, 402142054@qq.com
  Subject: Re: BUG #17663:Connect to the database through jdbc, call the stored procedure containing the rollback statement,the database triggers an assertion, and the database is in recovery mode.
  In-Reply-To: <1667307420050.56657@hundsun.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