[SERVER-43983] No Such Transaction Created: 14/Oct/19  Updated: 06/Dec/19  Resolved: 06/Dec/19

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

Type: Bug Priority: Major - P3
Reporter: yeongseok kim Assignee: Danny Hatcher (Inactive)
Resolution: Incomplete Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Steps To Reproduce:

Start a transaction  in java application using java mongo driver's method 

session.startTransaction()

and then stop the application process on purpose in the middle. 

and then restart the app and start another transaction. 

and the abort transaction happens automatically, 

Participants:

 Description   

2019-10-13T22:20:36.753-0400 I COMMAND [conn3342] command BESPIN.AwsBillingDaily_1 command: delete \{ delete: "AwsBillingDaily_1", ordered: true, $db: "BESPIN", $clusterTime: { clusterTime: Timestamp(1571019627, 1), signature: { hash: BinData(0, 663871C3301BAF22C036E131D8FF4BBF57F3DD12), keyId: 6743826200705105950 } }, lsid: \{ id: UUID("8595004d-f6b1-4177-9b06-449e2f3a0088") }, txnNumber: 1, startTransaction: true, readConcern: \{ level: "local" }, autocommit: false } numYields:0 ok:0 errMsg:"Transaction 8595004d-f6b1-4177-9b06-449e2f3a0088:1 was aborted on statement 0 due to: an error from cluster data placement change :: caused by :: Encountered error from 10.251.245.205:27017 during a transaction :: caused by :: epoch mismatch detected for BESPIN.AwsBillingDaily_1, the collection may have been dropped and recreated" errName:StaleConfig errCode:13388 reslen:717 protocol:op_msg 1049ms
2019-10-13T22:20:36.754-0400 I COMMAND [conn3344] command BESPIN.AwsBillingMonthly_1 command: delete \{ delete: "AwsBillingMonthly_1", ordered: true, $db: "BESPIN", $clusterTime: { clusterTime: Timestamp(1571019627, 1), signature: { hash: BinData(0, 663871C3301BAF22C036E131D8FF4BBF57F3DD12), keyId: 6743826200705105950 } }, lsid: \{ id: UUID("8595004d-f6b1-4177-9b06-449e2f3a0088") }, txnNumber: 1, autocommit: false } numYields:0 ok:0 errMsg:"Encountered error from 10.251.245.98:27017 during a transaction :: caused by :: Transaction 1 has been aborted." errName:NoSuchTransaction errCode:251 reslen:380 protocol:op_msg 999ms



 Comments   
Comment by Danny Hatcher (Inactive) [ 08/Nov/19 ]

yeongseok.kim@bespinglobal.com, are you still having this issue? If so, could you please provide the information I requested in my last comment?

Comment by Danny Hatcher (Inactive) [ 21/Oct/19 ]

Due to not having the full context of the code base, I can't run your code locally thus cannot reproduce the issue. Can you place some debug statements in your code at every step of the error process you are reporting? Then run the application and provide the Java output as well as the mongod logs for the full process. I'd like to see the first transaction being started on the mongod, the second transaction being started, and that second transaction being aborted, all in the Java and the mongod logs.

Comment by yeongseok kim [ 18/Oct/19 ]

for more information, I have implemented the job in Spring Batch framework. and transaction is being handled in the provided method runBillingJobPerCompany. 

Comment by yeongseok kim [ 18/Oct/19 ]

public void runBillingJobPerCompany(String tableName, String siteCode, Map.Entry<Object, List> c) {
 String companyId = c.getKey().toString();
 List<Map<Object, Object>> list = c.getValue();
 
 try {
 retryTemplate.execute(new RetryCallback<Void, Exception>() {
 @Override
 public Void doWithRetry(RetryContext arg0) throws Exception {
 ClientSession session = client.startSession();
 awsBillingJobDataShareBean.setSession(session);
 
 if(awsBillingJobDataShareBean.getSession().hasActiveTransaction()){
 awsBillingJobDataShareBean.getSession().abortTransaction();
 }
 awsBillingJobDataShareBean.getSession().startTransaction();
 long transactionNumberToStart = awsBillingJobDataShareBean.getSession().getServerSession().getTransactionNumber();
 log.info("start transactionNumber >>"+String.valueOf(transactionNumberToStart));
 
 for (Map<Object, Object> o : list) {
 JobParameters jobParameters = getJobParametersForAwsBillingJob(tableName, siteCode, companyId, o);
 JobExecution awsBillingJobExecution = jobLauncher.run(awsBillingJob, jobParameters);
 }
 
 JobParameters awsBillingLatestDateUpdateJobParameters = getJobParametersForAwsBillingLatestDateUpdateJob(siteCode, companyId);
 JobExecution jobExecution = jobLauncher.run(awsBillingLatestDateUpdateJob, awsBillingLatestDateUpdateJobParameters);
 log.error(jobExecution.getFailureExceptions().toString());
 return null;
 }
 });
 long transactionNumberToCommit = awsBillingJobDataShareBean.getSession().getServerSession().getTransactionNumber();
 log.info("commit transactionNumber >>"+String.valueOf(transactionNumberToCommit));
 awsBillingJobDataShareBean.getSession().commitTransaction();
 }catch (Exception e){
 e.printStackTrace();
 awsBillingJobDataShareBean.getSession().abortTransaction();
 }finally {
 awsBillingJobDataShareBean.getSession().close();
 }
 
 
}

Comment by Danny Hatcher (Inactive) [ 17/Oct/19 ]

I'm unable to reproduce the issue you're reporting. If you provide the actual Java code that you are using to encounter the problem I can take a look.

Comment by yeongseok kim [ 15/Oct/19 ]

To Solve the problem, I temporarily deleted the collection. and then it worked. 

But, this workaround will affect service in production environment. 

So, I need to know what's root cause of this error. 

Comment by yeongseok kim [ 15/Oct/19 ]

Java driver version is the latest one. 3.11 sync version.
Java code is simple,

ClientSession session = client.startSession()
session.startTransaction()
Delete logic
Write logic with WriteConcern Local
session.CommitTransaction
Or abort if error comes up

Comment by Danny Hatcher (Inactive) [ 14/Oct/19 ]

Can you please provide a reproduction in Java code as well as the Java driver version you are using?

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