Refactoring postgres_fdw code to rollback remote transaction

Started by Fujii Masaoabout 5 years ago6 messageshackers
Jump to latest
#1Fujii Masao
masao.fujii@oss.nttdata.com

Hi,

In postgres_fdw, pgfdw_xact_callback() and pgfdw_subxact_callback() do
almost the same thing to rollback remote toplevel- and sub-transaction.
But their such rollback logics are implemented separately and
in different way. Which would decrease the readability and maintainability,
I think. So how about making the common function so that those callback
functions can just use it? Patch attached.

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION

Attachments:

refactor_pgfdw_rollback_v1.patchtext/plain; charset=UTF-8; name=refactor_pgfdw_rollback_v1.patch; x-mac-creator=0; x-mac-type=0Download+77-102
#2Zhihong Yu
zyu@yugabyte.com
In reply to: Fujii Masao (#1)
Re: Refactoring postgres_fdw code to rollback remote transaction

On Thu, Sep 16, 2021 at 7:31 PM Fujii Masao <masao.fujii@oss.nttdata.com>
wrote:

Hi,

In postgres_fdw, pgfdw_xact_callback() and pgfdw_subxact_callback() do
almost the same thing to rollback remote toplevel- and sub-transaction.
But their such rollback logics are implemented separately and
in different way. Which would decrease the readability and maintainability,
I think. So how about making the common function so that those callback
functions can just use it? Patch attached.

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION

Hi,

+ goto fail; /* Trouble clearing prepared statements */

The label fail can be removed. Under the above condition,
entry->changing_xact_state is still true. You can directly return.

Cheers

#3Fujii Masao
masao.fujii@oss.nttdata.com
In reply to: Zhihong Yu (#2)
Re: Refactoring postgres_fdw code to rollback remote transaction

On 2021/09/17 11:40, Zhihong Yu wrote:

+           goto fail;          /* Trouble clearing prepared statements */

The label fail can be removed. Under the above condition,  entry->changing_xact_state is still true. You can directly return.

Thanks for the review! Yes, you're right. Attached the updated version of the patch.

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION

Attachments:

refactor_pgfdw_rollback_v2.patchtext/plain; charset=UTF-8; name=refactor_pgfdw_rollback_v2.patch; x-mac-creator=0; x-mac-type=0Download+75-102
#4Bharath Rupireddy
bharath.rupireddyforpostgres@gmail.com
In reply to: Fujii Masao (#3)
Re: Refactoring postgres_fdw code to rollback remote transaction

On Fri, Sep 17, 2021 at 8:28 AM Fujii Masao <masao.fujii@oss.nttdata.com> wrote:

On 2021/09/17 11:40, Zhihong Yu wrote:

+ goto fail; /* Trouble clearing prepared statements */

The label fail can be removed. Under the above condition, entry->changing_xact_state is still true. You can directly return.

Thanks for the review! Yes, you're right. Attached the updated version of the patch.

+1 for the code refactoring (1 file changed, 75 insertions(+), 102
deletions(-)).

The v2 patch looks good to me as is.

Regards,
Bharath Rupireddy.

#5Fujii Masao
masao.fujii@oss.nttdata.com
In reply to: Bharath Rupireddy (#4)
Re: Refactoring postgres_fdw code to rollback remote transaction

On 2021/09/17 15:33, Bharath Rupireddy wrote:

On Fri, Sep 17, 2021 at 8:28 AM Fujii Masao <masao.fujii@oss.nttdata.com> wrote:

On 2021/09/17 11:40, Zhihong Yu wrote:

+ goto fail; /* Trouble clearing prepared statements */

The label fail can be removed. Under the above condition, entry->changing_xact_state is still true. You can directly return.

Thanks for the review! Yes, you're right. Attached the updated version of the patch.

+1 for the code refactoring (1 file changed, 75 insertions(+), 102
deletions(-)).

The v2 patch looks good to me as is.

Thanks for the review! Barring any objection, I will commit the patch.

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION

#6Fujii Masao
masao.fujii@oss.nttdata.com
In reply to: Fujii Masao (#5)
Re: Refactoring postgres_fdw code to rollback remote transaction

On 2021/09/22 0:16, Fujii Masao wrote:

Thanks for the review! Barring any objection, I will commit the patch.

Pushed. Thanks!

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION