Adding volatile qualifer

From: Tatsuo Ishii <ishii(at)postgresql(dot)org>
To: pgpool-hackers(at)lists(dot)postgresql(dot)org
Subject: Adding volatile qualifer
Date: 2026-07-01 01:11:48
Message-ID: 20260701.101148.451717746326656928.ishii@postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgpool-hackers

While looking into the Pgpool-II main source code, I noticed that
local pointer array "my_backend_status" is not volatile qualified,
while it should have been.

BACKEND_STATUS *my_backend_status[MAX_NUM_BACKENDS]; /* Backend status buffer */

This array members are initialized:

for (i = 0; i < MAX_NUM_BACKENDS; i++)
{
my_backend_status[i] = &(BACKEND_INFO(i).backend_status);
}

Without volatile, *(my_backend_status[i]) could read state value
because of compiler optimization. Since my_backend_status[i] is
referred to in popular VALID_BACKEND macro, we should fix it in all
supported branches.

Attached is the patch for master branch.

Regards,
--
Tatsuo Ishii
SRA OSS K.K.
English: http://www.sraoss.co.jp/index_en/
Japanese:http://www.sraoss.co.jp

Attachment Content-Type Size
failover_fix.patch text/x-patch 1.0 KB

Responses

Browse pgpool-hackers by date

  From Date Subject
Next Message Tatsuo Ishii 2026-07-02 07:39:22 Re: [PATCH] Segfault in pool_do_auth() when failover races with a new connection
Previous Message Tatsuo Ishii 2026-06-30 07:46:00 Re: [PATCH] Segfault in pool_do_auth() when failover races with a new connection