Skip to content

Commit 578f2d0

Browse files
authored
Commit last transaction before ANALYZE phase (#780)
The way the code works prior to this change proposal, is that the transaction open for the final table to have constraints applied, will be left un-commited during the ANALYZE phase. Since an ACCESS EXCLUSIVE lock will still be held, this can be problematic.
1 parent a7d4590 commit 578f2d0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

sql/procedures/reapply_constraints_proc.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,12 @@ FOR v_row IN EXECUTE v_sql LOOP
112112
PERFORM @[email protected]_constraints(p_parent_table, format('%s.%s', v_row.partition_schemaname, v_row.partition_tablename)::text);
113113
END IF;
114114
END IF; -- end apply
115+
COMMIT;
115116

116117
IF v_row.partition_tablename = v_child_stop THEN
117118
RAISE DEBUG 'reapply_constraint: Reached stop at %.%', v_row.partition_schemaname, v_row.partition_tablename;
118119
EXIT; -- stop creating constraints after optimize target is reached
119120
END IF;
120-
COMMIT;
121121
PERFORM pg_sleep(p_wait);
122122
END LOOP;
123123

0 commit comments

Comments
 (0)