MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / cacheState

Method cacheState

src/jrd/tpc.cpp:198–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

196}
197
198CommitNumber TipCache::cacheState(TraNumber number)
199{
200 fb_assert(m_tpcHeader);
201 GlobalTpcHeader* header = m_tpcHeader->getHeader();
202
203 TraNumber oldest = header->oldest_transaction.load(std::memory_order_relaxed);
204
205 if (number < oldest)
206 return CN_PREHISTORIC;
207
208 TpcBlockNumber blockNumber = number / m_transactionsPerBlock;
209 ULONG offset = number % m_transactionsPerBlock;
210
211 Sync sync(&m_sync_status, FB_FUNCTION);
212 TransactionStatusBlock* block = getTransactionStatusBlock(header, blockNumber, sync);
213
214 // This should not really happen ever
215 fb_assert(block);
216
217 if (!block)
218 return CN_PREHISTORIC;
219
220 // Barrier is not needed here when we are reading state from cache
221 // because all callers of this function are prepared to handle
222 // slightly out-dated information and will take slow path if necessary
223 CommitNumber state = block->data[offset];
224
225 return state;
226}
227
228void TipCache::initializeTpc(thread_db *tdbb)
229{

Callers 2

VIO_intermediate_gcFunction · 0.80
TPC_cache_stateFunction · 0.80

Calls 2

getHeaderMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected