[SERVER-23902] Failing to create a thread should fail with a useful error message Created: 25/Apr/16  Updated: 08/Jan/24  Resolved: 20/Jul/16

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: 3.2.9, 3.3.8

Type: Bug Priority: Major - P3
Reporter: Jonathan Reams Assignee: Mira Carey
Resolution: Done Votes: 0
Labels: code-only
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-23370 sync producer exception: Resource tem... Closed
Related
is related to SERVER-23793 core dump on mongod Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Completed:
Sprint: Platforms 15 (06/03/16), Platforms 18 (08/05/16)
Participants:

 Description   

Wherever we create a stdx::thread, we should catch any exceptions and print them with some useful information. Right now they just don't get caught (except in the listener), and can cause confusing crashes with just a backtrace and no error message (see SERVER-23793).



 Comments   
Comment by Githook User [ 19/Jul/16 ]

Author:

{u'username': u'hanumantmk', u'name': u'Jason Carey', u'email': u'jcarey@argv.me'}

Message: SERVER-23902 non-throwing stdx::thread

Instead of aliasing std::thread for stdx::thread, we wrap std::thread in an api compatible version
which std::terminates if std::thread's constructor throws.

Given that we don't have a good strategy for re-trying thread creation failures, this improves our
stack traces, as we can see which part of the code failed to create a thread, rather than getting a
generic error at the top of the stack.

(cherry picked from commit 0b5cbbadf49da830f20fba6e779b7278f211e394)
Branch: v3.2
https://github.com/mongodb/mongo/commit/93ef827c92e0acdb3bd0b6fbe6e85fe7f5e1c489

Comment by Githook User [ 13/Jul/16 ]

Author:

{u'username': u'hanumantmk', u'name': u'Jason Carey', u'email': u'jcarey@argv.me'}

Message: Revert "SERVER-23902 non-throwing stdx::thread"

This reverts commit 2c330bf540cc4cc4924c0f048cd5f8b21406653c.
Branch: v3.2
https://github.com/mongodb/mongo/commit/25555416f020dd68f9b8107acc5a24e2d3eee163

Comment by Githook User [ 13/Jul/16 ]

Author:

{u'username': u'hanumantmk', u'name': u'Jason Carey', u'email': u'jcarey@argv.me'}

Message: SERVER-23902 non-throwing stdx::thread

Instead of aliasing std::thread for stdx::thread, we wrap std::thread in
an api compatible version which std::terminates if std::thread's
constructor throws. Given that we don't have a good strategy for
re-trying thread creation failures, this improves our stack traces, as
we can see which part of the code failed to create a thread, rather than
getting a generic error at the top of the stack.

(cherry picked from commit 0b5cbbadf49da830f20fba6e779b7278f211e394)
Branch: v3.2
https://github.com/mongodb/mongo/commit/2c330bf540cc4cc4924c0f048cd5f8b21406653c

Comment by Mira Carey [ 03/Jun/16 ]

ramon.fernandez,

This improves diagnostics for systems reaching thread exhaustion and the impetus was to improve debuggability for support. I think we should consider it for a backport.

Comment by Githook User [ 03/Jun/16 ]

Author:

{u'username': u'hanumantmk', u'name': u'Jason Carey', u'email': u'jcarey@argv.me'}

Message: SERVER-23902 non-throwing stdx::thread

Instead of aliasing std::thread for stdx::thread, we wrap std::thread in
an api compatible version which std::terminates if std::thread's
constructor throws. Given that we don't have a good strategy for
re-trying thread creation failures, this improves our stack traces, as
we can see which part of the code failed to create a thread, rather than
getting a generic error at the top of the stack.
Branch: master
https://github.com/mongodb/mongo/commit/0b5cbbadf49da830f20fba6e779b7278f211e394

Generated at Thu Feb 08 04:04:46 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.