Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't increase cache size when write failed #23759

Open
lee3164 opened this issue Sep 27, 2022 · 0 comments · May be fixed by #23760
Open

Don't increase cache size when write failed #23759

lee3164 opened this issue Sep 27, 2022 · 0 comments · May be fixed by #23760

Comments

@lee3164
Copy link

lee3164 commented Sep 27, 2022

for k, v := range values {
newKey, err := store.write([]byte(k), v)
if err != nil {
// The write failed, hold onto the error and adjust the size delta.
werr = err
addedSize -= uint64(Values(v).Size())
c.decreaseSize(uint64(Values(v).Size()))
}
if newKey {
addedSize += uint64(len(k))
c.increaseSize(uint64(len(k)))
}
}

I notice in TestCache_CacheWriteMulti_TypeConflict test, we assume cache size won't increase when writing failed, but actually, it adds key size, I think this may be a bug. So this test cannot pass

if err := c.WriteMulti(map[string][]Value{"foo": values[:1], "bar": values[1:]}); err == nil {
t.Fatalf(" expected field type conflict")
}
if exp, got := uint64(v0.Size())+3, c.Size(); exp != got {
t.Fatalf("cache size incorrect after 2 writes, exp %d, got %d", exp, got)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant