From: | PG Bug reporting form <noreply(at)postgresql(dot)org> |
---|---|
To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Cc: | xu(dot)xw2008(at)163(dot)com |
Subject: | BUG #18486: Is there something wrong with the calculation in ReorderBufferChangeSize()? |
Date: | 2024-05-29 09:05:25 |
Message-ID: | 18486-22cd3a6dc05a2454@postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
The following bug has been logged on the website:
Bug reference: 18486
Logged by: Xingwang Xu
Email address: xu(dot)xw2008(at)163(dot)com
PostgreSQL version: 17beta1
Operating system: CentOS7.9
Description:
In the code related to logical replication, there is a function
ReorderBufferChangeSize(), which is used to calculate the size of a change
in memory.
When looking at the ReorderBufferChangeSize() function, I saw the following
code:
case REORDER_BUFFER_CHANGE_MESSAGE:
{
Size prefix_size = strlen(change->data.msg.prefix) + 1;
sz += prefix_size + change->data.msg.message_size +
sizeof(Size) + sizeof(Size);
break;
}
When calculating the change size of the message type, there are two
“sizeof(Size)” in the code. It is not clear why these two “sizeof(Size)” are
added and whether these two “sizeof(Size)” are redundant.
The data in change of message type is defined as:
struct
{
char *prefix;
Size message_size;
char *message;
} msg;
The size of msg seems to have been calculated at the beginning of
ReorderBufferChangeSize() with “sizeof(ReorderBufferChange)”.Is it only
necessary to add the specific data space occupied by *prefix and *message?
Not super familiar with this so please let me know if there's something I've
missed.
Thanks,
Xingwang xu
From | Date | Subject | |
---|---|---|---|
Next Message | PG Bug reporting form | 2024-05-29 12:25:00 | BUG #18487: libpq: Race condition in PQsetdbLogin/emitHostIdentityInfo/libpq_gettext |
Previous Message | Laurenz Albe | 2024-05-29 07:51:08 | Re: Bug report - pg_upgrade tool seems to have a race condition when trying to delete a pg_wal file |