diff --git a/doc/release-notes/12391-fix-pid-generator-volatility.md b/doc/release-notes/12391-fix-pid-generator-volatility.md new file mode 100644 index 00000000000..32469ea9459 --- /dev/null +++ b/doc/release-notes/12391-fix-pid-generator-volatility.md @@ -0,0 +1,5 @@ +Fixed an issue where dataset creation could become stuck in an infinite loop when using a custom stored procedure for PID generation. + +The root cause was the stored procedure being marked as `IMMUTABLE` in PostgreSQL, which allowed the database or persistence layer to cache its result. + +A Flyway migration has been added to automatically set the volatility of `generateIdentifierFromStoredProcedure()` to `VOLATILE` instead. \ No newline at end of file diff --git a/doc/sphinx-guides/source/_static/util/createsequence.sql b/doc/sphinx-guides/source/_static/util/createsequence.sql index 7ac1968de2c..ff24789afc0 100644 --- a/doc/sphinx-guides/source/_static/util/createsequence.sql +++ b/doc/sphinx-guides/source/_static/util/createsequence.sql @@ -30,4 +30,4 @@ BEGIN identifier := nextval('datasetidentifier_seq')::varchar; RETURN identifier; END; -$$ LANGUAGE plpgsql IMMUTABLE; +$$ LANGUAGE plpgsql VOLATILE; diff --git a/doc/sphinx-guides/source/_static/util/identifier_from_timestamp.sql b/doc/sphinx-guides/source/_static/util/identifier_from_timestamp.sql index a755b5ecd4a..4324cc0e348 100644 --- a/doc/sphinx-guides/source/_static/util/identifier_from_timestamp.sql +++ b/doc/sphinx-guides/source/_static/util/identifier_from_timestamp.sql @@ -43,4 +43,4 @@ BEGIN identifier := base36_encode(curr_time_msec); RETURN identifier; END; -$$ LANGUAGE plpgsql IMMUTABLE; +$$ LANGUAGE plpgsql VOLATILE; diff --git a/src/main/resources/db/migration/V6.10.1.2.sql b/src/main/resources/db/migration/V6.10.1.2.sql new file mode 100644 index 00000000000..5e8e0aeea95 --- /dev/null +++ b/src/main/resources/db/migration/V6.10.1.2.sql @@ -0,0 +1,14 @@ +-- This migration ensures that the function used for identifier generation +-- is marked as VOLATILE to prevent caching issues that could lead to +-- infinite loops in the application code. + +DO $$ +BEGIN + IF EXISTS ( + SELECT 1 + FROM pg_proc + WHERE proname = 'generateidentifierfromstoredprocedure' + ) THEN + ALTER FUNCTION generateIdentifierFromStoredProcedure() VOLATILE; + END IF; +END $$;