edits
[iotcloud.git] / version2 / src / C / Table.cc
index 15dee7683a05545c1c9f0aea98484ba4a0d114d3..531337cc5336f1c69dac6aed68018b2899355c98 100644 (file)
@@ -1988,6 +1988,7 @@ bool Table::compactArbitrationData() {
        bool gotNewCommit = false;
 
        uint numberToDelete = 1;
+       
        while (numberToDelete < pendingSendArbitrationRounds->size()) {
                ArbitrationRound *round = pendingSendArbitrationRounds->get(pendingSendArbitrationRounds->size() - numberToDelete - 1);
 
@@ -2019,10 +2020,12 @@ bool Table::compactArbitrationData() {
                        newSize += round->getAbortsCount();
 
                        if (newSize > ArbitrationRound_MAX_PARTS) {
-                               // Cant compact since it would be too large
+                               // Can't compact since it would be too large
+                               if (lastRound->getCommit() != newCommit &&
+                                               round->getCommit() != newCommit)
+                                       delete newCommit;
                                break;
                        }
-
                        // Set the new compacted part
                        if (lastRound->getCommit() == newCommit)
                                lastRound->setCommit(NULL);
@@ -2121,7 +2124,6 @@ bool Table::updateCommittedTable() {
        SetIterator<int64_t, Hashtable<int64_t, Commit *> *> *liveit = getKeyIterator(liveCommitsTable);
        while (liveit->hasNext()) {
                int64_t arbitratorId = liveit->next();
-
                // Get all the commits for a specific arbitrator
                Hashtable<int64_t, Commit *> *commitForClientTable = liveCommitsTable->get(arbitratorId);
 
@@ -2146,7 +2148,6 @@ bool Table::updateCommittedTable() {
                for (uint i = 0; i < commitSequenceNumbers->size(); i++) {
                        int64_t commitSequenceNumber = commitSequenceNumbers->get(i);
                        Commit *commit = commitForClientTable->get(commitSequenceNumber);
-
                        // Special processing if a commit is not complete
                        if (!commit->isComplete()) {
                                if (i == (commitSequenceNumbers->size() - 1)) {
@@ -2260,11 +2261,6 @@ bool Table::updateCommittedTable() {
                                SetIterator<KeyValue *, KeyValue *, uintptr_t, 0> *kvit = commit->getKeyValueUpdateSet()->iterator();
                                while (kvit->hasNext()) {
                                        KeyValue *kv = kvit->next();
-                                       printf("Commited KeyValue Table update for %p\n", this);
-                                       kv->getKey()->print();
-                                       printf("\n");
-                                       kv->getValue()->print();
-                                       printf("\n");
                                        committedKeyValueTable->put(kv->getKey(), kv);
                                        liveCommitsByKeyTable->put(kv->getKey(), commit);
                                }