Is it safe to do BatchLookup + BatchDelete in a loop? #1904
Replies: 1 comment
-
|
Turns out the code was wrong (my bad 🙈 ) . The possible error values returned by After closer inspection, Lines 1242 to 1246 in c64ffee According to 9d02bd3:
Which looks like what's happening here. I was using a batch of size 1000, but sounds like this was not large enough. Any suggestions on how to avoid this batch vs bucket size mismatch issue? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a situation in which I have a large hash map with entries containing timestamps on each of them. I run a goroutine on userspace that periodically runs a loop to iterate over all entries in the map and delete only those whose timestamp is older than a given threshold.
The code looks something like this:
But I'm wondering: is it safe to delete entries while I'm iterating over the map? Note I can't use
BatchLookupAndDeletebecause I need to selectively delete entries from the map.I'm observing some hangs in production where this loop sometimes gets stuck inside the call to
BatchLookupand I suspect it may be related to the interaction between lookups and deletions in the loop above. Here's a flamegraph captured using pprof during one of these hangs:Beta Was this translation helpful? Give feedback.
All reactions