[SERVER-46796] Specific errors during prepare should get propagated to the client Created: 11/Mar/20  Updated: 29/Oct/23  Resolved: 28/Apr/20

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: None
Fix Version/s: 4.4.0-rc4, 4.7.0

Type: Improvement Priority: Major - P3
Reporter: Maria van Keulen Assignee: Gregory Noma
Resolution: Fixed Votes: 0
Labels: ShardedTxn:FutureOptimizations
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Documented
is documented by DOCS-13619 Investigate changes in SERVER-46796: ... Closed
Related
related to SERVER-44409 Add FSM test for creating indexes/col... Closed
Backwards Compatibility: Fully Compatible
Backport Requested:
v4.4
Sprint: Sharding 2020-05-04
Participants:

 Description   

SERVER-44409 adds a test that attempts (and fails) to do a prepared transaction that creates a collection. The failure is expected, since we presently disallow collection creation inside prepared transactions.

The test must presently check that commitTransaction_forTesting() fails with NoSuchTransaction, but the logs for the test confirm that the OperationNotSupportedInTransaction error does occur:

[js_test:create_new_collections_prepared_transactions] 2020-03-11T12:45:54.642-0400 d20022| {"t":{"$date":"2020-03-11T12:45:54.641-0400"},"s":"I", "c":"TXN",     "id":22483,"ctx":"conn28","msg":"Participant shard received prepareTransaction for transaction with txnNumber {opCtx_getTxnNumber} on session {opCtx_getLogicalSessionId}","attr":{"opCtx_getTxnNumber":0,"opCtx_getLogicalSessionId":{"id":{"$uuid":"8edc05c3-fc28-4e7d-9468-b353e9a6ac31"},"uid":{"$binary":{"base64":"47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=","subType":"0"}}}}}
[js_test:create_new_collections_prepared_transactions] 2020-03-11T12:45:54.643-0400 d20022| {"t":{"$date":"2020-03-11T12:45:54.642-0400"},"s":"I", "c":"TXN",     "id":51802,"ctx":"conn28","msg":"transaction","attr":{"parameters":{"lsid":{"id":{"$uuid":"8edc05c3-fc28-4e7d-9468-b353e9a6ac31"},"uid":{"$binary":{"base64":"47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=","subType":"0"}}},"txnNumber":0,"autocommit":false,"readConcern":{"provenance":"clientSupplied"}},"readTimestamp":"Timestamp(0, 0)","terminationCause":"aborted","timeActiveMicros":58189,"timeInactiveMicros":121171,"numYields":0,"locks":{"ReplicationStateTransition":{"acquireCount":{"w":3}},"Global":{"acquireCount":{"w":2}},"Database":{"acquireCount":{"w":2}},"Collection":{"acquireCount":{"r":1,"w":2}},"Mutex":{"acquireCount":{"r":3}}},"storage":{},"wasPrepared":false,"durationMillis":179}}
[js_test:create_new_collections_prepared_transactions] 2020-03-11T12:45:54.643-0400 d20020| {"t":{"$date":"2020-03-11T12:45:54.643-0400"},"s":"D3","c":"TXN",     "id":22479,"ctx":"TransactionCoordinator","msg":"{txnIdToString_lsid_txnNumber} Coordinator shard received {status} from shard {shardId} for {commandObj}","attr":{"txnIdToString_lsid_txnNumber":"8edc05c3-fc28-4e7d-9468-b353e9a6ac31:0","status":{"code":263,"codeName":"OperationNotSupportedInTransaction","errmsg":"Cannot create new collections inside distributed transactions"},"shardId":"create_new_collections_prepared_transactions-rs0","commandObj":{"prepareTransaction":1,"lsid":{"id":{"$uuid":"8edc05c3-fc28-4e7d-9468-b353e9a6ac31"},"uid":{"$binary":{"base64":"47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=","subType":"0"}}},"txnNumber":0,"autocommit":false,"writeConcern":{"w":"majority"}}}}

It seems that the coordinator shard does not propagate the OperationNotSupportedInTransaction error to the caller. It would be nice to propagate errors during prepare to more clearly communicate what caused the prepare to fail.



 Comments   
Comment by Githook User [ 30/Apr/20 ]

Author:

{'name': 'Gregory Noma', 'email': 'gregory.noma@gmail.com', 'username': 'gregorynoma'}

Message: SERVER-46796 Propagate specific errors during transaction prepare to the client

(cherry picked from commit c3652beac9345444f2961724ecb655afa93195ce)
Branch: v4.4
https://github.com/mongodb/mongo/commit/6438d5eaaaca15a251854d7344e3e49fba894d3e

Comment by Githook User [ 28/Apr/20 ]

Author:

{'name': 'Gregory Noma', 'email': 'gregory.noma@gmail.com', 'username': 'gregorynoma'}

Message: SERVER-46796 Propagate specific errors during transaction prepare to the client
Branch: master
https://github.com/mongodb/mongo/commit/c3652beac9345444f2961724ecb655afa93195ce

Comment by Esha Maharishi (Inactive) [ 31/Mar/20 ]

Bringing this back into Needs Scheduling to take into account the new information Maria noted.

Comment by Esha Maharishi (Inactive) [ 11/Mar/20 ]

Here is where the coordinateCommitTransaction command loses information about the specific error code returned from a participant for prepare.

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