Skip to content

Commit

Permalink
[#23124] YSQL: Disable advisory locks usage in pg_partman
Browse files Browse the repository at this point in the history
Summary:
Some of the pg_partman functions and procedures that involves creation and dropping/deletion of partitioned tables
takes transaction level advisory locks.

Currently advisory locks are supported in YugabyteDB. Therefore this diff disabled invocation of acquiring advisory locks.
Jira: DB-12057

Test Plan: jenkins: compile only

Reviewers: skumar, hsunder, jason

Reviewed By: jason

Subscribers: yql

Differential Revision: https://phorge.dev.yugabyte.com/D36426
  • Loading branch information
Devansh Saxena committed Jul 15, 2024
1 parent bc55a46 commit e1ef208
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ BEGIN
* Options to move table to different schema, drop only indexes or actually drop the table from the database.
*/

/* YB: advisory lock not supported
v_adv_lock := pg_try_advisory_xact_lock(hashtext('pg_partman drop_partition_id'));
IF v_adv_lock = 'false' THEN
RAISE NOTICE 'drop_partition_id already running.';
RETURN 0;
END IF;
*/

IF p_retention IS NULL THEN
SELECT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ BEGIN
* Options to move table to different schema, drop only indexes or actually drop the table from the database.
*/

/* YB: advisory lock not supported
v_adv_lock := pg_try_advisory_xact_lock(hashtext('pg_partman drop_partition_time'));
IF v_adv_lock = 'false' THEN
RAISE NOTICE 'drop_partition_time already running.';
RETURN 0;
END IF;
*/

-- Allow override of configuration options
IF p_retention IS NULL THEN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,13 @@ BEGIN
* Be aware that constraint exclusion may not work properly until an analyze on the partition set is run.
*/

/* YB: advisory lock not supported
v_adv_lock := pg_try_advisory_xact_lock(hashtext('pg_partman run_maintenance'));
IF v_adv_lock = 'false' THEN
RAISE NOTICE 'Partman maintenance already running.';
RETURN;
END IF;
*/

SELECT current_setting('search_path') INTO v_old_search_path;
IF length(v_old_search_path) > 0 THEN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,14 @@ BEGIN
* For trigger-based, moves data to parent
*/

/* YB: advisory lock not supported
v_adv_lock := pg_try_advisory_xact_lock(hashtext('pg_partman undo_partition_native'));
IF v_adv_lock = 'false' THEN
RAISE NOTICE 'undo_partition_native already running.';
partitions_undone = -1;
RETURN;
END IF;
*/

IF p_parent_table = p_target_table THEN
RAISE EXCEPTION 'Target table cannot be the same as the parent table';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ v_total bigint := 0;

BEGIN

/* YB: advisory lock not supported
v_adv_lock := pg_try_advisory_xact_lock(hashtext('pg_partman partition_data_proc'), hashtext(p_parent_table));
IF v_adv_lock = 'false' THEN
RAISE NOTICE 'Partman partition_data_proc already running for given parent table: %.', p_parent_table;
RETURN;
END IF;
*/

SELECT control, epoch
INTO v_control, v_epoch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ BEGIN
* Typical usage would be to run the drop mode, edit the data, then run apply mode to re-create all constraints on a partition set."
*/

/* YB: advisory lock not supported
v_adv_lock := pg_try_advisory_lock(hashtext('pg_partman reapply_constraints'));
IF v_adv_lock = false THEN
RAISE NOTICE 'Partman reapply_constraints_proc already running or another session has not released its advisory lock.';
RETURN;
END IF;
*/


SELECT control, premake, optimize_constraint, datetime_string, epoch, partition_interval
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ v_sql text;

BEGIN

/* YB: advisory lock not supported
v_adv_lock := pg_try_advisory_lock(hashtext('pg_partman run_analyze'));
IF v_adv_lock = false THEN
RAISE NOTICE 'Partman analyze already running or another session has not released its advisory lock.';
RETURN;
END IF;
*/

FOR v_row IN SELECT parent_table FROM @extschema@.part_config
LOOP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ v_tables_list_sql text;

BEGIN

/* YB: advisory lock not supported
v_adv_lock := pg_try_advisory_lock(hashtext('pg_partman run_maintenance'));
IF v_adv_lock = false THEN
RAISE NOTICE 'Partman maintenance already running or another session has not released its advisory lock.';
RETURN;
END IF;
*/

v_tables_list_sql := 'SELECT parent_table
FROM @extschema@.part_config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ v_total bigint := 0;

BEGIN

/* YB: advisory lock not supported
v_adv_lock := pg_try_advisory_xact_lock(hashtext('pg_partman undo_partition_proc'), hashtext(p_parent_table));
IF v_adv_lock = 'false' THEN
RAISE NOTICE 'Partman undo_partition_proc already running for given parent table: %.', p_parent_table;
RETURN;
END IF;
*/

SELECT partition_type
INTO v_partition_type
Expand Down

0 comments on commit e1ef208

Please sign in to comment.