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

fix: group.Set() not updating hot cache for all nodes #69

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

xWiiLLz
Copy link

@xWiiLLz xWiiLLz commented Apr 16, 2024

When there are more than 2 nodes, the hotCache is never updated when using the Set() 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 is false, which would then yield out-of-date values to the other nodes 🤔

Comment on lines +391 to +393
if e != nil {
err = errors.Join(err, e)
}
Copy link
Author

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

Copy link

@Baliedge Baliedge left a 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() {

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

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],

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?

Copy link
Contributor

@thrawn01 thrawn01 Dec 2, 2024

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

@Baliedge
Copy link

@thrawn01 You may want to incorporate this fix in your fork.

@thrawn01
Copy link
Contributor

thrawn01 commented Dec 3, 2024

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.

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 this pull request may close these issues.

3 participants