From: | Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> |
---|---|
To: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Cc: | Dilip Kumar <dilipbalaut(at)gmail(dot)com> |
Subject: | Re: pgsql: Improve performance of subsystems on top of SLRU |
Date: | 2024-03-03 14:29:22 |
Message-ID: | 202403031429.zvfh7chvuk24@alvherre.pgsql |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers pgsql-hackers |
On 2024-Feb-28, Alvaro Herrera wrote:
> Improve performance of subsystems on top of SLRU
Coverity had the following complaint about this commit:
________________________________________________________________________________________________________
*** CID NNNNNNN: Control flow issues (DEADCODE)
/srv/coverity/git/pgsql-git/postgresql/src/backend/access/transam/multixact.c: 1375 in GetMultiXactIdMembers()
1369 * and acquire the lock of the new bank.
1370 */
1371 lock = SimpleLruGetBankLock(MultiXactOffsetCtl, pageno);
1372 if (lock != prevlock)
1373 {
1374 if (prevlock != NULL)
>>> CID 1592913: Control flow issues (DEADCODE)
>>> Execution cannot reach this statement: "LWLockRelease(prevlock);".
1375 LWLockRelease(prevlock);
1376 LWLockAcquire(lock, LW_EXCLUSIVE);
1377 prevlock = lock;
1378 }
1379
1380 slotno = SimpleLruReadPage(MultiXactOffsetCtl, pageno, true, multi);
And I think it's correct that this is somewhat bogus, or at least
confusing: the only way to have control back here on line 1371 after
having executed once is via the "goto retry" line below; and there we
release "prevlock" and set it to NULL beforehand, so it's impossible for
prevlock to be NULL. Looking closer I think this code is all confused,
so I suggest to rework it as shown in the attached patch.
I'll have a look at the other places where we use this "prevlock" coding
pattern tomorrow.
--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
Attachment | Content-Type | Size |
---|---|---|
0001-rework-locking-code-in-GetMultiXactIdMembers.patch | text/x-diff | 3.9 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Heikki Linnakangas | 2024-03-03 17:39:48 | pgsql: Redefine backend ID to be an index into the proc array |
Previous Message | Alvaro Herrera | 2024-03-03 13:57:22 | pgsql: GUC table: Add description to computed variables |
From | Date | Subject | |
---|---|---|---|
Next Message | Tomas Vondra | 2024-03-03 14:36:23 | Re: BitmapHeapScan streaming read user and prelim refactoring |
Previous Message | Jelte Fennema-Nio | 2024-03-03 14:27:35 | Re: Make query cancellation keys longer |