summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <grothoff@gnunet.org>2023-08-27 14:05:09 +0200
committerChristian Grothoff <grothoff@gnunet.org>2023-08-27 14:05:12 +0200
commitdd7567fd05b29004c6517963923deacadfbc0a73 (patch)
treec4a15a0815f4483d9f0ad44df774ebd4951a02f5
parent58e6b66e2fdadbe3818d8385ec8e149384905588 (diff)
downloadanastasis-dd7567fd05b29004c6517963923deacadfbc0a73.tar.gz
anastasis-dd7567fd05b29004c6517963923deacadfbc0a73.tar.bz2
anastasis-dd7567fd05b29004c6517963923deacadfbc0a73.zip
-fix issue with multiple dbinit running concurrently
-rw-r--r--src/stasis/versioning.sql7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/stasis/versioning.sql b/src/stasis/versioning.sql
index 116f409..c7fa812 100644
--- a/src/stasis/versioning.sql
+++ b/src/stasis/versioning.sql
@@ -146,12 +146,17 @@
BEGIN;
+-- Added by Christian Grothoff to support concurrency, see
+-- https://stackoverflow.com/questions/29900845/create-schema-if-not-exists-raises-duplicate-key-error?rq=4
+LOCK TABLE pg_catalog.pg_namespace;
+
+
-- This file adds versioning support to database it will be loaded to.
-- It requires that PL/pgSQL is already loaded - will raise exception otherwise.
-- All versioning "stuff" (tables, functions) is in "_v" schema.
-- All functions are defined as 'RETURNS SETOF INT4' to be able to make them to RETURN literally nothing (0 rows).
--- >> RETURNS VOID<< IS similar, but it still outputs "empty line" in psql when calling.
+-- >> RETURNS VOID<< IS similar, but it still outputs "empty line" in psql when calling
CREATE SCHEMA IF NOT EXISTS _v;
COMMENT ON SCHEMA _v IS 'Schema for versioning data and functionality.';