Project

General

Profile

Bug #11004

Several door servers don't properly handle exiting threads

Added by Gordon Ross 5 months ago. Updated 4 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
-
Start date:
2019-05-14
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
needs-triage

Description

In investigating #11039, it was discovered that some door servers fail to cause thread counts to decrement on thread exit.

Door servers can register their own thread-creation functions. These functions can maintain whatever size thread pool they want, and can block requests if too many threads are active. However, they must ensure that at least one thread is available to server requests.

Many of these 'limiting' door servers use thread-specific data to decrement the number of active threads in the case that a thread exists. However, nearly all of them set the TSD value to NULL, which means the destructor never gets called, and so the thread count is never decremented. This could lead to a complete depletion of the thread pool, and so no new door requests can be served.

Note that, under normal circumstances, door server threads never exit - they're supposed to use 'door_return' instead of allowing an exit - and so this should only happen due to programming errors. Thread exit should still be handled appropriately, particularly in the presence of library code.

idmapd, nscd, and ldapcachemgr all use TSDs to handle this, but set 'value' to NULL. nfs-mountd also uses TSD destructors to handle thread counts, but selectively sets 'value' to 1 for reasons that aren't clear, and as such isn't included in this bug.

Found by code inspection; There is no known method to test this, and it's unclear if any threads actually exit.

History

#1

Updated by Gordon Ross 5 months ago

  • Description updated (diff)
  • Status changed from New to In Progress
#2

Updated by Gordon Ross 5 months ago

Testing: No functional impact in normal operation (just regression checks)
In production since early 2019

#3

Updated by Electric Monk 4 months ago

  • Status changed from In Progress to Closed
  • % Done changed from 0 to 100

git commit fea136a04b3f86ab3ec31e4c157379030fee9ade

commit  fea136a04b3f86ab3ec31e4c157379030fee9ade
Author: Matt Barden <matt.barden@nexenta.com>
Date:   2019-06-06T15:13:38.000Z

    11004 Several door servers don't properly handle exiting threads
    11198 Allow adjustment of max_threads for idmapd
    Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
    Reviewed by: Evan Layton <evan.layton@nexenta.com>
    Approved by: Garrett D'Amore <garrett@damore.org>

Also available in: Atom PDF