Skip to content

[CALCITE-6048] ServerTest#testTruncateTable fails intermittently due …#3567

Closed
libenchao wants to merge 2 commits intoapache:mainfrom
libenchao:6048-ServerTest-is-unstable
Closed

[CALCITE-6048] ServerTest#testTruncateTable fails intermittently due …#3567
libenchao wants to merge 2 commits intoapache:mainfrom
libenchao:6048-ServerTest-is-unstable

Conversation

@libenchao
Copy link
Member

…to method not found exception

@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 6, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

if (method == null) {
if (map.containsKey(key)) {
// We already looked for the method and found nothing.
// We should get again because it may be putted an object by another thread.
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this solve the race or just reduce the window of vulnerability?
The right way to do this is with some locking mechanism.

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right, adding synchronizing was in my first version. However, after looking at all the failure history, I only see the wrong result, not see the concurrent accessing exceptions, so I just proposed to add a minimal improvement without adding too much synchronizing burden to it.

I don't have a strong opinion on it, if you think adding locking mechanism is a more thorough solution which we should do, I can change back to it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't really understand where the threads come from, so I have no idea how to do this.
If all it takes is to make this method synchronized (or some other one), it looks more principled.
If you think this works always, I say it's fine.

Copy link
Member Author

Choose a reason for hiding this comment

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

The multi-threading comes from tests concurrent running, and they share a singleton ServerDdlExecutor, which will result concurrent accessing here.

I agree that adding synchronized is a better choice, since we already have some similar usages such as in JaninoRelMetadataProvider.

@JiajunBernoulli
Copy link
Contributor

It seems that the CI running time has not changed.

LGTM.

@libenchao libenchao closed this in dc115a8 Dec 13, 2023
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