-
Notifications
You must be signed in to change notification settings - Fork 130
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
introduce in-memory mutex to avoid race condition issues in parallel workers runs #819
Conversation
🦋 Changeset detectedLatest commit: 0ba6498 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
🧪 Prereleases are available for testing 🧪 @cloudflare/next-on-pagesYou can install this latest build in your project with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/next-on-pages/runs/9794913991/npm-package-next-on-pages-819 @cloudflare/eslint-plugin-next-on-pagesYou can install this latest build in your project with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/next-on-pages/runs/9794913991/npm-package-eslint-plugin-next-on-pages-819 |
098045f
to
8abe434
Compare
@dario-piotrowicz We haven't managed to get this pre-release in production for us because there seems to be a deadlock somewhere (on a small proportion of requests). Really struggling to create a reproducible case since the worker isn't flushing log lines until the request completes and the request never does complete 😅 |
oh... ok that's not good 😓 let me have a think about it 😓 |
…rallel worker runs add finally block for done call
…rallel worker runs format code
@ostenbom I've added a (if this doesn't fix it I have another idea in mind, but I hope that this should be enough) |
Here are the very strange conditions under which I can get it to deadlock 🤪 :
The last |
@dario-piotrowicz anything more you can do here? Or is this a not-so-expected use case? Appreciate your help here! ⭐ |
* What is this file for? | ||
* | ||
* workerd isolates share the same modules registry meaning that it can happen for the same isolate to run | ||
* multiple instances of the same worker and those will share the modules' state. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An isolate by definition runs only one "instance" of the Worker. However, one Worker instance may handle many requests, possibly at the same time, possibly from different users. Global state will be shared across all these requests.
Basically all servers work this way, including Node.js. We actually would like to change this in Workers, but it requires building new fundamental technology.
Sorry to keep pinging you @dario-piotrowicz but this is affecting hundreds of our users every day, and is our main source of instability on |
@ostenbom sorry, I meant to reply to your older ping sooner 😓 I don't think that this is a not-so-expected use case and I do believe we need to fix it asap... I simply hadn't had time to dedicate to this (as I've been working on other unrelated projects) I don't think that there's anything specific you can do on your end 😓 anyways I'm really sorry that this is affecting many of your users, I will try my best to prioritize this work and I promise to either give you a solution or some concrete info by the end of this week/begging of the next ( |
Hi @ostenbom 🙂 I've tried a different solution for this in #836 I've been testing this with your reproduction and it seems to be working smoothly 😃 (hopefully I am not getting false positives for some reason 🤔) I still want to polish it a bit and analyze more this approach, but please if you want try the PR's prerelease and let me know if it works for you 🙂 |
Thanks @dario-piotrowicz! This one looks good! Both passing the reproduction and our internal tests, plus not deadlocking! 😍 |
@ostenbom Awesome! thanks for confirming! 😄 I'll close this PR then and let's just move to the other one, I need to do some light polishing and I think it should be good to go 🙂 |
fixes #805