Skip to content

Commit

Permalink
v1.6.0 Fixed lock wait counter not being reset in partitioning functions
Browse files Browse the repository at this point in the history
  • Loading branch information
keithf4 committed Feb 11, 2014
1 parent 00d4378 commit 2a7f66b
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Expand Up @@ -7,6 +7,7 @@
-- For id-based partitioning, only the partition starting at the given value (plus premake) will be made.
-- pg_jobmon is now truly optional. Additonal configuration option for each individual partition set to turn it off and on. run_maintenance() now has an optional parameter to turn it off when being run. If you tried to partition pg_jobmon tables before, it would cause a permanent lockwait. Turn pg_jobmon off for those tables to avoid this.
-- Fixed partition_data_time() & partition_data_id() functions to recreate the parent trigger function when static partitioning is used. Without this, partitioning more recent data that may have gotten into the parent table could possibly leave the function without conditions for the new partitions. run_maintenance() would eventually fix this for time partitioning, but id partitioning could be left in a broken state forever. (Github issue #16)
-- Fixed bug in partition_data_time() & partition_data_id() to reset the lock wait counter properly between loops. Bug reported & fixed by bougyman from #postgresql on Freenode.
-- pg_partman only supports id intervals greater than 1. May see if I can get an interval of 1 working later, but changed create_parent() to check for this and not allow it since it won't work properly at this time. New partitions were not automatically created if interval was set to 1. (Github issue #15)
-- Clarify in docs that the id interval value passed to create_parent() must actually be in text type format.
-- Changed drop & undo partition functions to use transaction based advistory locks.
Expand Down
4 changes: 2 additions & 2 deletions bin/dump_partition.py
Expand Up @@ -78,7 +78,7 @@ def create_hash(table_name):
break
shash.update(data)
except IOError, (ErrorNo, ErrorMsg):
print "Cannot access dump file for hash creation: " + ErrorMessage
print "Cannot access dump file for hash creation: " + ErrorMsg
sys.exit(2)

hash_file = os.path.join(args.output, args.schema + "." + table_name + ".hash")
Expand All @@ -88,7 +88,7 @@ def create_hash(table_name):
with open(hash_file, "w") as fh:
fh.write(shash.hexdigest() + " " + os.path.basename(output_file))
except IOError, (ErroNo, ErrorMsg):
print "Unable to write to hash file: " + ErrorMessage
print "Unable to write to hash file: " + ErrorMsg
sys.exit(2)


Expand Down
2 changes: 1 addition & 1 deletion sql/functions/partition_data_id.sql
Expand Up @@ -59,6 +59,7 @@ FOR i IN 1..p_batch_count LOOP

-- do some locking with timeout, if required
IF p_lock_wait > 0 THEN
v_lock_iter := 0;
WHILE v_lock_iter <= 5 LOOP
v_lock_iter := v_lock_iter + 1;
BEGIN
Expand Down Expand Up @@ -103,4 +104,3 @@ RETURN v_total_rows;

END
$$;

2 changes: 1 addition & 1 deletion sql/functions/partition_data_time.sql
Expand Up @@ -104,6 +104,7 @@ FOR i IN 1..p_batch_count LOOP

-- do some locking with timeout, if required
IF p_lock_wait > 0 THEN
v_lock_iter := 0;
WHILE v_lock_iter <= 5 LOOP
v_lock_iter := v_lock_iter + 1;
BEGIN
Expand Down Expand Up @@ -148,4 +149,3 @@ RETURN v_total_rows;

END
$$;

3 changes: 3 additions & 0 deletions updates/pg_partman--1.5.1--1.6.0.sql
Expand Up @@ -6,6 +6,7 @@
-- For id-based partitioning, only the partition starting at the given value (plus premake) will be made.
-- pg_jobmon is now truly optional. Additonal configuration option for each individual partition set to turn it off and on. run_maintenance() now has an optional parameter to turn it off when being run. If you tried to partition pg_jobmon tables before, it would cause a permanent lockwait. Turn pg_jobmon off for those tables to avoid this.
-- Fixed partition_data_time() & partition_data_id() functions to recreate the parent trigger function when static partitioning is used. Without this, partitioning more recent data that may have gotten into the parent table could possibly leave the function without conditions for the new partitions. run_maintenance() would eventually fix this for time partitioning, but id partitioning could be left in a broken state forever. (Github issue #16)
-- Fixed bug in partition_data_time() & partition_data_id() to reset the lock wait counter properly between loops. Bug reported & fixed by bougyman from #postgresql on Freenode.
-- pg_partman only supports id intervals greater than 1. May see if I can get an interval of 1 working later, but changed create_parent() to check for this and not allow it since it won't work properly at this time. New partitions were not automatically created if interval was set to 1. (Github issue #15)
-- Clarify in docs that the id interval value passed to create_parent() must actually be in text type format.
-- Changed drop & undo partition functions to use transaction based advistory locks.
Expand Down Expand Up @@ -930,6 +931,7 @@ FOR i IN 1..p_batch_count LOOP

-- do some locking with timeout, if required
IF p_lock_wait > 0 THEN
v_lock_iter := 0;
WHILE v_lock_iter <= 5 LOOP
v_lock_iter := v_lock_iter + 1;
BEGIN
Expand Down Expand Up @@ -1984,6 +1986,7 @@ FOR i IN 1..p_batch_count LOOP

-- do some locking with timeout, if required
IF p_lock_wait > 0 THEN
v_lock_iter := 0;
WHILE v_lock_iter <= 5 LOOP
v_lock_iter := v_lock_iter + 1;
BEGIN
Expand Down

0 comments on commit 2a7f66b

Please sign in to comment.