[SERVER-47690] mongos changes for snapshot reads Created: 21/Apr/20  Updated: 29/Oct/23  Resolved: 07/May/20

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

Type: Task Priority: Major - P3
Reporter: A. Jesse Jiryu Davis Assignee: A. Jesse Jiryu Davis
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-47996 Ban snapshot "distinct" outside trans... Closed
Related
related to SERVER-47915 Write commands silently ignore readCo... Closed
Backwards Compatibility: Fully Compatible
Sprint: Repl 2020-05-18
Participants:

 Description   

Select a timestamp for readConcern: "snapshot" reads that don't have atClusterTime. Forward the readConcern to shards. For snapshot reads that do have atClusterTime, use that timestamp for shard targeting. Make any changes required to store atClusterTime in mongos cursors' read concerns.

Return "atClusterTime" in replies to snapshot read commands. In ClusterFindCmd::run, add:

                // Build the response document.
                CursorResponseBuilder::Options options;
                options.isInitialResponse = true;
              + options.atClusterTime = repl::ReadConcernArgs::get(opCtx).getArgsAtClusterTime();
                CursorResponseBuilder firstBatch(result, options);

In establishMergingMongosCursor(), add:

    rpc::OpMsgReplyBuilder replyBuilder;
    CursorResponseBuilder::Options options;
    options.isInitialResponse = true;
  + options.atClusterTime = repl::ReadConcernArgs::get(opCtx).getArgsAtClusterTime();
    CursorResponseBuilder responseBuilder(&replyBuilder, options);

Audit uses of the CursorResponse class as well.

In cluster_distinct_cmd.cpp and cluster_find_cmd.cpp:

        result.appendArray("values", b.obj());
        if (repl::ReadConcernArgs::get(opCtx).getArgsAtClusterTime()) {
            result.append("atClusterTime"_sd,
                          repl::ReadConcernArgs::get(opCtx).getArgsAtClusterTime()->asTimestamp());
        }
 
        return true;

Support distinct on unsharded collections with snapshot reads, for consistency with transactions. (Ban snapshot distinct on sharded collections is SERVER-47996.)



 Comments   
Comment by Githook User [ 07/May/20 ]

Author:

{'name': 'A. Jesse Jiryu Davis', 'email': 'jesse@mongodb.com', 'username': 'ajdavis'}

Message: SERVER-47690 Snapshot reads via mongos
Branch: master
https://github.com/mongodb/mongo/commit/b17baeb4a77d8400e0283db06ae3a959e05b2560

Comment by Lingzhi Deng [ 29/Apr/20 ]

This ticket will likely need to modify applyReadWriteConcern on how to append readConcern when sending commands to shards. This is also essential for aggregations that involve direct shard-to-shard communications (e.g. $unionWith on sharded collections).

Comment by A. Jesse Jiryu Davis [ 28/Apr/20 ]

On a branch, I have the start of a sharding test for snapshot reads. We need to test find/aggregate/distinct, with standalone/RS shards, with/without causal consistency. With RS shards, we need to test primary/secondary reads.

Generated at Thu Feb 08 05:14:57 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.