# HG changeset patch # User jbe # Date 1544194082 -3600 # Node ID aa23fa17604d1a75d4bfa05ac135deeb22cbb5c7 # Parent 6f427a8f80612db50be5cd8b98622cefd35d28e1 Removed "snapshot_retention" configuration: always delete unused snapshots immediately diff -r 6f427a8f8061 -r aa23fa17604d core.sql --- a/core.sql Wed Dec 05 00:35:30 2018 +0100 +++ b/core.sql Fri Dec 07 15:48:02 2018 +0100 @@ -67,15 +67,13 @@ CREATE TABLE "system_setting" ( - "member_ttl" INTERVAL, - "snapshot_retention" INTERVAL ); + "member_ttl" INTERVAL ); CREATE UNIQUE INDEX "system_setting_singleton_idx" ON "system_setting" ((1)); COMMENT ON TABLE "system_setting" IS 'This table contains only one row with different settings in each column.'; COMMENT ON INDEX "system_setting_singleton_idx" IS 'This index ensures that "system_setting" only contains one row maximum.'; COMMENT ON COLUMN "system_setting"."member_ttl" IS 'Time after members get their "active" flag set to FALSE, if they do not show any activity.'; -COMMENT ON COLUMN "system_setting"."snapshot_retention" IS 'Unreferenced snapshots are retained for the given period of time after creation; set to NULL for infinite retention.'; CREATE TABLE "contingent" ( @@ -3830,17 +3828,6 @@ COMMENT ON VIEW "unused_snapshot" IS 'Snapshots that are not referenced by any issue (either as latest snapshot or as snapshot at phase/state change)'; -CREATE VIEW "expired_snapshot" AS - SELECT "unused_snapshot".* FROM "unused_snapshot" CROSS JOIN "system_setting" - WHERE "unused_snapshot"."calculated" < - now() - "system_setting"."snapshot_retention"; - -CREATE RULE "delete" AS ON DELETE TO "expired_snapshot" DO INSTEAD - DELETE FROM "snapshot" WHERE "id" = OLD."id"; - -COMMENT ON VIEW "expired_snapshot" IS 'Contains "unused_snapshot"s that are older than "system_setting"."snapshot_retention" (for deletion)'; - - CREATE VIEW "open_issue" AS SELECT * FROM "issue" WHERE "closed" ISNULL; @@ -6501,7 +6488,7 @@ RAISE WARNING 'Function "check_everything" should only be used for development and debugging purposes'; DELETE FROM "expired_session"; DELETE FROM "expired_token"; - DELETE FROM "expired_snapshot"; + DELETE FROM "unused_snapshot"; PERFORM "check_activity"(); PERFORM "calculate_member_counts"(); FOR "area_id_v" IN SELECT "id" FROM "area_with_unaccepted_issues" LOOP @@ -6519,6 +6506,7 @@ EXIT WHEN "persist_v" ISNULL; END LOOP; END LOOP; + DELETE FROM "unused_snapshot"; RETURN; END; $$; diff -r 6f427a8f8061 -r aa23fa17604d lf_update.c --- a/lf_update.c Wed Dec 05 00:35:30 2018 +0100 +++ b/lf_update.c Fri Dec 07 15:48:02 2018 +0100 @@ -105,8 +105,8 @@ // delete expired tokens and authorization codes: exec_sql(db, NULL, &err, 0, "DELETE FROM \"expired_token\""); - // delete expired snapshots: - exec_sql(db, NULL, &err, 0, "DELETE FROM \"expired_snapshot\""); + // delete unused snapshots: + exec_sql(db, NULL, &err, 0, "DELETE FROM \"unused_snapshot\""); // check member activity: exec_sql(db, NULL, &err, 0, "SET TRANSACTION ISOLATION LEVEL READ COMMITTED; SELECT \"check_activity\"()"); @@ -274,7 +274,10 @@ } if (res) PQclear(res); - // cleanup and exit: + // delete unused snapshots: + exec_sql(db, NULL, &err, 0, "DELETE FROM \"unused_snapshot\""); + + // cleanup and exit: PQfinish(db); return err;