RE: [PATCH] Fix possible underflow in expression (maxoff - 1) - Mailing list pgsql-hackers

From Ranier Vilela
Subject RE: [PATCH] Fix possible underflow in expression (maxoff - 1)
Date
Msg-id CO2PR05MB2629E54E4EA6358958F5EF23E3530@CO2PR05MB2629.namprd05.prod.outlook.com
Whole thread Raw
In response to Re: [PATCH] Fix possible underflow in expression (maxoff - 1)  (Thomas Munro <thomas.munro@gmail.com>)
List pgsql-hackers
De: Thomas Munro <thomas.munro@gmail.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
patchthat 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
goodin the patch. 
Unfortunately, that would not show where in the code the problem would be.

regards,
Ranier Vilela


pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Optimizing TransactionIdIsCurrentTransactionId()
Next
From: Ranier Vilela
Date:
Subject: RE: [Proposal] Level4 Warnings show many shadow vars