Inaccurate comments in ReorderBufferCheckMemoryLimit()

From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Inaccurate comments in ReorderBufferCheckMemoryLimit()
Date: 2023-07-31 15:15:25
Message-ID: CAD21AoA9XB7OR86BqvrCe2dMYX+Zv3-BvVmjF=GY2z6jN-kqjg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

Attachment Content-Type Size
fix_comment.patch application/octet-stream 944 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Junwang Zhao 2023-07-31 15:26:13 Re: pg_upgrade fails with in-place tablespace
Previous Message Euler Taveira 2023-07-31 14:27:46 Re: CDC/ETL system on top of logical replication with pgoutput, custom client