Inaccurate comments in ReorderBufferCheckMemoryLimit()
Masahiko Sawada <sawada.mshk@gmail.com>
From: Masahiko Sawada <sawada.mshk@gmail.com>
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2023-07-31T15:15:25Z
Lists: pgsql-hackers
Attachments
- fix_comment.patch (application/octet-stream) patch
Hi all,
While reading the code, I realized that the following code comments
might not be accurate:
/*
* Pick the largest transaction (or subtransaction) and evict it from
* memory by streaming, if possible. Otherwise, spill to disk.
*/
if (ReorderBufferCanStartStreaming(rb) &&
(txn = ReorderBufferLargestStreamableTopTXN(rb)) != NULL)
{
/* we know there has to be one, because the size is not zero */
Assert(txn && rbtxn_is_toptxn(txn));
Assert(txn->total_size > 0);
Assert(rb->size >= txn->total_size);
ReorderBufferStreamTXN(rb, txn);
}
AFAICS since ReorderBufferLargestStreamableTopTXN() returns only
top-level transactions, the comment above the if statement is not
right. It would not pick a subtransaction.
Also, I'm not sure that the second comment "we know there has to be
one, because the size is not zero" is right since there might not be
top-transactions that are streamable. I think this is why we say
"Otherwise, spill to disk".
I've attached a patch to fix these comments. Feedback is very welcome.
Regards,
--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com
Commits
-
Fix ReorderBufferCheckMemoryLimit() comment.
- 0125c4e21d7e 17.0 landed
- 5c0fcef76a44 16.0 landed
- 01357f1da94b 15.4 landed
- 2e3741fb5733 14.9 landed