[SERVER-37458] Mongos does not apply commitTransaction's writeConcern Created: 03/Oct/18 Updated: 29/Oct/23 Resolved: 14/Dec/18 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Sharding |
| Affects Version/s: | None |
| Fix Version/s: | 4.1.7 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Shane Harvey | Assignee: | Esha Maharishi (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | ShardedTxn:DistributedCommit | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||
| Operating System: | ALL | ||||||||
| Steps To Reproduce: |
|
||||||||
| Sprint: | Sharding 2018-12-17 | ||||||||
| Participants: | |||||||||
| Description |
|
Mongos seems to ignore the user's writeConcern on commitTransaction. For example:
Notice writeConcern:{w:"foo"} which should cause an unknown write concern error. Tested on https://github.com/mongodb/mongo/commit/860b392d9d3c006090a4c7fc3c6f3fa5460e5c5c:
|
| Comments |
| Comment by Esha Maharishi (Inactive) [ 14/Dec/18 ] | ||||||||||||||
|
(Note, "2) The coordinator shard needs to set its Client's last OpTime to the system last opTime" was committed under | ||||||||||||||
| Comment by Githook User [ 14/Dec/18 ] | ||||||||||||||
|
Author: {'username': 'EshaMaharishi', 'email': 'esha.maharishi@mongodb.com', 'name': 'Esha Maharishi'}Message: | ||||||||||||||
| Comment by Githook User [ 09/Dec/18 ] | ||||||||||||||
|
Author: {'name': 'Esha Maharishi', 'email': 'esha.maharishi@mongodb.com', 'username': 'EshaMaharishi'}Message: | ||||||||||||||
| Comment by Esha Maharishi (Inactive) [ 04/Dec/18 ] | ||||||||||||||
|
Note, there is a bug in mongos's propagation of the client's writeConcern on coordinateCommitTransaction that means mongos is actually not propagating the client's writeConcern currently. The bug is that coordinateCommitCmd.toBSON(opCtx->getWriteConcern(), false) should instead be written coordinateCommitCmd.toBSON(BSON("writeConcern" << opCtx->getWriteConcern()), false). When I fixed the bug and ran a test of passing an invalid writeConcern to commitTransaction through mongos, I found that the shard currently returns this error:
This means, as part of this ticket, 1) The shard needs to be made to accept writeConcern on coordinateCommitTransaction here. 2) The coordinator shard needs to set its Client's last OpTime to the system last OpTime, to actually wait for writeConcern of the writes done in the background thread. | ||||||||||||||
| Comment by Esha Maharishi (Inactive) [ 13/Nov/18 ] | ||||||||||||||
|
Note: We might have already fixed this in However, until | ||||||||||||||
| Comment by Esha Maharishi (Inactive) [ 13/Nov/18 ] | ||||||||||||||
|
The fix is to make the coordinator shard respect the client's writeConcern; the router already forwards the client's writeConcern to the coordinator shard. | ||||||||||||||
| Comment by Shane Harvey [ 04/Oct/18 ] | ||||||||||||||
|
Can you expand on why the writeConcern is not configurable? Are there plans to make it configurable in the future? The main reason I'm concerned is that writeConcern is already supported by replica sets in 4.0 and it's part of the driver's api. So I think it would be confusing for writeConcern to be supported on a replica set but not supported in Mongos. And what about wtimeout? Is that ignored as well? | ||||||||||||||
| Comment by Randolph Tan [ 04/Oct/18 ] | ||||||||||||||
|
Note that writeConcern for mongos commitTransaction is currently not configurable (commit is internally done with w: majority). shane.harvey, would it be sufficient for your case that mongos validates that it should be majority if provided? |