Hi, The parallel apply worker didn't add null termination to the string received from the leader apply worker via the shared memory queue. This action doesn't bring bugs as it's binary data but violates the rule established in StringInfo, which guarantees the presence of a terminating '\0' at the end of the string.
Although the original string in leader already includes the null termination, but we cannot just send all string including the null termination to the parallel worker, because that would increase the length while at the receiver there is still no null termination at data[length] which actually the length + 1 position. And we also cannot directly modify the received string like data[len] = '\0', because the data still points a shared buffer maintained by shared memory queue, so we'd better not modify the data outside of the string length. So, here is patch to use the standard StringInfo API to store the string while ensuring the addition of null termination. This can also resolve the Assert issue raised by another patch[1] currently under discussion. Thanks to Amit for offlist discussion regarding the analysis and fix. [1] https://www.postgresql.org/message-id/CAApHDvp6J4Bq9%3Df36-Z3mNWTsmkgGkSkX1Nwut%2BxhSi1aU8zQg%40mail.gmail.com Best Regards, Hou Zhijie
0001-Add-null-termination-to-string-received-in-parallel-.patch
Description: 0001-Add-null-termination-to-string-received-in-parallel-.patch