Skip to content

Fixes ISSUE-51718: Fix create.database with latest PG minor releases

Stefan Huehner requested to merge openbravo/devel/openbravo:fix/51718 into master

PostgreSQL latest minor versions (15.2, 14.7, 13.10, 12.14, 11.19) include a change to prohibit certain SQL to run in a pipeline without an explicit commit done just before.

Note: 10.x is not affected as it just went End Of Life before this change.

PG Release notes do not explain this very clearly as only talk about specific case:

Avoid an immediate commit after ANALYZE when using query pipelining.

This PostgreSQL commit goes into more details:

Discussion by another affected project explain the connection from 'in a pipeline to jdbc':

They asked PostgreSQL project about their case:

Only known case affecting us is ant create.database task. Specifically the DROP database run before (re-)creating the database:

    ERROR: DROP DATABASE cannot be executed within a pipeline

Earlier issue 45385 had to add an ALTER DATABASE just before the DROP DATABASE to work about an incompatibility of Amazon RDS (managed postgres).

As this intentionally ran ALTER and DROP database in a single transaction it now triggers that new restriction.

Given that we need to have both that RDS workaround + also work with the new PostgreSQL restriction run those two statements in two separate transactions.

That allows side-effect:

  • Owner of database changes to superuser 'postgres'
  • Only in case the "drop database" part fails

Testing done (all okay):

  • pg10 and pg12 (latest minor versions) 2*ant create.database
  • pg12 Local developer sharing db-user across various databases
  • pg12 check 'drop database' fails
    • have open connection to the database being droppped/recreated
    • fails as expected, side-effect (owner change) happens, closing connection and re-doing, works again
  • RDS12+RDS14
    • 2*ant create.database
    • also verified that both still require the "alter table" workaround today
    • Note: RDS itself does not yet have this behavior change, so only doing regression testing here
  • try (jobs_to_run=SIMPLE as fix only affecting create.db)
  • merged run

TODO:

  • dbsm testsuite (to see if more cases on top of this one are found)
    • Not a review/merge blocker
Edited by Stefan Huehner

Merge request reports