summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKim van der Riet <kpvdr@apache.org>2014-08-25 20:25:09 +0000
committerKim van der Riet <kpvdr@apache.org>2014-08-25 20:25:09 +0000
commit1c48b7586366e0fc2ae09454d2aec1ad313c3e90 (patch)
treed266e3cee9b2a6560368af3289c3e740ffb11188
parentee9f86e5efbc8d317e1197adae7d571b3c5a9dc3 (diff)
downloadqpid-python-1c48b7586366e0fc2ae09454d2aec1ad313c3e90.tar.gz
QPID-6043: Add a configuration option to overwrite files returned to the EFP
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1620426 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--cpp/src/qpid/linearstore/ISSUES48
-rw-r--r--cpp/src/qpid/linearstore/MessageStoreImpl.cpp19
-rw-r--r--cpp/src/qpid/linearstore/MessageStoreImpl.h7
-rw-r--r--cpp/src/qpid/linearstore/journal/EmptyFilePool.cpp30
-rw-r--r--cpp/src/qpid/linearstore/journal/EmptyFilePool.h1
-rw-r--r--cpp/src/qpid/linearstore/journal/EmptyFilePoolManager.cpp4
-rw-r--r--cpp/src/qpid/linearstore/journal/EmptyFilePoolManager.h2
-rw-r--r--cpp/src/qpid/linearstore/journal/EmptyFilePoolPartition.cpp6
-rw-r--r--cpp/src/qpid/linearstore/journal/EmptyFilePoolPartition.h3
9 files changed, 79 insertions, 41 deletions
diff --git a/cpp/src/qpid/linearstore/ISSUES b/cpp/src/qpid/linearstore/ISSUES
index 3e81575bae..2866e6c58d 100644
--- a/cpp/src/qpid/linearstore/ISSUES
+++ b/cpp/src/qpid/linearstore/ISSUES
@@ -48,8 +48,7 @@ Current/pending:
- 1088944 [Linearstore] store does not return all files to EFP after purging big queue
- 1078937 [linearstore] Installation and tests for new store analysis tool qpid-qls-analyze
svn r.1596633 2014-05-21: Modified to run from installed location
-# 5948 1121660 [linearstore] Broker restart failure with durable topic using non-durable exchange
-* - 1066256 [LinearStore] changing efp size after using store broke the new durable nodes creation
+* 6043 1066256 [LinearStore] changing efp size after using store broke the new durable nodes creation
* - 1089652 [RFE]: Configuration option for linear store to delete the used journal files instead of recycling them.
@@ -127,7 +126,7 @@ NO-JIRA - Added missing Apache copyright/license text
* jexception 0x0103 wmgr::get_events() threw JERR__AIO: AIO error. (AIO write operation failed: Invalid argument (-22) [pg=0 size=8192 offset=4096 fh=22])
5767 1098118 [linearstore] broker segfaults when recovering journal file with damaged header
svn r.1596509 2014-05-21 Proposed solution (committed by pmoravec)
- svn r.1599243 2014-06-02 Further fix
+ svn r.1599243 2014-06-02 Solution to additional case of file header corruption
5924 1124906 [linearstore] Qpidd Will Not Start with Large Number of Queues
svn r.1614665 2014-07-30 Proposed solution
5948 1121660 [AMQP 1.0] Broker restart failure with durable topic using non-durable exchange
@@ -141,35 +140,36 @@ In order to port the linearstore changes from trunk to a branch, the following s
no. svn r Q-JIRA RHBZ Date Alt Committer
--- ------- ------- -------- ---------- -------------
- 1. 1545563 5357 1052518 2013-11-26
- 2. 1547601 5358 1052727 2013-12-03
- 3. 1547641 5387 1036071 2013-12-03
- 4. 1547921 5388 1035802 2013-12-04
- 5. 1551304 NO-JIRA - 2013-12-16 (aconway)
- 6. 1551361 5425 1052445 2013-12-16
- 7. 1552772 5442 1039949 2013-12-20
- 8. 1553148 5444 1052775 2013-12-23
+ 1. 1545563 5357 1052518 2013-11-26 0.22-mrg
+ 2. 1547601 5358 1052727 2013-12-03 0.22-mrg
+ 3. 1547641 5387 1036071 2013-12-03 0.22-mrg
+ 4. 1547921 5388 1035802 2013-12-04 0.22-mrg
+ 5. 1551304 NO-JIRA - 2013-12-16 0.22-mrg (aconway)
+ 6. 1551361 5425 1052445 2013-12-16 0.22-mrg
+ 7. 1552772 5442 1039949 2013-12-20 0.22-mrg
+ 8. 1553148 5444 1052775 2013-12-23 0.22-mrg
9. 1556888 5362 - 2014-01-09
-10. 1556892 5460 1051097 2014-01-09
-11. 1557620 5473 1051924 2014-01-12
-12. 1558589 5483 - 2014-01-15
-13. 1558592 5484 1035843 2014-01-15
-14. 1558913 5487 1054448 2014-01-16
+10. 1556892 5460 1051097 2014-01-09 0.22-mrg
+11. 1557620 5473 1051924 2014-01-12 0.22-mrg
+12. 1558589 5483 - 2014-01-15 0.22-mrg
+13. 1558592 5484 1035843 2014-01-15 0.22-mrg
+14. 1558913 5487 1054448 2014-01-16 0.22-mrg
15. 1560530 5362 - 2014-01-22
16. 1561848 5362 - 2014-01-27
17. 1564808 5362 - 2014-02-05
-18. 1564877 5480 1053749 2014-02-05
+18. 1564877 5480 1053749 2014-02-05 0.22-mrg
19. 1564893 5361 - 2014-02-05
20. 1564935 5361 - 2014-02-05
-21. 1574513 5603 1063700 2014-03-05
-22. 1575009 5607 1064181 2014-03-06
-23. 1578899 5362 - 2014-03-18
-24. 1582730 5651 - 2014-03-28 (pmoravec)
+21. 1574513 5603 1063700 2014-03-05 0.22-mrg
+22. 1575009 5607 1064181 2014-03-06 0.22-mrg
+23. 1578899 5362 - 2014-03-18 parts in 0.22-mrg
+24. 1582730 5651 - 2014-03-28 0.22-mrg (pmoravec)
25. 1583778 5362 - 2014-04-01
26. 1584379 5661 - 2014-04-03
-27. 1594215 5750 1078142 2014-05-13
-28. 1596509 5767 1098118 2014-05-21 (pmoravec)
-29. 1596633 NO-JIRA 1078937 2014-05-21
+27. 1594215 5750 1078142 2014-05-13 0.22-mrg
+28. 1596509 5767 1098118 2014-05-21 0.22-mrg (pmoravec)
+29. 1596633 NO-JIRA 1078937 2014-05-21 (includes tools install update)
+30. 1599243 5767 1098118 2014-06-02 0.22-mrg
30. 1599243 5767 1098118 2014-06-02
31. 1614665 5924 1124906 2014-07-30
diff --git a/cpp/src/qpid/linearstore/MessageStoreImpl.cpp b/cpp/src/qpid/linearstore/MessageStoreImpl.cpp
index 5431862d6a..8e4c6e38e1 100644
--- a/cpp/src/qpid/linearstore/MessageStoreImpl.cpp
+++ b/cpp/src/qpid/linearstore/MessageStoreImpl.cpp
@@ -54,7 +54,7 @@ qpid::sys::Mutex TxnCtxt::globalSerialiser;
MessageStoreImpl::MessageStoreImpl(qpid::broker::Broker* broker_, const char* envpath_) :
defaultEfpPartitionNumber(0),
defaultEfpFileSize_kib(0),
- truncateFlag(false),
+ overwriteBeforeReturnFlag(false),
wCachePgSizeSblks(0),
wCacheNumPages(0),
tplWCachePgSizeSblks(0),
@@ -174,7 +174,8 @@ bool MessageStoreImpl::init(const qpid::Options* options_)
uint32_t tplJrnlWrCachePageSizeKib = chkJrnlWrPageCacheSize(opts->tplWCachePageSizeKib, "tpl-wcache-page-size");
// Pass option values to init()
- return init(opts->storeDir, efpPartition, efpFilePoolSize_kib, opts->truncateFlag, jrnlWrCachePageSizeKib, tplJrnlWrCachePageSizeKib);
+ return init(opts->storeDir, efpPartition, efpFilePoolSize_kib, opts->truncateFlag, jrnlWrCachePageSizeKib,
+ tplJrnlWrCachePageSizeKib, opts->overwriteBeforeReturnFlag);
}
// These params, taken from options, are assumed to be correct and verified
@@ -183,11 +184,13 @@ bool MessageStoreImpl::init(const std::string& storeDir_,
qpid::linearstore::journal::efpDataSize_kib_t efpFileSize_kib_,
const bool truncateFlag_,
uint32_t wCachePageSizeKib_,
- uint32_t tplWCachePageSizeKib_)
+ uint32_t tplWCachePageSizeKib_,
+ const bool overwriteBeforeReturnFlag_)
{
if (isInit) return true;
// Set geometry members (converting to correct units where req'd)
+ overwriteBeforeReturnFlag = overwriteBeforeReturnFlag_;
defaultEfpPartitionNumber = efpPartition_;
defaultEfpFileSize_kib = efpFileSize_kib_;
wCachePgSizeSblks = wCachePageSizeKib_ / QLS_SBLK_SIZE_KIB; // convert from KiB to number sblks
@@ -210,6 +213,7 @@ bool MessageStoreImpl::init(const std::string& storeDir_,
QLS_LOG(info, "> TPL number of write cache pages: " << tplWCacheNumPages);
QLS_LOG(info, "> EFP partition: " << defaultEfpPartitionNumber);
QLS_LOG(info, "> EFP file size pool: " << defaultEfpFileSize_kib << " (KiB)");
+ QLS_LOG(info, "> Overwrite before return to EFP: " << (overwriteBeforeReturnFlag?"True":"False"));
return isInit;
}
@@ -291,6 +295,7 @@ void MessageStoreImpl::init()
efpMgr.reset(new qpid::linearstore::journal::EmptyFilePoolManager(getStoreTopLevelDir(),
defaultEfpPartitionNumber,
defaultEfpFileSize_kib,
+ overwriteBeforeReturnFlag,
jrnlLog));
efpMgr->findEfpPartitions();
}
@@ -1522,7 +1527,8 @@ MessageStoreImpl::StoreOptions::StoreOptions(const std::string& name_) :
wCachePageSizeKib(defWCachePageSizeKib),
tplWCachePageSizeKib(defTplWCachePageSizeKib),
efpPartition(defEfpPartition),
- efpFileSizeKib(defEfpFileSizeKib)
+ efpFileSizeKib(defEfpFileSizeKib),
+ overwriteBeforeReturnFlag(defOverwriteBeforeReturnFlag)
{
addOptions()
("store-dir", qpid::optValue(storeDir, "DIR"),
@@ -1543,6 +1549,11 @@ MessageStoreImpl::StoreOptions::StoreOptions(const std::string& name_) :
"Empty File Pool partition to use for finding empty journal files")
("efp-file-size", qpid::optValue(efpFileSizeKib, "N"),
"Empty File Pool file size in KiB to use for journal files. Must be a multiple of 4 KiB.")
+ ("overwrite-before-return", qpid::optValue(overwriteBeforeReturnFlag, "yes|no"),
+ "If yes|true|1, will overwrite each store file with zeros before returning "
+ "it to the Empty File Pool. When not in use (the default), then old message data remains "
+ "in the file, but is overwritten on next use. This option should only be used where security "
+ "considerations justify it as it makes the store somewhat slower.")
;
}
diff --git a/cpp/src/qpid/linearstore/MessageStoreImpl.h b/cpp/src/qpid/linearstore/MessageStoreImpl.h
index 7fd1b89660..51e02ff395 100644
--- a/cpp/src/qpid/linearstore/MessageStoreImpl.h
+++ b/cpp/src/qpid/linearstore/MessageStoreImpl.h
@@ -82,6 +82,7 @@ class MessageStoreImpl : public qpid::broker::MessageStore, public qpid::managem
uint32_t tplWCachePageSizeKib;
uint16_t efpPartition;
uint64_t efpFileSizeKib;
+ bool overwriteBeforeReturnFlag;
};
protected:
@@ -101,6 +102,7 @@ class MessageStoreImpl : public qpid::broker::MessageStore, public qpid::managem
static const uint32_t defTplWCachePageSizeKib = defWCachePageSizeKib / 8;
static const uint16_t defEfpPartition = 1;
static const uint64_t defEfpFileSizeKib = 512 * QLS_SBLK_SIZE_KIB;
+ static const bool defOverwriteBeforeReturnFlag = false;
static const std::string storeTopLevelDir;
static qpid::sys::Duration defJournalGetEventsTimeout;
@@ -129,7 +131,7 @@ class MessageStoreImpl : public qpid::broker::MessageStore, public qpid::managem
std::string storeDir;
qpid::linearstore::journal::efpPartitionNumber_t defaultEfpPartitionNumber;
qpid::linearstore::journal::efpDataSize_kib_t defaultEfpFileSize_kib;
- bool truncateFlag;
+ bool overwriteBeforeReturnFlag;
uint32_t wCachePgSizeSblks;
uint16_t wCacheNumPages;
uint32_t tplWCachePgSizeSblks;
@@ -252,7 +254,8 @@ class MessageStoreImpl : public qpid::broker::MessageStore, public qpid::managem
qpid::linearstore::journal::efpDataSize_kib_t efpFileSizeKib = defEfpFileSizeKib,
const bool truncateFlag = false,
uint32_t wCachePageSize = defWCachePageSizeKib,
- uint32_t tplWCachePageSize = defTplWCachePageSizeKib);
+ uint32_t tplWCachePageSize = defTplWCachePageSizeKib,
+ const bool overwriteBeforeReturnFlag_ = false);
void truncateInit();
diff --git a/cpp/src/qpid/linearstore/journal/EmptyFilePool.cpp b/cpp/src/qpid/linearstore/journal/EmptyFilePool.cpp
index fafaf0b612..4ad68d9a3b 100644
--- a/cpp/src/qpid/linearstore/journal/EmptyFilePool.cpp
+++ b/cpp/src/qpid/linearstore/journal/EmptyFilePool.cpp
@@ -132,6 +132,9 @@ void EmptyFilePool::returnEmptyFile(const std::string& fqSrcFile) {
}
}
resetEmptyFileHeader(emptyFileName);
+ if (partitionPtr_->getOverwriteBeforeReturnFlag()) {
+ overwriteFileContents(emptyFileName);
+ }
pushEmptyFile(emptyFileName);
}
@@ -171,28 +174,35 @@ efpDataSize_kib_t EmptyFilePool::dataSizeFromDirName_kib(const std::string& dirN
// --- protected functions ---
void EmptyFilePool::createEmptyFile() {
+ std::string efpfn = getEfpFileName();
+ if (overwriteFileContents(efpfn)) {
+ pushEmptyFile(efpfn);
+ }
+}
+
+std::string EmptyFilePool::getEfpFileName() {
+ qpid::types::Uuid uuid(true);
+ std::ostringstream oss;
+ oss << efpDirectory_ << "/" << uuid << QLS_JRNL_FILE_EXTENSION;
+ return oss.str();
+}
+
+bool EmptyFilePool::overwriteFileContents(const std::string& fqFileName) {
::file_hdr_t fh;
::file_hdr_create(&fh, QLS_FILE_MAGIC, QLS_JRNL_VERSION, QLS_JRNL_FHDR_RES_SIZE_SBLKS, partitionPtr_->getPartitionNumber(), efpDataSize_kib_);
- std::string efpfn = getEfpFileName();
- std::ofstream ofs(efpfn.c_str(), std::ofstream::out | std::ofstream::binary);
+ std::ofstream ofs(fqFileName.c_str(), std::ofstream::out | std::ofstream::binary);
if (ofs.good()) {
ofs.write((char*)&fh, sizeof(::file_hdr_t));
uint64_t rem = ((efpDataSize_kib_ + (QLS_JRNL_FHDR_RES_SIZE_SBLKS * QLS_SBLK_SIZE_KIB)) * 1024) - sizeof(::file_hdr_t);
while (rem--)
ofs.put('\0');
ofs.close();
- pushEmptyFile(efpfn);
+ return true;
//std::cout << "WARNING: EFP " << efpDirectory << " is empty - created new journal file " << efpfn.substr(efpfn.rfind('/') + 1) << " on the fly" << std::endl; // DEBUG
} else {
//std::cerr << "ERROR: Unable to open file \"" << efpfn << "\"" << std::endl; // DEBUG
}
-}
-
-std::string EmptyFilePool::getEfpFileName() {
- qpid::types::Uuid uuid(true);
- std::ostringstream oss;
- oss << efpDirectory_ << "/" << uuid << QLS_JRNL_FILE_EXTENSION;
- return oss.str();
+ return false;
}
std::string EmptyFilePool::popEmptyFile() {
diff --git a/cpp/src/qpid/linearstore/journal/EmptyFilePool.h b/cpp/src/qpid/linearstore/journal/EmptyFilePool.h
index 5751c9d180..3a2c93f769 100644
--- a/cpp/src/qpid/linearstore/journal/EmptyFilePool.h
+++ b/cpp/src/qpid/linearstore/journal/EmptyFilePool.h
@@ -83,6 +83,7 @@ protected:
void createEmptyFile();
std::string getEfpFileName();
std::string popEmptyFile();
+ bool overwriteFileContents(const std::string& fqFileName);
void pushEmptyFile(const std::string fqFileName);
void resetEmptyFileHeader(const std::string& fqFileName);
bool validateEmptyFile(const std::string& emptyFileName) const;
diff --git a/cpp/src/qpid/linearstore/journal/EmptyFilePoolManager.cpp b/cpp/src/qpid/linearstore/journal/EmptyFilePoolManager.cpp
index cddb582191..e5fd44bd2d 100644
--- a/cpp/src/qpid/linearstore/journal/EmptyFilePoolManager.cpp
+++ b/cpp/src/qpid/linearstore/journal/EmptyFilePoolManager.cpp
@@ -36,10 +36,12 @@ namespace journal {
EmptyFilePoolManager::EmptyFilePoolManager(const std::string& qlsStorePath,
const efpPartitionNumber_t defaultPartitionNumber,
const efpDataSize_kib_t defaultEfpDataSize_kib,
+ const bool overwriteBeforeReturnFlag,
JournalLog& journalLogRef) :
qlsStorePath_(qlsStorePath),
defaultPartitionNumber_(defaultPartitionNumber),
defaultEfpDataSize_kib_(defaultEfpDataSize_kib),
+ overwriteBeforeReturnFlag_(overwriteBeforeReturnFlag),
journalLogRef_(journalLogRef)
{}
@@ -63,7 +65,7 @@ void EmptyFilePoolManager::findEfpPartitions() {
std::string fullDirPath(qlsStorePath_ + "/" + (*i));
EmptyFilePoolPartition* efppp = 0;
try {
- efppp = new EmptyFilePoolPartition(pn, fullDirPath, journalLogRef_);
+ efppp = new EmptyFilePoolPartition(pn, fullDirPath, overwriteBeforeReturnFlag_, journalLogRef_);
{
slock l(partitionMapMutex_);
partitionMap_[pn] = efppp;
diff --git a/cpp/src/qpid/linearstore/journal/EmptyFilePoolManager.h b/cpp/src/qpid/linearstore/journal/EmptyFilePoolManager.h
index fa667f3326..d7d08dcd25 100644
--- a/cpp/src/qpid/linearstore/journal/EmptyFilePoolManager.h
+++ b/cpp/src/qpid/linearstore/journal/EmptyFilePoolManager.h
@@ -45,6 +45,7 @@ protected:
const std::string qlsStorePath_;
const efpPartitionNumber_t defaultPartitionNumber_;
const efpDataSize_kib_t defaultEfpDataSize_kib_;
+ const bool overwriteBeforeReturnFlag_;
JournalLog& journalLogRef_;
partitionMap_t partitionMap_;
smutex partitionMapMutex_;
@@ -53,6 +54,7 @@ public:
EmptyFilePoolManager(const std::string& qlsStorePath_,
const efpPartitionNumber_t defaultPartitionNumber,
const efpDataSize_kib_t defaultEfpDataSize_kib,
+ const bool overwriteBeforeReturnFlag,
JournalLog& journalLogRef_);
virtual ~EmptyFilePoolManager();
diff --git a/cpp/src/qpid/linearstore/journal/EmptyFilePoolPartition.cpp b/cpp/src/qpid/linearstore/journal/EmptyFilePoolPartition.cpp
index bef8d4e788..f80268b0e6 100644
--- a/cpp/src/qpid/linearstore/journal/EmptyFilePoolPartition.cpp
+++ b/cpp/src/qpid/linearstore/journal/EmptyFilePoolPartition.cpp
@@ -37,9 +37,11 @@ const std::string EmptyFilePoolPartition::s_efpTopLevelDir_("efp"); // Sets the
EmptyFilePoolPartition::EmptyFilePoolPartition(const efpPartitionNumber_t partitionNum,
const std::string& partitionDir,
+ const bool overwriteBeforeReturnFlag,
JournalLog& journalLogRef) :
partitionNum_(partitionNum),
partitionDir_(partitionDir),
+ overwriteBeforeReturnFlag_(overwriteBeforeReturnFlag),
journalLogRef_(journalLogRef)
{
validatePartitionDir();
@@ -111,6 +113,10 @@ void EmptyFilePoolPartition::getEmptyFilePoolSizes_kib(std::vector<efpDataSize_k
}
}
+bool EmptyFilePoolPartition::getOverwriteBeforeReturnFlag() const {
+ return overwriteBeforeReturnFlag_;
+}
+
std::string EmptyFilePoolPartition::getPartitionDirectory() const {
return partitionDir_;
}
diff --git a/cpp/src/qpid/linearstore/journal/EmptyFilePoolPartition.h b/cpp/src/qpid/linearstore/journal/EmptyFilePoolPartition.h
index bd338461cb..7eb9f70d52 100644
--- a/cpp/src/qpid/linearstore/journal/EmptyFilePoolPartition.h
+++ b/cpp/src/qpid/linearstore/journal/EmptyFilePoolPartition.h
@@ -46,6 +46,7 @@ protected:
const efpPartitionNumber_t partitionNum_;
const std::string partitionDir_;
+ const bool overwriteBeforeReturnFlag_;
JournalLog& journalLogRef_;
efpMap_t efpMap_;
smutex efpMapMutex_;
@@ -53,6 +54,7 @@ protected:
public:
EmptyFilePoolPartition(const efpPartitionNumber_t partitionNum,
const std::string& partitionDir,
+ const bool overwriteBeforeReturnFlag,
JournalLog& journalLogRef);
virtual ~EmptyFilePoolPartition();
@@ -60,6 +62,7 @@ public:
EmptyFilePool* getEmptyFilePool(const efpDataSize_kib_t efpDataSize_kib);
void getEmptyFilePools(std::vector<EmptyFilePool*>& efpList);
void getEmptyFilePoolSizes_kib(std::vector<efpDataSize_kib_t>& efpDataSizesList) const;
+ bool getOverwriteBeforeReturnFlag() const;
std::string getPartitionDirectory() const;
efpPartitionNumber_t getPartitionNumber() const;