Description
Before this ticket, if a prepared transaction failed it would always fail with NoSuchTransaction. Now, the error reported by a failed prepared transaction can take other values which may indicate what caused a shard to vote to abort (for example OperationNotSupportedInTransaction as described in the ticket).
Description of Linked Ticket
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.
Scope of changes
Impact to Other Docs
MVP (Work and Date)
Resources (Scope or Design Docs, Invision, etc.)
|