[SERVER-74102] Hedging options should only be available on `mongos` Created: 16/Feb/23  Updated: 28/Feb/23

Status: Backlog
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Amirsaman Memaripour Assignee: Backlog - Service Architecture
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-38728 Allow pipeline with $lookup into a sh... Closed
Assigned Teams:
Service Arch
Operating System: ALL
Steps To Reproduce:

Try running the following against a mongod server:

db.adminCommand( { getParameter : 1, "readHedgingMode" : 1 } );

Participants:

 Description   

Hedging is controlled by the following server parameter, settable at both startup and runtime:

server_parameters:
  readHedgingMode:
    description: >-
        Enables hedged reads.
    set_at: [ startup, runtime ]
    cpp_class:
      name: HedgingModeServerParameter

The parameter is mapped to a global atomic, defined here and initialized to enabled:

AtomicWord<ReadHedgingMode> gReadHedgingMode{ReadHedgingMode::kOn};

This server parameter, along with other mongos-specific parameters (e.g., loadBalancerPort), is packed with async_requests_sender:

env.Library(
    target='async_requests_sender',
    source=[
        'async_requests_sender.cpp',
    ],
    LIBDEPS=[
        ...
        'mongos_server_parameters',
    ],
    LIBDEPS_PRIVATE=[
        '$BUILD_DIR/mongo/executor/hedge_options_util',
    ],
)

However, there are non-mongos compilation units that link against this target. For example, the following makes hedging and other mongos-specific behavior available for mongod servers:

env.Library(
    target='sharded_agg_helpers',
    ...
    LIBDEPS=[
        ...
        '$BUILD_DIR/mongo/s/async_requests_sender',
        ...
    ],
)



 Comments   
Comment by Jason Chan [ 28/Feb/23 ]

Note: We don't think this is specific to hedging options, as we expect there to be a set of parameters intended specifically for mongos that are actually allowed to be set on mongod, with untested behavior that may not have been thought through.

Comment by Amirsaman Memaripour [ 16/Feb/23 ]

The original feature aimed to add hedging only to mongos servers: https://www.mongodb.com/docs/manual/core/read-preference-hedge-option/

If hedging is a desired behavior for mongod servers, we should explicitly enable that by separating hedging from mongos-specific code, and test the behavior on mongod as well.

Comment by Max Hirschhorn [ 16/Feb/23 ]

What is the reason to disallow shards acting as routers (e.g. sharded $lookup) to hedge their requests the same way a mongos would?

Generated at Thu Feb 08 06:26:31 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.