Commit 87b4e108 authored by Eric Cano's avatar Eric Cano
Browse files

Fixed wrong updating of the max FSeq for the tape. Now done per-file instead...

Fixed wrong updating of the max FSeq for the tape. Now done per-file instead of at the end of the session.
parent 4e0f51ca
......@@ -51,8 +51,7 @@ void cta::ArchiveJob::complete() {
throw ChecksumNotSet("In cta::ArchiveJob::complete(): checksum not set");
// We are good to go to record the data in the persistent storage.
// First make the file safe on tape.
m_dbJob->bumpUpTapeFileCount(nameServerTapeFile.tapeFileLocation.vid,
nameServerTapeFile.tapeFileLocation.fSeq);
m_dbJob->bumpUpTapeFileCount(nameServerTapeFile.tapeFileLocation.fSeq);
// Now record the data in the archiveNS. The checksum will be validated if already
// present, of inserted if not.
m_ns.addTapeFile(SecurityIdentity(UserIdentity(std::numeric_limits<uint32_t>::max(),
......
......@@ -1385,7 +1385,7 @@ auto OStoreDB::ArchiveMount::getNextJob() -> std::unique_ptr<SchedulerDatabase::
// If the request is not around anymore, we will just move the the next
// Prepare the return value
std::unique_ptr<OStoreDB::ArchiveJob> privateRet(new OStoreDB::ArchiveJob(
jl.front().address, m_objectStore, m_agent));
jl.front().address, m_objectStore, m_agent, *this));
privateRet->m_copyNb = jl.front().copyNb;
objectstore::ScopedExclusiveLock atfrl;
try {
......@@ -1454,7 +1454,6 @@ void OStoreDB::ArchiveMount::complete(time_t completionTime) {
objectstore::ScopedExclusiveLock tl(t);
tpl.release();
t.fetch();
t.setLastFseq(nbFilesCurrentlyOnTape);
t.releaseBusy();
t.commit();
objectstore::ScopedExclusiveLock agl(m_agent);
......@@ -1464,8 +1463,8 @@ void OStoreDB::ArchiveMount::complete(time_t completionTime) {
}
OStoreDB::ArchiveJob::ArchiveJob(const std::string& jobAddress,
objectstore::Backend& os, objectstore::Agent& ag): m_jobOwned(false),
m_objectStore(os), m_agent(ag), m_atfr(jobAddress, os) {}
objectstore::Backend& os, objectstore::Agent& ag, ArchiveMount & am): m_jobOwned(false),
m_objectStore(os), m_agent(ag), m_atfr(jobAddress, os), m_archiveMount(am) {}
OStoreDB::RetrieveMount::RetrieveMount(objectstore::Backend& os, objectstore::Agent& a):
m_objectStore(os), m_agent(a) { }
......@@ -1622,6 +1621,31 @@ void OStoreDB::ArchiveMount::setDriveStatus(cta::DriveStatus status, time_t comp
dr.commit();
}
void OStoreDB::ArchiveMount::setTapeMaxFileCount(uint64_t maxFileId) {
// Update the max file count for the tape
objectstore::RootEntry re(m_objectStore);
objectstore::ScopedSharedLock rel(re);
re.fetch();
// Find the tape and update it.
objectstore::TapePool tp (re.getTapePoolAddress(mountInfo.tapePool), m_objectStore);
rel.release();
objectstore::ScopedSharedLock tpl(tp);
tp.fetch();
objectstore::Tape t(tp.getTapeAddress(mountInfo.vid), m_objectStore);
objectstore::ScopedExclusiveLock tl(t);
tpl.release();
t.fetch();
// We should never set the max file to the same value or lower (it should)
// always strictly go up.
if (t.getLastFseq() >= maxFileId) {
throw MaxFSeqNotGoingUp("In OStoreDB::ArchiveMount::setTapeMaxFileCount: trying to set maxFSeq to lower or equal value to before");
}
t.setLastFseq(maxFileId);
t.releaseBusy();
t.commit();
}
void OStoreDB::ArchiveJob::fail() {
if (!m_jobOwned)
throw JobNowOwned("In OStoreDB::ArchiveJob::fail: cannot fail a job not owned");
......@@ -1665,7 +1689,8 @@ void OStoreDB::ArchiveJob::fail() {
throw NoSuchTapePool("In OStoreDB::ArchiveJob::fail(): could not find the tape pool");
}
void OStoreDB::ArchiveJob::bumpUpTapeFileCount(const std::string& vid, uint64_t newFileCount) {
void OStoreDB::ArchiveJob::bumpUpTapeFileCount(uint64_t newFileCount) {
m_archiveMount.setTapeMaxFileCount(newFileCount);
}
......
......@@ -81,10 +81,12 @@ public:
objectstore::Backend & m_objectStore;
objectstore::Agent & m_agent;
public:
CTA_GENERATE_EXCEPTION_CLASS(MaxFSeqNotGoingUp);
virtual const MountInfo & getMountInfo();
virtual std::unique_ptr<ArchiveJob> getNextJob();
virtual void complete(time_t completionTime);
virtual void setDriveStatus(cta::DriveStatus status, time_t completionTime);
virtual void setTapeMaxFileCount(uint64_t maxFileId);
};
/* === Archive Job Handling =============================================== */
......@@ -95,10 +97,11 @@ public:
CTA_GENERATE_EXCEPTION_CLASS(NoSuchJob);
virtual void succeed();
virtual void fail();
virtual void bumpUpTapeFileCount(const std::string& vid, uint64_t newFileCount);
virtual void bumpUpTapeFileCount(uint64_t newFileCount);
virtual ~ArchiveJob();
private:
ArchiveJob(const std::string &, objectstore::Backend &, objectstore::Agent &);
ArchiveJob(const std::string &, objectstore::Backend &,
objectstore::Agent &, ArchiveMount &);
bool m_jobOwned;
uint16_t m_copyNb;
uint64_t m_mountId;
......@@ -106,6 +109,7 @@ public:
objectstore::Backend & m_objectStore;
objectstore::Agent & m_agent;
objectstore::ArchiveToFileRequest m_atfr;
ArchiveMount & m_archiveMount;
};
/* === Retrieve Mount handling ============================================ */
......
......@@ -186,7 +186,7 @@ public:
cta::NameServerTapeFile nameServerTapeFile;
virtual void succeed() = 0;
virtual void fail() = 0;
virtual void bumpUpTapeFileCount(const std::string & vid, uint64_t newFileCount) = 0;
virtual void bumpUpTapeFileCount(uint64_t newFileCount) = 0;
virtual ~ArchiveJob() {}
};
......
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