Commit 4491adf1 authored by Giuseppe Lo Presti's avatar Giuseppe Lo Presti
Browse files

Bug #95189: Time discrepencies between disk servers and name servers can lead...

Bug #95189: Time discrepencies between disk servers and name servers can lead to silent data loss on input.

Made the CastorFile.nsOpenTime column NOT NULL and added code to prefill it
at upgrade time. This will be a long operation...
parent 58d8ea01
......@@ -326,7 +326,7 @@ CREATE TABLE CastorFile (fileId INTEGER,
id INTEGER CONSTRAINT PK_CastorFile_Id PRIMARY KEY,
fileClass INTEGER,
tapeStatus INTEGER, -- can be ONTAPE, NOTONTAPE or DISKONLY
nsOpenTime NUMBER) -- timestamp given by the Nameserver at Cns_openx()
nsOpenTime NUMBER CONSTRAINT NN_CastorFile_NsOpenTime NOT NULL) -- timestamp given by the Nameserver at Cns_openx()
INITRANS 50 PCTFREE 50 ENABLE ROW MOVEMENT;
ALTER TABLE CastorFile ADD CONSTRAINT FK_CastorFile_FileClass
FOREIGN KEY (fileClass) REFERENCES FileClass (id)
......
......@@ -18,6 +18,9 @@ BEGIN setObjStatusName('DiskCopy', 'status', 0, 'DISKCOPY_VALID'); END;
DECLARE
remCF INTEGER;
CURSOR cfs IS
SELECT id FROM CastorFile WHERE nsOpenTime IS NULL;
ids "numList";
BEGIN
FOR cf IN (SELECT unique castorFile, status, nbCopies
FROM DiskCopy, CastorFile, FileClass
......@@ -33,6 +36,17 @@ BEGIN
WHERE id = cf.castorFile;
END LOOP;
COMMIT;
-- Update all nsOpenTime values
LOOP
OPEN cfs;
FETCH cfs BULK COLLECT INTO ids LIMIT 10000;
EXIT WHEN ifs.count = 0;
FORALL i IN 1 .. ids.COUNT
UPDATE CastorFile SET nsOpenTime = lastUpdateTime WHERE id = ids(i);
CLOSE cfs;
COMMIT;
END LOOP;
SELECT COUNT(*) INTO remCF FROM CastorFile WHERE tapestatus IS NULL;
XXX cleanup files with no diskcopy ???
......@@ -43,6 +57,8 @@ XXX cleanup files with no diskcopy ???
END;
/
ALTER TABLE CastorFile MODIFY (nsOpenTime CONSTRAINT NN_CastorFile_NsOpenTime NOT NULL);
DROP TRIGGER tr_DiskCopy_Online;
DROP PROCEDURE getDiskCopiesForJob;
DROP PROCEDURE processPrepareRequest;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment