Re: Rework LogicalOutputPluginWriterUpdateProgress - Mailing list pgsql-hackers
From | Peter Smith |
---|---|
Subject | Re: Rework LogicalOutputPluginWriterUpdateProgress |
Date | |
Msg-id | CAHut+Pvi3o2UWK4tGeZHK418R9-ZAYv31Nhf2fHSoVqc=YnxtQ@mail.gmail.com Whole thread Raw |
In response to | RE: Rework LogicalOutputPluginWriterUpdateProgress ("wangw.fnst@fujitsu.com" <wangw.fnst@fujitsu.com>) |
Responses |
Re: Rework LogicalOutputPluginWriterUpdateProgress
RE: Rework LogicalOutputPluginWriterUpdateProgress |
List | pgsql-hackers |
On Wed, Mar 1, 2023 at 9:16 PM wangw.fnst@fujitsu.com <wangw.fnst@fujitsu.com> wrote: > > On Tues, Feb 28, 2023 at 9:12 AM Peter Smith <smithpb2250@gmail.com> wrote: > > Here are some comments for the v2-0001 patch. > > > > (I haven't looked at the v3 that was posted overnight; maybe some of > > my comments have already been addressed.) > > Thanks for your comments. > > > ====== > > General > > > > 1. (Info from the commit message) > > Since we can know whether the change is an end of transaction change in the > > common code, we removed the LogicalDecodingContext->end_xact introduced > > in > > commit f95d53e. > > > > ~ > > > > TBH, it was not clear to me that this change was an improvement. IIUC, > > it removes the "unnecessary" member, but only does that by replacing > > it everywhere with a boolean parameter passed to > > update_progress_and_keepalive(). So the end result seems no less code, > > but it is less readable code now because you need to know what the > > true/false parameter means. I wonder if it would have been better just > > to leave this how it was. > > Since I think we can know the meaning of the input based on the parameter name > of the function, I think both approaches are fine. But the approach in the > current patch can reduce a member of the structure, so I think this modification > looks good to me. > Hmm, I am not so sure: - Why is reducing members of LogicalDecodingContext even a goal? I thought the LogicalDecodingContext is intended to be the one-stop place to hold *all* things related to the "Context" (including that member that was deleted). - How is reducing one member better than introducing one new parameter in multiple calls? Anyway, I think this exposes another problem. If you still want the patch to pass the 'finshed_xact' parameter separately then AFAICT the first parameter (ctx) now becomes unused/redundant in the WalSndUpdateProgressAndKeepalive function, so it ought to be removed. > > ====== > > src/backend/replication/logical/logical.c > > > > 3. General - calls to is_skip_threshold_change() > > > > + if (is_skip_threshold_change(ctx)) > > + update_progress_and_keepalive(ctx, false); > > > > There are multiple calls like this, which are guarding the > > update_progress_and_keepalive() with the is_skip_threshold_change() > > - See truncate_cb_wrapper > > - See message_cb_wrapper > > - See stream_change_cb_wrapper > > - See stream_message_cb_wrapper > > - See stream_truncate_cb_wrapper > > - See UpdateDecodingProgressAndKeepalive > > > > IIUC, then I was thinking all those conditions maybe can be pushed > > down *into* the wrapper, thereby making every calling code simpler. > > > > e.g. make the wrapper function code look similar to the current > > UpdateDecodingProgressAndKeepalive: > > > > BEFORE (update_progress_and_keepalive) > > { > > if (!ctx->update_progress_and_keepalive) > > return; > > > > ctx->update_progress_and_keepalive(ctx, ctx->write_location, > > ctx->write_xid, ctx->did_write, > > finished_xact); > > } > > AFTER > > { > > if (!ctx->update_progress_and_keepalive) > > return; > > > > if (finished_xact || is_skip_threshold_change(ctx)) > > { > > ctx->update_progress_and_keepalive(ctx, ctx->write_location, > > ctx->write_xid, ctx->did_write, > > finished_xact); > > } > > } > > Since I want to keep the function update_progress_and_keepalive simple, I didn't > change it. Hmm, the reason given seems like a false economy to me. You are able to keep this 1 function simpler only by adding more complexity to the calls in 6 other places. Let's see if other people have opinions about this. ~~~ 1. + +static void UpdateProgressAndKeepalive(LogicalDecodingContext *ctx, + bool finished_xact); + +static bool is_keepalive_threshold_exceeded(LogicalDecodingContext *ctx); 1a. There is an unnecessary extra blank line above the UpdateProgressAndKeepalive. ~ 1b. I did not recognize a reason for the different naming conventions. Here are two new functions but one is CamelCase and one is snake_case. What are the rules to decide the naming? ------ Kind Regards, Peter Smith. Fujitsu Australia
pgsql-hackers by date: