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

Fix worker_threads support #1110

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

Qard
Copy link

@Qard Qard commented Dec 20, 2024

This makes node-rdkafka work correctly with worker_threads. There were several issues which needed resolving and some changes which were needed to prevent data being shared across threads and to ensure everything is cleaned up completely when the thread exits.

Changes included:

  • Use NODE_MODULE_CONTEXT_AWARE to init module
  • No globals, shared data needs to live in PerIsolateData.
  • No using uv_default_loop(), need to get the loop owned by the current thread.
  • Dispatcher::Deactivate() on destruct to stop uv_async_t so thread can teardown loop safely
  • Connection and Topic types need cleanup hooks to ensure they are deleted when the thread is torn down.
  • Construct Conf with correctly-sized type so destructor and sub-class fields aren't overwriting random memory
  • Give AsyncWorker types unique AsyncResource names for better debugging

@Qard Qard force-pushed the fix-worker-threads branch from 006158e to 8071391 Compare December 20, 2024 18:43
@Qard Qard marked this pull request as ready for review December 21, 2024 08:52
src/common.h Outdated Show resolved Hide resolved
Signed-off-by: Stephen Belanger <[email protected]>
@Qard Qard force-pushed the fix-worker-threads branch from 8071391 to 3f378cb Compare December 23, 2024 12:57
Copy link

@rozzilla rozzilla left a comment

Choose a reason for hiding this comment

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

QA done over this and this PRs. Works fine ✅

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