Skip to content

Commit 79e8c10

Browse files
committed
rangefeed: don't hold references to popped events
Make sure that any memory referenced by this event isn't held back from GC because it is still in the already-read portion of the chunk. Fixes #149320 Informs #149121 Release note: None
1 parent 9015a1c commit 79e8c10

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pkg/kv/kvserver/rangefeed/event_queue.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ func (q *eventQueue) popFront() (sharedMuxEvent, bool) {
9090
q.read = 0
9191
}
9292
res := q.first.data[q.read]
93+
q.first.data[q.read] = sharedMuxEvent{}
9394
q.read++
9495
q.size--
9596
return res, true
@@ -113,7 +114,9 @@ func (q *eventQueue) drain(ctx context.Context) {
113114
max = q.write
114115
}
115116
for i := start; i < max; i++ {
116-
chunk.data[i].alloc.Release(ctx)
117+
item := chunk.data[i]
118+
chunk.data[i] = sharedMuxEvent{}
119+
item.alloc.Release(ctx)
117120
}
118121
next := chunk.nextChunk
119122
putPooledQueueChunk(chunk)

0 commit comments

Comments
 (0)