1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-12-18 13:54:11 +03:00

Fixed a possible size mismatch in Sync, which could be caused

by a truncated logical file.
This commit is contained in:
Patrick LeBlanc
2019-05-23 13:41:24 -05:00
parent 51d06f1d93
commit a32e6c7bb4

View File

@@ -340,7 +340,7 @@ void Synchronizer::synchronizeDelete(const string &sourceFile, list<string>::ite
ScopedWriteLock s(ioc, sourceFile); ScopedWriteLock s(ioc, sourceFile);
cs->deleteObject(*it); cs->deleteObject(*it);
// delete any pending jobs for *it. // delete any pending jobs for *it. There shouldn't be any, this is out of pure paranoia.
boost::unique_lock<boost::recursive_mutex> sc(mutex); boost::unique_lock<boost::recursive_mutex> sc(mutex);
pendingOps.erase(*it); pendingOps.erase(*it);
} }
@@ -414,17 +414,17 @@ void Synchronizer::synchronizeWithJournal(const string &sourceFile, list<string>
} }
throw runtime_error(string("Synchronizer: getObject() failed: ") + strerror_r(errno, buf, 80)); throw runtime_error(string("Synchronizer: getObject() failed: ") + strerror_r(errno, buf, 80));
} }
assert(size <= mdEntry.length);
//TODO!! This sucks. Need a way to pass in a larger array to cloud storage, and also have it not //TODO!! This sucks. Need a way to pass in a larger array to cloud storage, and also have it not
// do any add'l alloc'ing or copying // do any add'l alloc'ing or copying
if (size < mdEntry.length) if (size < mdEntry.length)
{ {
boost::shared_array<uint8_t> tmp(new uint8_t[mdEntry.length]()); boost::shared_array<uint8_t> tmp(new uint8_t[mdEntry.length]());
memcpy(tmp.get(), data.get(), size); memcpy(tmp.get(), data.get(), size);
memset(&tmp[size], 0, mdEntry.length - size); // prob not necessary outside of testing memset(&tmp[size], 0, mdEntry.length - size);
data.swap(tmp); data.swap(tmp);
size = mdEntry.length;
} }
size = mdEntry.length; // reset length. Using the metadata as a source of truth (truncation), not actual file length.
err = ioc->mergeJournalInMem(data, size, journalName.c_str()); err = ioc->mergeJournalInMem(data, size, journalName.c_str());
if (err) if (err)