1
0
Fork 0

make transaction data read-only while iterating over it

This commit is contained in:
jsteemann 2017-02-24 12:25:20 +01:00
parent a14acee48b
commit b02168bdf0
3 changed files with 10 additions and 11 deletions

View File

@ -1336,8 +1336,8 @@ MMFilesWalLogfile* MMFilesLogfileManager::getCollectableLogfile() {
// iterate over all active readers and find their minimum used logfile id
MMFilesWalLogfile::IdType minId = UINT64_MAX;
auto cb = [&minId](TRI_voc_tid_t, TransactionData* data) {
MMFilesWalLogfile::IdType lastWrittenId = static_cast<MMFilesTransactionData*>(data)->lastSealedId;
auto cb = [&minId](TRI_voc_tid_t, TransactionData const* data) {
MMFilesWalLogfile::IdType lastWrittenId = static_cast<MMFilesTransactionData const*>(data)->lastSealedId;
if (lastWrittenId < minId && lastWrittenId != 0) {
minId = lastWrittenId;
@ -1383,8 +1383,8 @@ MMFilesWalLogfile* MMFilesLogfileManager::getRemovableLogfile() {
MMFilesWalLogfile::IdType minId = UINT64_MAX;
// iterate over all active transactions and find their minimum used logfile id
auto cb = [&minId](TRI_voc_tid_t, TransactionData* data) {
MMFilesWalLogfile::IdType lastCollectedId = static_cast<MMFilesTransactionData*>(data)->lastCollectedId;
auto cb = [&minId](TRI_voc_tid_t, TransactionData const* data) {
MMFilesWalLogfile::IdType lastCollectedId = static_cast<MMFilesTransactionData const*>(data)->lastCollectedId;
if (lastCollectedId < minId && lastCollectedId != 0) {
minId = lastCollectedId;
@ -1553,15 +1553,15 @@ MMFilesLogfileManager::runningTransactions() {
MMFilesWalLogfile::IdType lastCollectedId = UINT64_MAX;
MMFilesWalLogfile::IdType lastSealedId = UINT64_MAX;
auto cb = [&count, &lastCollectedId, &lastSealedId](TRI_voc_tid_t, TransactionData* data) {
auto cb = [&count, &lastCollectedId, &lastSealedId](TRI_voc_tid_t, TransactionData const* data) {
++count;
MMFilesWalLogfile::IdType value = static_cast<MMFilesTransactionData*>(data)->lastCollectedId;
MMFilesWalLogfile::IdType value = static_cast<MMFilesTransactionData const*>(data)->lastCollectedId;
if (value < lastCollectedId && value != 0) {
lastCollectedId = value;
}
value = static_cast<MMFilesTransactionData*>(data)->lastSealedId;
value = static_cast<MMFilesTransactionData const*>(data)->lastSealedId;
if (value < lastSealedId && value != 0) {
lastSealedId = value;
}

View File

@ -103,7 +103,7 @@ std::unordered_set<TRI_voc_tid_t> TransactionManager::getFailedTransactions() {
return failedTransactions;
}
void TransactionManager::iterateActiveTransactions(std::function<void(TRI_voc_tid_t, TransactionData*)> const& callback) {
void TransactionManager::iterateActiveTransactions(std::function<void(TRI_voc_tid_t, TransactionData const*)> const& callback) {
WRITE_LOCKER(allTransactionsLocker, _allTransactionsLock);
// iterate over all active transactions

View File

@ -31,8 +31,7 @@
namespace arangodb {
// to be derived by storage engines
struct TransactionData {
};
struct TransactionData {};
class TransactionManager {
static constexpr size_t numBuckets = 16;
@ -59,7 +58,7 @@ class TransactionManager {
void unregisterTransaction(TRI_voc_tid_t transactionId, bool markAsFailed);
// iterate all the active transactions
void iterateActiveTransactions(std::function<void(TRI_voc_tid_t, TransactionData*)> const& callback);
void iterateActiveTransactions(std::function<void(TRI_voc_tid_t, TransactionData const*)> const& callback);
private:
// hashes the transaction id into a bucket