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

CURATOR-719: Fix orSetData for parallel create calls #510

Merged
merged 1 commit into from
Dec 12, 2024

Conversation

HoustonPutman
Copy link
Contributor

@HoustonPutman HoustonPutman commented Dec 4, 2024

https://issues.apache.org/jira/browse/CURATOR-719

This fix really just lets the catch (KeeperException.NodeExistsException e) clause catch exceptions thrown in the if (createParentsIfNeeded) clause. Previously, since the two catch statements were for the same try, the KeeperException.NodeExistsException logic would not be called if that error was thrown when creating the node after creating the parents. This case can easily be seen when trying to call create.orSetData() in parallel on the same node, while creating parents if needed. This is because the NoNodeException would be thrown for both parallel calls, but only one would be able to create the new node in the catch statement, and the other would get an un-catchable NodeExistsException.

Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

Overall LGMT

but maybe the new test may pass not reproduce the issue

}
return null;
};
Future<Exception> f1 = executor.submit(setData);
Copy link
Contributor

Choose a reason for hiding this comment

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

we may be very lucky and not reproduce the problem (if the machine is "slow" and the two operations don't run concurrently)

maybe we can make this a little bit nasty and schedule many operations in parallel.
It would be great to have a way to intercept the code paths and verify that we have exercised all the possible branches. (Mockito?)

Copy link
Member

Choose a reason for hiding this comment

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

we may be very lucky and not reproduce the problem (if the machine is "slow" and the two operations don't run concurrently)

For concurrent sensitive test, I usually run with help from IDE "until failure" or "run x times". I, personally, think "reproduce" means that it will reproduce the bug given enough runs(tens to hundreds depends on context).

Mockito?

I prefer to run multiple times over mock if the number of runs is small. Mock forces us to think different and complicate things.

I tested this after reverting the fix, it failed in the first runs without resorting to "run x times" on my 2015 macbook pro.

Copy link
Contributor

Choose a reason for hiding this comment

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

with Mockito I mean that we can use a spy or override some method to ensure that we are hitting the expected code path.

I tested this after reverting the fix, it failed in the first runs without resorting to "run x times" on my 2015 macbook pro

let me try

Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

I have run the test locally and actually without the fix it fails at the first trial.

We can keep the test as it is now.

thank you @kezhuw

@eolivelli eolivelli merged commit ad19795 into apache:master Dec 12, 2024
10 checks passed
@eolivelli
Copy link
Contributor

thank you very much @HoustonPutman
looking forward to more contributions !

@HoustonPutman HoustonPutman deleted the parallel-creates branch December 12, 2024 16:48
@HoustonPutman
Copy link
Contributor Author

Thanks for checking y'all! I did make sure it failed without the fix, but I know how pesky these types of tests can be on different hardware and runtimes.

looking forward to more contributions !

I will definitely have a few more in the next few weeks 🙂

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