Skip to content
Snippets Groups Projects
Commit d1d70a13 authored by Sebastien Ponce's avatar Sebastien Ponce
Browse files

Fixed bug #98412: Fix cleanup of failed diskcopy when they are too numerous

parent b07d0055
No related branches found
No related tags found
No related merge requests found
...@@ -704,38 +704,36 @@ END; ...@@ -704,38 +704,36 @@ END;
CREATE OR REPLACE PROCEDURE deleteFailedDiskCopies(timeOut IN NUMBER) AS CREATE OR REPLACE PROCEDURE deleteFailedDiskCopies(timeOut IN NUMBER) AS
dcIds "numList"; dcIds "numList";
cfIds "numList"; cfIds "numList";
ct INTEGER;
BEGIN BEGIN
-- select INVALID diskcopies without filesystem (they can exist after a LOOP
-- stageRm that came before the diskcopy had been created on disk) and ALL FAILED -- select INVALID diskcopies without filesystem (they can exist after a
-- ones (coming from failed recalls or failed removals from the GC daemon). -- stageRm that came before the diskcopy had been created on disk) and ALL FAILED
-- Note that we don't select INVALID diskcopies from recreation of files -- ones (coming from failed recalls or failed removals from the GC daemon).
-- because they are taken by the standard GC as they physically exist on disk. -- Note that we don't select INVALID diskcopies from recreation of files
SELECT id -- because they are taken by the standard GC as they physically exist on disk.
BULK COLLECT INTO dcIds -- go only for 1000 at a time and retry if the limit was reached
FROM DiskCopy SELECT id
WHERE (status = 4 OR (status = 7 AND fileSystem = 0)) BULK COLLECT INTO dcIds
AND creationTime < getTime() - timeOut; FROM DiskCopy
SELECT /*+ INDEX(DC PK_DiskCopy_ID) */ UNIQUE castorFile WHERE (status = 4 OR (status = 7 AND fileSystem = 0))
BULK COLLECT INTO cfIds AND creationTime < getTime() - timeOut
FROM DiskCopy DC AND ROWNUM <= 1000;
WHERE id IN (SELECT /*+ CARDINALITY(ids 5) */ * FROM TABLE(dcIds) ids); SELECT /*+ INDEX(DC PK_DiskCopy_ID) */ UNIQUE castorFile
-- drop the DiskCopies BULK COLLECT INTO cfIds
FORALL i IN 1 .. dcIds.COUNT FROM DiskCopy DC
DELETE FROM DiskCopy WHERE id = dcIds(i); WHERE id IN (SELECT /*+ CARDINALITY(ids 5) */ * FROM TABLE(dcIds) ids);
COMMIT; -- drop the DiskCopies
-- maybe delete the CastorFiles if nothing is left for them FORALL i IN 1 .. dcIds.COUNT
ct := 0; DELETE FROM DiskCopy WHERE id = dcIds(i);
FOR i IN 1 .. cfIds.COUNT LOOP COMMIT;
deleteCastorFile(cfIds(i)); -- maybe delete the CastorFiles if nothing is left for them
ct := ct + 1; FOR i IN 1 .. cfIds.COUNT LOOP
IF ct = 1000 THEN deleteCastorFile(cfIds(i));
-- commit every 1000, don't pause END LOOP;
ct := 0; COMMIT;
COMMIT; -- exit if we did less than 1000
END IF; IF dcIds.COUNT < 1000 THEN EXIT; END IF;
END LOOP; END LOOP;
COMMIT;
END; END;
/ /
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment