liquid_feedback_core

changeset 295:69d6fba0f84c

Use EXCLUSIVE MODE table locks in function "lock_issue"("issue"."id")

Avoids deadlocks caused by explicit FOR UPDATE row locks when updating member statements and implicit FOR SHARE row locks when writing snapshots.
author jbe
date Thu Sep 13 17:02:22 2012 +0200 (2012-09-13)
parents e818f83e133b
children bcfde30040f6
files core.sql
line diff
     1.1 --- a/core.sql	Wed Jun 20 21:22:02 2012 +0200
     1.2 +++ b/core.sql	Thu Sep 13 17:02:22 2012 +0200
     1.3 @@ -2925,10 +2925,10 @@
     1.4    RETURNS VOID
     1.5    LANGUAGE 'plpgsql' VOLATILE AS $$
     1.6      BEGIN
     1.7 -      LOCK TABLE "member"     IN SHARE MODE;
     1.8 -      LOCK TABLE "privilege"  IN SHARE MODE;
     1.9 -      LOCK TABLE "membership" IN SHARE MODE;
    1.10 -      LOCK TABLE "policy"     IN SHARE MODE;
    1.11 +      LOCK TABLE "member"     IN EXCLUSIVE MODE;
    1.12 +      LOCK TABLE "privilege"  IN EXCLUSIVE MODE;
    1.13 +      LOCK TABLE "membership" IN EXCLUSIVE MODE;
    1.14 +      LOCK TABLE "policy"     IN EXCLUSIVE MODE;
    1.15        PERFORM NULL FROM "issue" WHERE "id" = "issue_id_p" FOR UPDATE;
    1.16        -- NOTE: The row-level exclusive lock in combination with the
    1.17        -- share_row_lock_issue(_via_initiative)_trigger functions (which
    1.18 @@ -2936,7 +2936,7 @@
    1.19        -- is changed, which could affect calculation of snapshots or
    1.20        -- counting of votes. Table "delegation" must be table-level-locked,
    1.21        -- as it also contains issue- and global-scope delegations.
    1.22 -      LOCK TABLE "delegation" IN SHARE MODE;
    1.23 +      LOCK TABLE "delegation" IN EXCLUSIVE MODE;
    1.24        LOCK TABLE "direct_population_snapshot"     IN EXCLUSIVE MODE;
    1.25        LOCK TABLE "delegating_population_snapshot" IN EXCLUSIVE MODE;
    1.26        LOCK TABLE "direct_interest_snapshot"       IN EXCLUSIVE MODE;

Impressum / About Us