[JAVA-3658]  Improve maxCommitTime timeout error message Created: 11/Mar/20  Updated: 18/Mar/20  Resolved: 18/Mar/20

Status: Closed
Project: Java Driver
Component/s: Error Handling
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Jennifer Huang (Inactive) Assignee: Jeffrey Yemin
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Customer claim, in the Java driver, or probably other drivers, the error message clients get is not clear in the following scenario.

1. When maxCommitTime is set, if a transaction timed out because of writeconcern not met the error message is:

Caused by: com.mongodb.MongoExecutionTimeoutException: operation exceeded time limit

2. When the maxCommitTime is set, but the transaction timed out for commit issues other than writeconcern not met, the error is the same.

Caused by: com.mongodb.MongoExecutionTimeoutException: operation exceeded time limit

Can we make this distinguishable? There're cases where customers wants to retry a transaction in scenario 2, but not 1.



 Comments   
Comment by Jennifer Huang (Inactive) [ 18/Mar/20 ]

nothing wrong with the driver

Comment by Jeffrey Yemin [ 18/Mar/20 ]

Yes, it sounds right. The server will report an error based on the first timeout that is encountered.

Comment by Jennifer Huang (Inactive) [ 18/Mar/20 ]

hey jeff.yemin

I created the first condition, "When maxCommitTime is set, if a transaction timed out because of writeconcern not met"

Got two types of errors depends on whether the maxCommitTime or the writeconcern timeout first.

If I set maxCommitTime shorter than wtimeoutMS so commit timeout first I get MongoExecutionTimeoutException error, code 50 and label [UnknownTransactionCommitResult] :

code is: 50
labels is: [UnknownTransactionCommitResult]
message is: operation exceeded time limit
com.mongodb.MongoExecutionTimeoutException: operation exceeded time limit
	at com.mongodb.internal.connection.ProtocolHelper.createSpecialException(ProtocolHelper.java:239)
	at com.mongodb.internal.connection.ProtocolHelper.createSpecialException(ProtocolHelper.java:246)
	at com.mongodb.internal.operation.WriteConcernHelper.throwOnSpecialException(WriteConcernHelper.java:52)
	at com.mongodb.internal.operation.WriteConcernHelper.throwOnWriteConcernError(WriteConcernHelper.java:46)
	at com.mongodb.operation.CommandOperationHelper$1.apply(CommandOperationHelper.java:145)
	at com.mongodb.operation.CommandOperationHelper$1.apply(CommandOperationHelper.java:142)
	at com.mongodb.operation.CommandOperationHelper$13.call(CommandOperationHelper.java:710)
	at com.mongodb.operation.OperationHelper.withReleasableConnection(OperationHelper.java:501)
	at com.mongodb.operation.CommandOperationHelper.executeRetryableCommand(CommandOperationHelper.java:703)
	at com.mongodb.operation.TransactionOperation.execute(TransactionOperation.java:70)
	at com.mongodb.operation.CommitTransactionOperation.execute(CommitTransactionOperation.java:133)
	at com.mongodb.operation.CommitTransactionOperation.execute(CommitTransactionOperation.java:53)
	at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.execute(MongoClientDelegate.java:213)
	at com.mongodb.client.internal.ClientSessionImpl.commitTransaction(ClientSessionImpl.java:129)
	at com.tour.QuickTour.main(QuickTour.java:70)

If I set maxCommitTime longer than wtimeoutMS so writeconcern timeout first I got MongoWriteConcernException, code 64 and label: [UnknownTransactionCommitResult]

code is: 64
labels is: [UnknownTransactionCommitResult]
message is: waiting for replication timed out
com.mongodb.MongoWriteConcernException: waiting for replication timed out
	at com.mongodb.internal.operation.WriteConcernHelper.createWriteConcernException(WriteConcernHelper.java:64)
	at com.mongodb.internal.operation.WriteConcernHelper.throwOnWriteConcernError(WriteConcernHelper.java:47)
	at com.mongodb.operation.CommandOperationHelper$1.apply(CommandOperationHelper.java:145)
	at com.mongodb.operation.CommandOperationHelper$1.apply(CommandOperationHelper.java:142)
	at com.mongodb.operation.CommandOperationHelper$13.call(CommandOperationHelper.java:710)
	at com.mongodb.operation.OperationHelper.withReleasableConnection(OperationHelper.java:501)
	at com.mongodb.operation.CommandOperationHelper.executeRetryableCommand(CommandOperationHelper.java:703)
	at com.mongodb.operation.TransactionOperation.execute(TransactionOperation.java:70)
	at com.mongodb.operation.CommitTransactionOperation.execute(CommitTransactionOperation.java:133)
	at com.mongodb.operation.CommitTransactionOperation.execute(CommitTransactionOperation.java:53)
	at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.execute(MongoClientDelegate.java:213)
	at com.mongodb.client.internal.ClientSessionImpl.commitTransaction(ClientSessionImpl.java:129)
	at com.tour.QuickTour.main(QuickTour.java:70)

Didn't create the 2nd condition tho, not sure how to get transaction commit timeout other than writeconcern not met, but it seem whenever maxCommitTime timed out first the MongoExecutionTimeoutException is thrown and according to the code the error code is 50.

Customer wants to be able to tell whether the timeout is caused by writeconcern or some other factor, I believe they can distinguish that by alway set maxCommitTime longer than wtimeoutMS and see whether the error is MongoWriteConcernException or MongoExecutionTimeoutException, MongoWriteConcernException = writeconcern timeout failed the commit, MongoExecutionTimeoutException = something else failed the commit.

Does that sound right to you?

Comment by Jeffrey Yemin [ 16/Mar/20 ]

Not sure what you mean by over-written. Can you provide some evidence (e.g. server logs) that the server is returning error code 50 for a write concern error?

Comment by Jeffrey Yemin [ 11/Mar/20 ]

Looking at the driver source code, it looks like the only error code for which we create this exception type is 50.

Comment by Jeffrey Yemin [ 11/Mar/20 ]

Hi jennifer.huang, just to make sure we understand exactly what the customer is experiencing, please provide full stack traces for both exceptions.

I'm also curious, if they can't distinguish between the two, how they know that the exceptions are for different reasons?

Generated at Thu Feb 08 09:00:08 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.