Skip to content
This repository was archived by the owner on Aug 10, 2025. It is now read-only.

Commit 17fe61d

Browse files
author
user
committed
Fixed a few important bugs.
1. Fixes a problem where blcoks with zero tuples were being written out. This could occur when, say 200 blcoks would be queued for eviction, but only 50 blocks worth of data could be evicted. Then it would still evict 150 empty blocks due to an = sign. 2. Fixed a double delete of blockIDs when migrating that caused a problem due to running out of room. 3. Moved the chooseDB selection of AntiCacheDBs to inside the loop of batching evictions. By having it outside of the loop, when a tier would fill, it wouldn't trigger a migration, only a FullBackingStoreException and failure.
1 parent 164f61c commit 17fe61d

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

src/ee/anticache/AntiCacheDB.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ AntiCacheBlock* AntiCacheDB::getLRUBlock() {
8282
} else {
8383
lru_block_id = m_block_lru.front();
8484
lru_block = readBlock(lru_block_id);
85-
m_totalBlocks--;
85+
//m_totalBlocks--;
8686
return lru_block;
8787
}
8888
}

src/ee/anticache/AntiCacheEvictionManager.cpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -549,11 +549,7 @@ bool AntiCacheEvictionManager::evictBlockToDisk(PersistentTable *table, const lo
549549
VOLT_DEBUG("%s Table Schema:\n%s",
550550
evictedTable->name().c_str(), evictedTable->schema()->debug().c_str());
551551

552-
// get the AntiCacheDB instance from the executorContext
553-
// For now use the single AntiCacheDB from PersistentTable but in the future, this
554-
// method to get the AntiCacheDB will have to choose which AntiCacheDB from to
555-
// evict to
556-
AntiCacheDB* antiCacheDB = table->getAntiCacheDB(chooseDB(block_size, m_migrate));
552+
AntiCacheDB* antiCacheDB;
557553
int tuple_length = -1;
558554
bool needs_flush = false;
559555

@@ -571,6 +567,12 @@ bool AntiCacheEvictionManager::evictBlockToDisk(PersistentTable *table, const lo
571567
for(int i = 0; i < num_blocks; i++)
572568
{
573569

570+
// get the AntiCacheDB instance from the executorContext
571+
// For now use the single AntiCacheDB from PersistentTable but in the future, this
572+
// method to get the AntiCacheDB will have to choose which AntiCacheDB from to
573+
// evict to
574+
antiCacheDB = table->getAntiCacheDB(chooseDB(block_size, m_migrate));
575+
574576
// get the LS16B and send that to the antiCacheDB
575577
uint16_t _block_id = antiCacheDB->nextBlockId();
576578

@@ -661,7 +663,7 @@ bool AntiCacheEvictionManager::evictBlockToDisk(PersistentTable *table, const lo
661663
table->name().c_str(), num_tuples_evicted);
662664

663665
// Only write out a bock if there are tuples in it
664-
if (num_tuples_evicted >= 0) {
666+
if (num_tuples_evicted > 0) {
665667
std::vector<int> numTuples;
666668
numTuples.push_back(num_tuples_evicted);
667669
block.writeHeader(numTuples);
@@ -686,6 +688,7 @@ bool AntiCacheEvictionManager::evictBlockToDisk(PersistentTable *table, const lo
686688
// TODO: make this look like
687689
// block.flush();
688690
// antiCacheDB->writeBlock(block);
691+
VOLT_DEBUG("about to write block %x to acid %d", _block_id, antiCacheDB->getACID());
689692
antiCacheDB->writeBlock(table->name(),
690693
_block_id,
691694
num_tuples_evicted,
@@ -696,7 +699,7 @@ bool AntiCacheEvictionManager::evictBlockToDisk(PersistentTable *table, const lo
696699

697700
bool reused = table->removeUnevictedBlockID(block_id);
698701
if (reused) {
699-
VOLT_INFO("Reusing block_id 0x%x, should be safe", block_id);
702+
VOLT_DEBUG("Reusing block_id 0x%x, should be safe", block_id);
700703
} else {
701704
VOLT_DEBUG("First time block_id 0x%x has been used", block_id);
702705
}
@@ -781,7 +784,7 @@ bool AntiCacheEvictionManager::evictBlockToDiskInBatch(PersistentTable *table, P
781784
// evictedTable->name().c_str(), evictedTable->schema()->debug().c_str());
782785

783786
// get the AntiCacheDB instance from the executorContext
784-
AntiCacheDB* antiCacheDB = table->getAntiCacheDB(chooseDB(block_size, m_migrate));
787+
AntiCacheDB* antiCacheDB;
785788
int tuple_length = -1;
786789
bool needs_flush = false;
787790

@@ -822,6 +825,7 @@ bool AntiCacheEvictionManager::evictBlockToDiskInBatch(PersistentTable *table, P
822825
// VOLT_INFO("Printing child's LRU chain");
823826
// this->printLRUChain(childTable, 4, true);
824827
// get a unique block id from the executorContext
828+
antiCacheDB = table->getAntiCacheDB(chooseDB(block_size, m_migrate));
825829
uint16_t _block_id = antiCacheDB->nextBlockId();
826830
// find out whether this tier blocks and set a flag (bit 19)
827831
// then shift 3b for the ACID (8 levels)
@@ -1343,6 +1347,7 @@ int32_t AntiCacheEvictionManager::migrateBlock(int32_t block_id, AntiCacheDB* ds
13431347
int32_t new_block_id = 0;
13441348

13451349
if (dstDB->getFreeBlocks() == 0) {
1350+
VOLT_WARN("Our destination is full!");
13461351
throw FullBackingStoreException((uint32_t)block_id, (uint32_t)dstDB->getACID());
13471352
}
13481353

@@ -1423,7 +1428,7 @@ int32_t AntiCacheEvictionManager::migrateLRUBlock(AntiCacheDB* srcDB, AntiCacheD
14231428
return (int32_t) _new_block_id;
14241429
}
14251430

1426-
1431+
VOLT_DEBUG("migrating LRU block");
14271432
AntiCacheBlock* block = srcDB->getLRUBlock();
14281433
int16_t _block_id = block->getBlockId();
14291434
int32_t block_id = (int32_t)_block_id;
@@ -1467,7 +1472,7 @@ int32_t AntiCacheEvictionManager::migrateLRUBlock(AntiCacheDB* srcDB, AntiCacheD
14671472
VOLT_TRACE("Updating tuple blockid from %8x to %8x", block_id, new_block_id);
14681473
}
14691474
}
1470-
VOLT_DEBUG("updated %u migrated tuples [#%8x -> #%8x]", updated, block_id, new_block_id);
1475+
VOLT_INFO("updated %u migrated tuples [#%8x -> #%8x]", updated, block_id, new_block_id);
14711476
} else {
14721477
VOLT_WARN("No evicted table! If this is an EE test, shouldn't be a problem");
14731478
}

src/ee/anticache/NVMAntiCacheDB.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ void NVMAntiCacheDB::writeBlock(const std::string tableName,
196196
const char* data,
197197
const long size) {
198198

199+
VOLT_TRACE("free blocks: %d", getFreeBlocks());
199200
if (getFreeBlocks() == 0) {
200201
VOLT_WARN("No free space in ACID %d for blockid %u with blocksize %ld",
201202
m_ACID, blockId, size);
@@ -280,14 +281,15 @@ uint16_t NVMAntiCacheDB::getFreeNVMBlockIndex() {
280281

281282
if(m_NVMBlockFreeList.size() > 0) {
282283
free_index = m_NVMBlockFreeList.back();
283-
VOLT_INFO("popping %u from list of size: %d", free_index, (int)m_NVMBlockFreeList.size());
284+
VOLT_DEBUG("popping %u from list of size: %d", free_index, (int)m_NVMBlockFreeList.size());
284285
m_NVMBlockFreeList.pop_back();
285286
} else {
286287
if (m_nextFreeBlock == getMaxBlocks()) {
288+
VOLT_WARN("Backing store full m_nextFreeBlock %d == max %d", m_nextFreeBlock, getMaxBlocks());
287289
throw FullBackingStoreException(0, m_nextFreeBlock);
288290
} else {
289291
free_index = m_nextFreeBlock;
290-
VOLT_INFO("no reusable blocks (size: %d), using index %u", (int)m_NVMBlockFreeList.size(), free_index);
292+
VOLT_DEBUG("no reusable blocks (size: %d), using index %u", (int)m_NVMBlockFreeList.size(), free_index);
291293
++m_nextFreeBlock;
292294
}
293295
}
@@ -299,7 +301,7 @@ uint16_t NVMAntiCacheDB::getFreeNVMBlockIndex() {
299301

300302
void NVMAntiCacheDB::freeNVMBlock(uint16_t index) {
301303
m_NVMBlockFreeList.push_back(index);
302-
VOLT_INFO("list size: %d back: %u", (int)m_NVMBlockFreeList.size(), m_NVMBlockFreeList.back());
304+
VOLT_DEBUG("list size: %d back: %u", (int)m_NVMBlockFreeList.size(), m_NVMBlockFreeList.back());
303305
//m_blockIndex--;
304306
}
305307
}

0 commit comments

Comments
 (0)