RE: [PATCH] Fix possible underflow in expression (maxoff - 1)

From: Ranier Vilela <ranier_gyn(at)hotmail(dot)com>
To: "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: RE: [PATCH] Fix possible underflow in expression (maxoff - 1)
Date: 2019-12-18 10:13:03
Message-ID: CO2PR05MB2629E54E4EA6358958F5EF23E3530@CO2PR05MB2629.namprd05.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

De: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Enviado: quarta-feira, 18 de dezembro de 2019 00:18

>If you're working on/with static code analysis tools, I have some
>requests :-) How could we automate the discovery of latch wait
>programming mistakes?
I doubt that static analysis can help with this problem.
This seems to me more like a high logic problem. Static tools are good at discovering flaws as uninitialized variable.
In a quick research I did on the subject, I found that sql queries specifically made can reveal latch wait.
So my suggestion for automating would be, if don't already have it, include a test class in regression testing:
make latch
Starting from a baseline (v12.1), which would generate an expected amount of latchs, as soon as the reviewer applied a patch that might touch buffer pages, it could run the test suite.
Once the result showed a significant increase in the number of latches, it would be a warning that something is not good in the patch.
Unfortunately, that would not show where in the code the problem would be.

regards,
Ranier Vilela

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Ranier Vilela 2019-12-18 10:16:49 RE: [Proposal] Level4 Warnings show many shadow vars
Previous Message Simon Riggs 2019-12-18 10:07:07 Optimizing TransactionIdIsCurrentTransactionId()