[SERVER-37700] Remove white-space from use in setThreadName Created: 22/Oct/18  Updated: 29/Oct/23  Resolved: 08/Jan/19

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 4.1.7

Type: Improvement Priority: Major - P3
Reporter: Benjamin Caimano (Inactive) Assignee: Jonathan Ma
Resolution: Fixed Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Sprint: Service Arch 2018-12-31, Service Arch 2019-01-14
Participants:

 Description   

Less robust programs may parse the proc filesystem incorrectly if there is whitespace in thread names. I propose that we debug assert that there is no whitespace in the name inside the function setThreadName.

As of now, I've found thread names containing spaces in:

  • src/mongo/db/commands/generic.cpp
  • src/mongo/db/index_builder.cpp
  • src/mongo/db/keys_collection_manager.cpp
  • src/mongo/db/repl/oplog_applier.cpp
  • src/mongo/db/s/metadata_manager.cpp
  • src/mongo/db/s/session_catalog_migration_destination_test.cpp
  • src/mongo/db/storage/wiredtiger/wiredtiger_record_store_mongod.cpp
  • src/mongo/dbtests/deferred_writer.cpp
  • src/mongo/s/client/shard_registry.cpp


 Comments   
Comment by Benjamin Caimano (Inactive) [ 08/Jan/19 ]

As an additional note, we found situations where clients were able to set the thread name. We cannot effectively prevent the setting of thread names with white space in that case.

Comment by Jonathan Ma [ 08/Jan/19 ]

Ticket has been adjusted to only scrubbing whitespaces from existing thread names.

Comment by Githook User [ 08/Jan/19 ]

Author:

{'email': 'jonathan.ma@mongodb.com', 'name': 'Jonathan Ma'}

Message: SERVER-37700 Remove thread names that include whitespaces
Branch: master
https://github.com/mongodb/mongo/commit/a43fb64a1c640378c54d1e61869d607f70154f91

Comment by Benjamin Caimano (Inactive) [ 21/Dec/18 ]

For reference, thread names are set via setThreadName. These also tend to get set via this fill in.

This change is desirable because it's a trivial way to make mongodb easier to understand for tools that parse procfs data since it tends to be space separated.

Comment by Benjamin Caimano (Inactive) [ 22/Oct/18 ]

I think there might be precedent for hyphens instead? (Not sure it matters, just commenting.)

Comment by Sara Williamson [ 22/Oct/18 ]

The plan here would be to change whitespace to underscores.

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