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

FetchDNS: Keep dnsjava selector thread out of ToePool #444

Merged
merged 2 commits into from
Nov 27, 2021

Conversation

ato
Copy link
Collaborator

@ato ato commented Nov 1, 2021

Fixes #425, the dnsjava selector thread using 100% CPU because it was being created in the toe thread pool and then interrupted when the job was terminated. By doing a dummy lookup in a static block we ensure the selector thread is launched from a normal thread rather than from a toe thread.

There was an existing workaround in CrawlController for a similar problem with the dnsjava cache cleaner thread. This cleaner thread no longer exists in the current version of dnsjava but I assume we still want to set the cache size anyway. I moved this code to FetchDNS as well to keep the code that interfaces with dnsjava centralized. Since the cache is global it only needs to be configured once, not on every job launch.

Since the cache is global we only need to configure it once, not every
time we start a job. By moving it we keep the code that interfaces with
dnsjava centralized in FetchDNS.

Looks like dnsjava no longer uses a cleaner thread so remove the comment
referring to it.
dnsjava will create its global selector thread on first DNS lookup.
Since the first lookup occurs on a toe thread then this will cause the
selector thead to join the job's toe thread group. This is a problem
because when the job is terminated ToePool sends an interrupt to all
threads in the thread group which the dnsjava selector thread is
not expected and never clears. The interrupted state then causes
select() to return immediately instead of sleeping so it consumes
100% CPU.

So workaround this by doing a dummy lookup when FetchDNS is loaded,
this ensures the first lookup happens on the web server thread that
handles the job build action instead of a toe thread.

Fixes: 045b251 ("Update to latest version of dnsjava")
@ato ato merged commit d63cb9a into master Nov 27, 2021
@ato ato deleted the fix-dnsjava-selector-thread branch November 27, 2021 03:41
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.

dnsjava NIO selector thread stuck at 100% after terminating job
1 participant