Done
Details
Assignee
Eric ValukEric Valuk(Deactivated)Reporter
Julian LadischJulian LadischPriority
P3Story Points
3Sprint
NoneDevelopment Team
Core: PlatformFix versions
TestRail: Cases
Open TestRail: CasesTestRail: Runs
Open TestRail: Runs
Details
Details
Assignee
Eric Valuk
Eric Valuk(Deactivated)Reporter
Julian Ladisch
Julian LadischPriority
Story Points
3
Sprint
None
Development Team
Core: Platform
Fix versions
TestRail: Cases
Open TestRail: Cases
TestRail: Runs
Open TestRail: Runs
Created March 20, 2019 at 9:36 AM
Updated February 5, 2020 at 5:35 PM
Resolved May 2, 2019 at 6:42 PM
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
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:
Add a section to RMB README.md how and why to generate UUIDs in Java.
Fail with a error message pointing to that section when schema.json contains
"generateId": true
or"generateId": false
so that all modules remove it when updating RMB. https://github.com/folio-org/raml-module-builder/tree/v23.11.0#the-post-tenant-apiRemove the "generateId" support from schema.json tenant API: https://github.com/folio-org/raml-module-builder/blob/v23.11.0/domain-models-runtime/src/main/resources/templates/db_scripts/main.ftl#L53
Do the same for "populateJsonWithId" as described in RMB-346. RMB-347 and RMB-346 should be implemented at the same time.
No longer "CREATE EXTENSION pgcrypto" to fail any gen_random_uuid() usage.
If there is a consensus about https://folio-org.atlassian.net/browse/RMB-277 (default name for primary key name) that should also be implemented at the same time (= removing the schema.json option "pkColumnName").