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

Unify expiry condition in getWithInfo() and onEvict() #319

Merged
merged 1 commit into from
Jun 14, 2022

Conversation

chen-zhuohan
Copy link
Contributor

@chen-zhuohan chen-zhuohan commented May 24, 2022

Closes: #318

shard.go Show resolved Hide resolved
@janisz
Copy link
Collaborator

janisz commented May 27, 2022

@chen-zhuohan it looks like we have race now

@chen-zhuohan
Copy link
Contributor Author

it seems be some problem about uint64(out of the uint64 limits).

func (s *cacheShard) isExpired(oldestEntry []byte, currentTimestamp uint64) bool {
	oldestTimestamp := readTimestampFromEntry(oldestEntry)
	fmt.Println(time.Unix(int64(currentTimestamp), 0), time.Unix(int64(oldestTimestamp), 0), currentTimestamp-oldestTimestamp, s.lifeWindow, currentTimestamp-oldestTimestamp > s.lifeWindow)
	return currentTimestamp-oldestTimestamp > s.lifeWindow
}

I get this print:
2022-05-30 16:02:56 +0800 CST 2022-05-30 16:02:57 +0800 CST 18446744073709551615 600 true

see 18446744073709551615, and the problem will be clean.

I add another check to fix it.

@janisz janisz changed the title fix: expired Unify expiry condition in getWithInfo() and onEvict() May 30, 2022
@chen-zhuohan
Copy link
Contributor Author

chen-zhuohan commented Jun 14, 2022

how long will the change merged QAQ @janisz

@janisz janisz merged commit 7c2932e into allegro:master Jun 14, 2022
@janisz
Copy link
Collaborator

janisz commented Jun 14, 2022

@chen-zhuohan I'm sorry, I missed this. It's merged, thanks!
I wish we couldn't had meet when I worked at @bytedance

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.

the different Expired judge in cacheShard.getWithInfo() and cacheShard.onEvict()
2 participants