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

Can't create new Wasm Execution Contexts while another thread is running an existing Execution Context #40

Closed
gzurl opened this issue Mar 29, 2023 · 0 comments · Fixed by #41
Assignees
Labels
⚠️ bug Something isn't working

Comments

@gzurl
Copy link
Contributor

gzurl commented Mar 29, 2023

Describe the bug

In execution_ctx.rs run() method, the WASM_RUNTIME_EXECUTIONCTXS hash map is locked as read() during the Wasm module execution.

This means new threads (new HTTP incoming requests) can't create new execution contexts since that would require exclusive write() access.

In a 'normal' scenario, this is suboptimal because it might lead to a situation where Apache is allocating more resources than mod_wasm can leverage.

But in an adverse scenario, if a Wasm module execution takes longer than usual (or hangs up), that might block other incoming requests.

Since CPU-limited executions are not implemented yet (see #9), it would be much better to ensure that the WASM_RUNTIME_EXECUTIONCTXS hash map is not locked at all during the Wasm module execution.

Reproduction steps

  1. Create a configuration with two different locations:
    • a) /intense_task, whose Wasm execution takes a long time (ie: 10secs)
    • b) /light_task, a very simple and immediate task
  2. Start up Apache and check both locations works as expected.
  3. Then load /intense_task, and right after, try loading /light_task: It should be obvious that such /light_task won't start until /intense_task is done.

Expected behavior

In a mono-thread scenario (ie.: httpd -X), new requests are queued and dispatched one by one.
In a multi-threading scenario, new requests shouldn't be delayed because other requests are running the Wasm module.

Additional context

This issue was reported by @juamedgod, who noticed a wrong behavior while testing a dev version of PHP.wasm whose execution never finished. Thanks for reporting!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚠️ bug Something isn't working
Projects
None yet
1 participant