-
Notifications
You must be signed in to change notification settings - Fork 73
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
fix: group.Set() not updating hot cache for all nodes #69
base: master
Are you sure you want to change the base?
Conversation
if e != nil { | ||
err = errors.Join(err, e) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there were some errors but the last one yielded nil, the previous code would not return any error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this contribution! Very sorry nobody noticed the PR for so long. This is definitely a problem worth fixing. Please see my comments.
|
||
g.localSet(key, value, expire, &g.hotCache) | ||
|
||
for _, peer := range g.peers.GetAll() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to see this code deduplicated with its counterpart in the owner code path (line 324). Move to function?
group.localSet(*out.Key, out.Value, expire, &group.mainCache) | ||
c := &group.mainCache | ||
if out.HotCache != nil && *out.HotCache { | ||
c = &group.hotCache |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking that Set()
on owner peer should update only mainCache
, otherwise respect out.HotCache
flag.
var cmds []*exec.Cmd | ||
var wg sync.WaitGroup | ||
for i := 0; i < nChild; i++ { | ||
cmd := exec.Command(os.Args[0], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not on board with launching nested go test
processes. Can this be achieved with goroutines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
due to how this older version of group cache works, you have to do it this way. This is one of the reasons why I forked and re-wrote it https://github.com/groupcache/groupcache-go ✨
@thrawn01 You may want to incorporate this fix in your fork. |
I've created a new PR to fix this issue on the new repo groupcache/groupcache-go#11 The correct thing to do is ALWAYS delete the updated key from the hotCache. See the PR for explanation. |
When there are more than 2 nodes, the
hotCache
is never updated when using theSet()
method. Added a test which triggers the bug (you can test it by removing the accompanying fix done in groupcache.go).However, it does look to me like the
hotCache
param in the Set method is misleading: the hot caches are used even if the provided arg isfalse
, which would then yield out-of-date values to the other nodes 🤔