# HG changeset patch # User Sascha L. Teichmann # Date 1299580540 0 # Node ID 63f555bbdbc0d3f19b8506444f79cbda21427e19 # Parent fde2f193e846692d9cd303a0d0bfa158e9ed147b Fix a foreign key constraint violation when deleting outdated artifacts. artifacts/trunk@1425 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r fde2f193e846 -r 63f555bbdbc0 ChangeLog --- a/ChangeLog Tue Mar 08 10:25:51 2011 +0000 +++ b/ChangeLog Tue Mar 08 10:35:40 2011 +0000 @@ -1,3 +1,16 @@ +2011-03-08 Sascha L. Teichmann + + * artifact-database/src/main/resources/sql/org-h2-driver.properties + artifact-database/src/main/resources/sql/org-postgresql-driver.properties: + The cleaner job is scanning the artifact database for outdated artifacts. + artifacts are aging independent from the collections they are in. + So the cleaner wants to delete artifacts that are still in + collections which violates a foreign key constraint and renders + the cleaner inop because this condition remains. + + The fix prevents this behavior by only deleting artifacts that + are not in a collection. + 2011-03-08 Sascha L. Teichmann * artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java: diff -r fde2f193e846 -r 63f555bbdbc0 artifact-database/src/main/resources/sql/org-h2-driver.properties --- a/artifact-database/src/main/resources/sql/org-h2-driver.properties Tue Mar 08 10:25:51 2011 +0000 +++ b/artifact-database/src/main/resources/sql/org-h2-driver.properties Tue Mar 08 10:35:40 2011 +0000 @@ -10,7 +10,9 @@ artifacts.touch=UPDATE artifacts SET last_access = CURRENT_TIMESTAMP WHERE id = ? artifacts.outdated=SELECT id, factory, data FROM artifacts WHERE ttl IS NOT NULL \ - AND DATEDIFF('MILLISECOND', last_access, CURRENT_TIMESTAMP) > ttl LIMIT 50 + AND DATEDIFF('MILLISECOND', last_access, CURRENT_TIMESTAMP) > ttl \ + AND id NOT IN (SELECT UNIQUE artifact_id FROM collection_items) \ + LIMIT 50 artifacts.select.gid=SELECT id, last_access, ttl, factory, data FROM artifacts WHERE gid = ? diff -r fde2f193e846 -r 63f555bbdbc0 artifact-database/src/main/resources/sql/org-postgresql-driver.properties --- a/artifact-database/src/main/resources/sql/org-postgresql-driver.properties Tue Mar 08 10:25:51 2011 +0000 +++ b/artifact-database/src/main/resources/sql/org-postgresql-driver.properties Tue Mar 08 10:35:40 2011 +0000 @@ -10,7 +10,9 @@ artifacts.touch=UPDATE artifacts SET last_access = CURRENT_TIMESTAMP WHERE id = ? artifacts.outdated=SELECT id, factory, data FROM artifacts WHERE ttl IS NOT NULL \ - AND CURRENT_TIMESTAMP - last_access > (ttl || ' microseconds')::interval LIMIT 50 + AND CURRENT_TIMESTAMP - last_access > (ttl || ' microseconds')::interval \ + AND id NOT IN (SELECT UNIQUE artifact_id FROM collection_items) \ + LIMIT 50 artifacts.select.gid=SELECT id, last_access, ttl, factory, data FROM artifacts WHERE gid = ?::uuid