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

ARTEMIS-3591: stop paging checkMemory task executing twice #3985

Merged

Conversation

gemmellr
Copy link
Member

Stop paging checkMemory task executing twice in some cases.


// We check again to avoid a race condition where the size can come down just after the element
// has been added, but the check to execute was done before the element was added
// NOTE! We do not fix this race by locking the whole thing, doing this check provides
// MUCH better performance in a highly concurrent environment
if (!pagingManager.isGlobalFull() && (sizeInBytes.get() < maxSize || maxSize < 0)) {
// run it now
runWhenAvailable.run();
atomicRunWhenAvailable.run();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohhh... I thought you had a more complex case involved on this.

Thanks for this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope just the obvious cases mentioned on the JIRA, spotted when reading it for some older PR (dont recall which). Theres probably a few different paths it can happen, but the most basic solution used here hits the general issue. Took a lot longer to come up with a reliable test to exercise the problem than to fix.

@clebertsuconic clebertsuconic merged commit 36dcb30 into apache:main Mar 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants