Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/release-notes/12391-fix-pid-generator-volatility.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion doc/sphinx-guides/source/_static/util/createsequence.sql
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ BEGIN
identifier := nextval('datasetidentifier_seq')::varchar;
RETURN identifier;
END;
$$ LANGUAGE plpgsql IMMUTABLE;
$$ LANGUAGE plpgsql VOLATILE;
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ BEGIN
identifier := base36_encode(curr_time_msec);
RETURN identifier;
END;
$$ LANGUAGE plpgsql IMMUTABLE;
$$ LANGUAGE plpgsql VOLATILE;
14 changes: 14 additions & 0 deletions src/main/resources/db/migration/V6.10.1.2.sql
Original file line number Diff line number Diff line change
@@ -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 $$;
Loading