Uploaded image for project: 'RAML Module Builder'
  1. RAML Module Builder
  2. RMB-347

Remove gen_random_uuid() as it fails in replication environments

    XMLWordPrintable

    Details

    • Template:
    • Sprint:
      CP: sprint 62
    • Story Points:
      3
    • Development Team:
      Core: Platform

      Description

      gen_random_uuid() creates a different UUID in each node of a replicated PostgreSQL environment.
      This has been reported for mod-configuration and Pgpool-II replication in #sys-ops on Slack yesterday. From the Pgpool-II manual:
      https://www.pgpool.net/docs/latest/en/html/restrictions.html

      Functions, etc. In Native Replication mode

      There is no guarantee that any data provided using a context-dependent mechanism (e.g. random number, transaction ID, OID, SERIAL, sequence), will be replicated correctly on multiple backends. For SERIAL, enabling insert_lock will help replicating data. insert_lock also helps SELECT setval() and SELECT nextval().

      mod-configuration is special in that it lets the database create a new UUID that always overwrites any provided UUID for the primary key _id:

      https://github.com/folio-org/mod-configuration/blob/v5.0.1/mod-configuration-server/src/main/java/org/folio/rest/impl/ConfigAPI.java#L159
      https://github.com/folio-org/mod-configuration/blob/v5.0.1/mod-configuration-server/src/main/resources/templates/db_scripts/schema.json#L14-L15
      https://github.com/folio-org/raml-module-builder/blob/v23.11.0/domain-models-runtime/src/main/resources/templates/db_scripts/main.ftl#L53

      Most other modules never overwrite a primary key UUID _id provided by the caller of the POST API. And if no such primary key is provided they create a new one in Java code so that all replicated nodes receive the same _id. The suggested implementation in PgUtil.post also works this way:
      https://github.com/folio-org/raml-module-builder/blob/v23.11.0/domain-models-runtime/src/main/java/org/folio/rest/persist/PgUtil.java#L358
      https://github.com/folio-org/raml-module-builder/blob/v23.11.0/domain-models-runtime/src/main/java/org/folio/rest/persist/PgUtil.java#L305

      How to fix:

      If there is a consensus about https://issues.folio.org/browse/RMB-277 (default name for primary key name) that should also be implemented at the same time (= removing the schema.json option "pkColumnName").

        TestRail: Results

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                evaluk Eric Valuk
                Reporter:
                julianladisch Julian Ladisch
                Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:

                    TestRail: Runs

                      TestRail: Cases