Skip to content

Commit d4d50a3

Browse files
committed
feat: allow retry if as_mut fail
1 parent 1a92399 commit d4d50a3

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

vm/src/dictdatatype.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,17 @@ impl<T: Clone> Dict<T> {
248248
if let Some(index) = entry_index.index() {
249249
// Update existing key
250250
if let Some(entry) = inner.entries.get_mut(index) {
251-
let entry = entry
252-
.as_mut()
253-
.expect("The dict was changed since we did lookup.");
251+
let entry = if let Some(entry) = entry.as_mut() {
252+
entry
253+
} else {
254+
// The dict was changed since we did lookup. Let's try again.
255+
// this is very rare to happen
256+
// (and seems only happen with very high freq gc, and about three to four time in 200000 iters)
257+
// but still possible
258+
// so logging a warn is acceptable in here
259+
warn!("The dict was changed since we did lookup. Let's try again.");
260+
continue;
261+
};
254262
if entry.index == index_index {
255263
let removed = std::mem::replace(&mut entry.value, value);
256264
// defer dec RC

0 commit comments

Comments
 (0)