-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Concurrent map writes when incrementing a property from setup()'s return #693
Comments
As you've mentioned, you shouldn't use the setup data in this way. The setup data is in no way intended or suitable for synchronization or even cross-VU modification. The different VUs have their own separate JS runtimes and the only reason that this sort-of works is that we currently don't do a deep copy of the setup data for each VU and a quirk in the way go manages objects... But even then it wouldn't have worked in a distributed cluster/cloud execution scenario... This issue, #684 and #558, make me reevaluate how we handle the setup data... I think that we should either make the setup data totally read-only (which I'm not sure is actually possible with goja) or we should do something like this:
Regarding a global counter, it would be quite difficult and costly in terms of synchronization overhead to do in a distributed execution setting. Building a unique ID from |
I figured this would fail at most when running in a future distributed mode (which I look forward to). I only tried it because it wasn't explicitly recommended against in the docs, and worked with fewer VUs. So maybe the documentation should at least contain a warning. If possible, a read-only state would probably be the best 'immediate' fix, as a deep copy would increase the memory foot print. And as for my use case of a global counter for unique test data, a stream API (#592) is what I extremely look forward to, too. I haven't tried using third party modules for external data sources yet (e.g. Redis), but figure the performance impact on the test run might be noticible. The downside of a 'unique' ID from __VU and __ITER is that one needs to manually pre-slice the test data on a per-VU basis, which is not so elegant. |
This was fixed by #799 |
I'm getting a race condition when I'm using a "global counter" by incrementing an object property in the VU code that I pass from setup().
I realize that such a construct was prone to a race condition. But I wanted a global counter so that I could iterate through test data that I needed to be unique for every VU. I know one can use a construct by defining a variable from (__VU,__ITER), but a global counter was something I knew from JMeter, so I wanted to use that. Now it bit me :).
script.js
Run:
racecondition.txt:
The text was updated successfully, but these errors were encountered: