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

DB-7022 avoid coordinated pauses from multiple threads #1857

Merged
merged 3 commits into from
May 24, 2018
Merged

Conversation

OlegMazurov
Copy link

No description provided.

long jitter = (long)(normalPause * RANDOM.nextFloat() * 0.01f); // 1% possible jitter
return normalPause + jitter;
// DB-7022 avoid coordinated pauses from multiple threads
return RANDOM.nextLong() % normalPause;
Copy link
Contributor

Choose a reason for hiding this comment

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

The Random.nextLong() may return a negative value, so need to use the absolute value or something. See the following for a potential problem with getting the absolute value of the smallest possible long:
https://help.semmle.com/wiki/display/JAVA/Incorrect+absolute+value+of+random+number

Copy link
Author

Choose a reason for hiding this comment

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

Good point. Will provide a better fix.

Copy link
Contributor

@dgomezferro dgomezferro left a comment

Choose a reason for hiding this comment

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

I like this latest version more, have you tested it on a cluster to make sure it behaves nicely?

@OlegMazurov
Copy link
Author

I'm going to test the latest version in cluster and backport it to 2.5/2.7.

Copy link
Contributor

@yxia92 yxia92 left a comment

Choose a reason for hiding this comment

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

I'm putting it on hold for merge until explicitly confirmed from Oleg with his analysis of test result. Changing the status to "Request Changes".

@s0
Copy link

s0 commented May 22, 2018

Hi guys! I see you've caught a potential coding problem by hand and referred to our documentation for more info. That's awesome! You may be interested in LGTM.com, where our analysis of such problems is freely available for open source projects like Splice Machine.

One of the most important features is automatic code review for GitHub Pull Requests. LGTM will automatically comment on PRs that introduce new alerts — ranging from potentially critical security issues (such as this one in AMPHTML), to resource leaks (such as this one in a NASA project), to unsafe/incorrect random numbers. The coding problem you manually spotted here will have been automatically detected if PR integration was enabled for your project.

LGTM.com is already analysing >70K open source repos; here are the results for splicemachine/spliceengine: https://lgtm.com/projects/g/splicemachine/spliceengine/alerts/.

You can enable PR integration here: https://lgtm.com/projects/g/splicemachine/spliceengine/ci/

My co-worker used your build instructions to set up a custom build command so that LGTM can successfully analyse splicemachine; I will open a PR here with those settings so you can tweak them in the future.

(Full disclosure: I work at Semmle, on the team responsible for LGTM.com)

@OlegMazurov
Copy link
Author

@yxia92 I updated DB-7022 with my latest analysis. I find the proposed fix beneficial and would like to proceed with merging it.

@yxia92
Copy link
Contributor

yxia92 commented May 22, 2018

Thanks @OlegMazurov I've changed my vote to approval.

@jyuanca jyuanca merged commit 5b37ac9 into master May 24, 2018
@MurrayBrown MurrayBrown deleted the DB-7022 branch August 2, 2018 04:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

10 participants