On Wed, Oct 11, 2023 at 12:18 PM Zhijie Hou (Fujitsu) <houzj.f...@fujitsu.com> wrote: > > 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. >
Yeah, it may not be a good idea to modify the buffer pointing to shared memory without any lock as we haven't reserved that part of memory. So, we can't follow the trick used in exec_bind_message() to maintain the convention that StringInfos have a trailing null. David, do you see any better way to fix this case? -- With Regards, Amit Kapila.