Mercurial > dive4elements > framework
changeset 195:63f555bbdbc0
Fix a foreign key constraint violation when deleting outdated artifacts.
artifacts/trunk@1425 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 08 Mar 2011 10:35:40 +0000 |
parents | fde2f193e846 |
children | 171b6200d26d |
files | ChangeLog artifact-database/src/main/resources/sql/org-h2-driver.properties artifact-database/src/main/resources/sql/org-postgresql-driver.properties |
diffstat | 3 files changed, 19 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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 <sascha.teichmann@intevation.de> + + * 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 <sascha.teichmann@intevation.de> * artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java:
--- 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 = ?
--- 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