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

FakerValues initialization isn't thread safe #574

Closed
ttuckergw opened this issue Dec 21, 2022 · 9 comments
Closed

FakerValues initialization isn't thread safe #574

ttuckergw opened this issue Dec 21, 2022 · 9 comments

Comments

@ttuckergw
Copy link

Describe the bug
We currently use JavaFaker with Gatling for load testing and would like to switch to DataFaker, but there is a multi-threaded initialization bug in JavaFaker FakeValues.get() that we would like to report. I downloaded the DataFaker sources for version 1.7.0, and I see it still has that same JavaFaker code. It is a pretty trivial bug. That method should be a synchronized Java method so that SnakeYaml isn’t invoked multiple times in a multi-threaded environment to initialize the same fake values data.

To Reproduce
Run a Gatling load test with 100+ closed model users (or a java multi-threaded test with 100+ threads) that uses a single Faker library (fake names for instance). You should see multiple invocations of SnakeYaml all trying to initialize the Fake Values for the same library simultaneously.

Expected behavior
The FakeValues code should only need to initialize the FakeValues for each library once in a multi-threaded environment.

Versions:
DataFaker 1.7.0 (and the current JavaFaker release 1.0.2)

Additional context
We see this issue with Gatling load testing.

@snuyanzin
Copy link
Collaborator

do you have a bit more details or code sample?

@ttuckergw
Copy link
Author

ttuckergw commented Dec 21, 2022 via email

@snuyanzin
Copy link
Collaborator

here would be ok

@bodiam
Copy link
Contributor

bodiam commented Dec 21, 2022

@ttuckergw could you try the latest snapshot version, and check if it's resolved there?

@ttuckergw
Copy link
Author

ttuckergw commented Dec 21, 2022 via email

@ttuckergw
Copy link
Author

ttuckergw commented Dec 22, 2022 via email

@bodiam
Copy link
Contributor

bodiam commented Dec 22, 2022

@ttuckergw don't thank me, but @snuyanzin. He is the concurrency expert here, and fixed the issue!

Thanks for confirming that this fixed the issue!

@bodiam bodiam closed this as completed Dec 22, 2022
@valfirst
Copy link
Contributor

is there any plan to release this fix soon? we've also faced this issue, snapshots are good for testing, but it'll be safer to use stable release version for production

@bodiam
Copy link
Contributor

bodiam commented Dec 26, 2022

@valfirst No, there's no plan yet for a new release at this moment, but our snapshots are pretty stable. I was thinking of creating a new release every 100 stars or so as an experiment, so.... 99 stars to go :-)

valfirst added a commit to vividus-framework/vividus that referenced this issue Dec 30, 2022
The root cause of the fixed issue: datafaker-net/datafaker#574.
It's needed to use JitPack build, because new `datafaker` release is not plublished and timeline is unknown
(see more: datafaker-net/datafaker#574 (comment)).
`datafaker` SNAPSHOT builds may introduce unexpected breaking changes e.g.
datafaker-net/datafaker@e44736d,
that's why they are not acceptable.
valfirst added a commit to vividus-framework/vividus that referenced this issue Dec 30, 2022
The root cause of the fixed issue: datafaker-net/datafaker#574.
It's needed to use JitPack build, because new `datafaker` release is not plublished and timeline is unknown
(see more: datafaker-net/datafaker#574 (comment)).
`datafaker` SNAPSHOT builds may introduce unexpected breaking changes e.g.
datafaker-net/datafaker@e44736d,
that's why they are not acceptable.
valfirst added a commit to vividus-framework/vividus that referenced this issue Dec 30, 2022
The root cause of the fixed issue: datafaker-net/datafaker#574.
It's needed to use JitPack build, because new `datafaker` release is not plublished and timeline is unknown
(see more: datafaker-net/datafaker#574 (comment)).
`datafaker` SNAPSHOT builds may introduce unexpected breaking changes e.g.
datafaker-net/datafaker@e44736d,
that's why they are not acceptable.
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

No branches or pull requests

4 participants