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

node-red: ./src/threadpool.c:329: uv__queue_done: Assertion `uv__has_active_reqs(req->loop)' failed #386

Closed
bergmanu opened this issue Nov 28, 2022 · 4 comments

Comments

@bergmanu
Copy link
Collaborator

bergmanu commented Nov 28, 2022

A customer in the forum reported that his node-red application crashes periodically when he reads four inputs in a 7.5Hz period.
The crash reason is:
Assertion 'uv__has_active_reqs(req->loop)' failed

I reproduced that issue with a simplified flow (see attachment): Only having three digital inputs connected and provide a "blink" signal in a 7.5Hz period by DQs of a S7-1500 PLC to each of them simultaneously.
(Mostly) As soon as the blink application starts, node-red crashes with the following statement:

Jul 13 18:19:50 iot2050-debian node-red[818]: node-red: ./src/threadpool.c:329: uv__queue_done: Assertion `uv__has_active_reqs(req->loop)' failed
Jul 13 18:19:50 iot2050-debian systemd[1]: node-red.service: Main process exited, code=killed, status=6/ABRT
Jul 13 18:19:50 iot2050-debian systemd[1]: node-red.service: Failed with result 'signal'.
Jul 13 18:19:50 iot2050-debian systemd[1]: node-red.service: Consumed 29.504s CPU time.

Changing the period to 1Hz does not change the behavior.

UPDATE:
Behavior only happens when min. 2 DIs are provided with the signal simultaneously.
When providing only one DI with a signal, it works as expected. As soon as the signal is provided to a second input, the issue happens.

Hardware / Software used:

  • IOT2050 Basic (FS:02) and IOT2050 Advanced (FS:04)
  • Input Module Sink/Source
  • Example Image V1.2.2 and Example Image V1.3.1.1
  • Node-Red Flow: DI_crash_simplified.txt
@jan-kiszka
Copy link
Collaborator

Reproduced, also with the board generating the signals itself (I don't have a PLC around). Seems there is some race condition, hopefully in mraa (which is easier to fix) and not in libuv, the nodejs event helper library. Needs more debugging.

BTW, it seems the issue was also reported to Node-RED before, see https://discourse.nodered.org/t/assertion-uv-has-active-reqs-req-loop-failed/68564.

@jan-kiszka
Copy link
Collaborator

See libuv/libuv#3846 for a first attempt to fix it. Looks good here with 50 Hz self-trigger on two inputs which crashes immediately otherwise.

@jan-kiszka
Copy link
Collaborator

jan-kiszka commented Dec 5, 2022

A (likely) more correct fix is under testing now, see siemens/mraa@b10341f.

jan-kiszka added a commit to siemens/mraa that referenced this issue Dec 5, 2022
According to [1] and based on stress tests, it is not correct to call
uv_queue_work outside of the loop thread. We rather need to use the
async API of libuv. That even simplifies things.

Resolves "uv__queue_done: Assertion `uv__has_active_reqs(req->loop)' failed"
errors that were easy to trigger by multiple DIs being used in parallel.
See also [2].

[1] libuv/libuv#3847
[2] siemens/meta-iot2050#386

Signed-off-by: Jan Kiszka <[email protected]>
@bergmanu
Copy link
Collaborator Author

bergmanu commented Dec 6, 2022

Can confirm that the image containing this fix does not have this behavior anymore.
Tested the flow with 3 connected DIs (7,5Hz) without any error for 2h.

huaqianli pushed a commit to huaqianli/mraa that referenced this issue Apr 7, 2023
According to [1] and based on stress tests, it is not correct to call
uv_queue_work outside of the loop thread. We rather need to use the
async API of libuv. That even simplifies things.

Resolves "uv__queue_done: Assertion `uv__has_active_reqs(req->loop)' failed"
errors that were easy to trigger by multiple DIs being used in parallel.
See also [2].

[1] libuv/libuv#3847
[2] siemens/meta-iot2050#386

Signed-off-by: Jan Kiszka <[email protected]>
huaqianli pushed a commit to huaqianli/mraa that referenced this issue Nov 27, 2023
According to [1] and based on stress tests, it is not correct to call
uv_queue_work outside of the loop thread. We rather need to use the
async API of libuv. That even simplifies things.

Resolves "uv__queue_done: Assertion `uv__has_active_reqs(req->loop)' failed"
errors that were easy to trigger by multiple DIs being used in parallel.
See also [2].

[1] libuv/libuv#3847
[2] siemens/meta-iot2050#386

Signed-off-by: Jan Kiszka <[email protected]>
bniedermayr pushed a commit to bniedermayr/mraa that referenced this issue Apr 10, 2024
According to [1] and based on stress tests, it is not correct to call
uv_queue_work outside of the loop thread. We rather need to use the
async API of libuv. That even simplifies things.

Resolves "uv__queue_done: Assertion `uv__has_active_reqs(req->loop)' failed"
errors that were easy to trigger by multiple DIs being used in parallel.
See also [2].

[1] libuv/libuv#3847
[2] siemens/meta-iot2050#386

Signed-off-by: Jan Kiszka <[email protected]>
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

2 participants