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

Errors with concurrent simulator requests due to global interpreter state #282

Merged
merged 2 commits into from
Apr 1, 2024

Conversation

richardmarshall
Copy link
Collaborator

Currently if the interpreter is not threadsafe as much of the state for an individual request being processed is stored in the interpreter struct itself. This causes problems for the simulator if it receives multiple concurrent requests.

While it might be nice for the interpreter to be threadsafe reworking things for that would be rather involved. A simpler solution to solve this specific issue is to add an interpreter lock which the simulator HTTP handler can acquire before processing a request.

This PR adds lock/unlock behavior for the interpreter http handler as well as setting up the Fastly-FF header to let the handler detect loops. Without that a deadlock could occur if the simulator was configured to be a backend for itself.

Copy link
Owner

@ysugimoto ysugimoto left a comment

Choose a reason for hiding this comment

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

Looks good.

I agree with you because the simulator is just for local debugging, not for production use so it's okay to be locked by mutex.

@ysugimoto ysugimoto merged commit c337452 into ysugimoto:main Apr 1, 2024
1 check passed
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.

2 participants