Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1waOhA-001lzu-2J for pgpool-hackers@arkaria.postgresql.org; Fri, 19 Jun 2026 02:11:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1waOh9-00EgAi-1g for pgpool-hackers@arkaria.postgresql.org; Fri, 19 Jun 2026 02:10:59 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1waOh9-00EgAb-11 for pgpool-hackers@lists.postgresql.org; Fri, 19 Jun 2026 02:10:59 +0000 Received: from meldrar.postgresql.org ([2a02:c0:301:0:ffff::31]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1waOh6-000000014Zm-0Zie for pgpool-hackers@lists.postgresql.org; Fri, 19 Jun 2026 02:10:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=postgresql.org; s=20171124; h=Content-Transfer-Encoding:Content-Type: Mime-Version:References:In-Reply-To:From:Subject:Cc:To:Message-Id:Date:Sender :Reply-To:Content-ID:Content-Description; bh=aUcJhSHSkAODfG8blg/VEUU+1v65hAIbsb7W14QcQfc=; b=iKANJUAyx3TahBrWKSPOPwpIf1 hJARfsjLBbuT8WtCPE3NTtl43d168CQ910lNBwzwvxdfafctBxg617BARrFpyx3WNBY66yII8ZxgM jA9ajPR+vtLLACYD/BGSORivY6yrdmeWdlxE5aGSLhGYIwk6WfoWcWyHej8ba6ryUvQEuAs26o8Qp SgKho+bizM6v+mzGiXQa8oJJ9cezLL2M/sJvsNTr/txM5Q3wJsREHVo34N/9fK9h+ArvO6Zt6Ccyf 84Fg64OWX2tGHVWrwzI3iTPzvQSjMlUl9dswybZrzECsDhy139avoY+9FxJAaHTbra76ocHh4IOhq yR3gOd0A==; Received: from [2409:11:4120:300:bb4b:c4e9:7426:10e1] (helo=localhost) by meldrar.postgresql.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1waOh0-0033jw-28; Fri, 19 Jun 2026 02:10:53 +0000 Date: Fri, 19 Jun 2026 11:10:37 +0900 (JST) Message-Id: <20260619.111037.159094338431818955.ishii@postgresql.org> To: nadav@tailorbrands.com Cc: pgpool-hackers@lists.postgresql.org Subject: Re: Proposal: Recent mutated table tracking in memory From: Tatsuo Ishii In-Reply-To: References: <20260604.185936.1758441592589268635.ishii@postgresql.org> X-Mailer: Mew version 6.8 on Emacs 29.3 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 2409:11:4120:300:bb4b:c4e9:7426:10e1 (failed) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > understood. we'll wait patiently or try master. > > thanks! While reviewing v5-0002-Feature-load-balancing-control-by-table-tracking.patch, I noticed following code: static void dml_adaptive(Node *node, char *query) { : : + /* + * For dml_adaptive_global: on COMMIT, flush the accumulated + * table writes to shared memory. On ROLLBACK, skip -- the + * writes never committed so no stale-read risk exists. This + * prevents polluting the table map with rolled-back + * transactions. + */ + int dlbow = + pool_config->disable_load_balance_on_write; + List *wlist = + session_context->transaction_temp_write_list; + + if (dlbow == DLBOW_DML_ADAPTIVE_GLOBAL && + is_commit_query(node) && + wlist != NIL) + { + ListCell *cell; + int dboid; + + dboid = + pool_track_table_mutation_get_database_oid(); + if (dboid > 0) + { + foreach(cell, wlist) + { + char *tname; + int toid; + + tname = (char *) lfirst(cell); + toid = + pool_table_name_to_oid(tname); + + if (toid > 0) + pool_track_table_mutation_mark_table_written( + toid, dboid); + } The code path is executed before the commit command is sent to primary PostgreSQL. I wonder what will happen if the commit command failed? Example: CREATE TEMP TABLE t1(i int PRIMARY KEY DEFERRABLE INITIALLY DEFERRED); CREATE TABLE INSERT INTO t1 VALUES(1); INSERT 0 1 BEGIN; BEGIN INSERT INTO t1 VALUES(1); INSERT 0 1 INSERT INTO t1 VALUES(2); INSERT 0 1 COMMIT; psql:deferable.sql:6: ERROR: duplicate key value violates unique constraint "t1_pkey" DETAIL: Key (i)=(1) already exists. As you can see, the COMMIT command failed and the effect of INSERT commands vanished too. However the code invalidates the data on the shared memory by pool_track_table_mutation_mark_table_written() when it should not be called? Regards, -- Tatsuo Ishii SRA OSS K.K. English: http://www.sraoss.co.jp/index_en/ Japanese:http://www.sraoss.co.jp