Skip to content

Commit 0a6965f

Browse files
committed
add debug logs in cache
1 parent d07f673 commit 0a6965f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

code/go/0chain.net/blobbercore/allocation/repository.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ func (r *Repository) GetByTx(ctx context.Context, allocationID, txHash string) (
135135
Allocation: a,
136136
}
137137
return a, nil
138+
} else if a != nil {
139+
logging.Logger.Debug("allocation_cache_miss", zap.String("allocation_id", allocationID), zap.String("tx_hash", txHash), zap.String("cached_tx_hash", a.Tx))
138140
}
139141

140142
alloc := &Allocation{}
@@ -260,7 +262,6 @@ func (r *Repository) Commit(tx *datastore.EnhancedDB) {
260262
return
261263
}
262264
for _, txnCache := range cache {
263-
alloc := r.getAllocFromGlobalCache(txnCache.Allocation.ID)
264265
mapLock.Lock()
265266
mut, ok := r.allocLock[txnCache.Allocation.ID]
266267
if !ok {
@@ -269,11 +270,13 @@ func (r *Repository) Commit(tx *datastore.EnhancedDB) {
269270
}
270271
mapLock.Unlock()
271272
mut.Lock()
273+
alloc := r.getAllocFromGlobalCache(txnCache.Allocation.ID)
272274
if alloc != nil {
273275
for _, update := range txnCache.AllocationUpdates {
274276
update(alloc)
275277
}
276278
if len(txnCache.AllocationUpdates) > 0 {
279+
logging.Logger.Debug("committing_allocation", zap.String("allocation_id", alloc.ID), zap.String("tx", alloc.Tx))
277280
r.setAllocToGlobalCache(alloc)
278281
}
279282
}

0 commit comments

Comments
 (0)