Skip to content

Commit 790239a

Browse files
committed
Fix concurrent map write issue in Geyser worker
1 parent 7f9bdab commit 790239a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

geyser/handler_memory.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ func (h *MemoryAccountWithDataUpdateHandler) onStateObserved(ctx context.Context
333333

334334
// Update the DB with the delta changes to the memory account state
335335
var wg sync.WaitGroup
336+
var cachedMemoryAccountStateUpdateMu sync.Mutex
336337
for _, dbUpdate := range dbUpdates {
337338
wg.Add(1)
338339

@@ -360,7 +361,9 @@ func (h *MemoryAccountWithDataUpdateHandler) onStateObserved(ctx context.Context
360361
err := h.ramStore.Save(ctx, record)
361362
switch err {
362363
case nil:
364+
cachedMemoryAccountStateUpdateMu.Lock()
363365
h.cachedMemoryAccountState[base58MemoryAccountAddress][dbUpdate.Index] = dbUpdate
366+
cachedMemoryAccountStateUpdateMu.Unlock()
364367
case ram.ErrStaleState:
365368
// Should never happen given current locking structure
366369
default:

0 commit comments

Comments
 (0)