CINXE.COM
Transaction rollback did not happen on error - Java SDK - Couchbase Forums
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Transaction rollback did not happen on error - Java SDK - Couchbase Forums</title> <meta name="description" content="Hi, I am using couchbase for first-time. I have a use-case of inserting new documents to couchbase ( all or none). On exception in transaction block, rollback of already inserted documents did not happen. Can you p&hellip;"> <meta name="generator" content="Discourse 3.4.0.beta3-dev - https://github.com/discourse/discourse version d71016522e8d9bb21c20312388271f8f0dd53069"> <link rel="icon" type="image/png" href="https://global.discourse-cdn.com/couchbase/optimized/2X/5/5c3358874946bfe880e9bf3ffda96c2bc67451a6_2_32x32.png"> <link rel="apple-touch-icon" type="image/png" href="https://global.discourse-cdn.com/couchbase/optimized/2X/b/b979c51a7b008edb40f4aaf42a8b8946bc100805_2_180x180.png"> <meta name="theme-color" media="all" content="#ffffff"> <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, user-scalable=yes, viewport-fit=cover"> <meta name="discourse-base-uri" content="/forums"> <link rel="canonical" href="https://www.couchbase.com/forums/t/transaction-rollback-did-not-happen-on-error/26315" /> <link rel="search" type="application/opensearchdescription+xml" href="https://www.couchbase.com/forums/opensearch.xml" title="Couchbase Forums Search"> <link href="https://sea2.discourse-cdn.com/couchbase/forums/stylesheets/color_definitions_couchbase-peach_9_5_5cb96aa5e2369938dc8ab42643259653fabe1f22.css?__ws=www.couchbase.com" media="all" rel="stylesheet" class="light-scheme"/> <link href="https://sea2.discourse-cdn.com/couchbase/forums/stylesheets/desktop_563761dc59698b385e0a22720014aac74a53e956.css?__ws=www.couchbase.com" media="all" rel="stylesheet" data-target="desktop" /> <link href="https://sea2.discourse-cdn.com/couchbase/forums/stylesheets/checklist_563761dc59698b385e0a22720014aac74a53e956.css?__ws=www.couchbase.com" media="all" rel="stylesheet" data-target="checklist" /> <link href="https://sea2.discourse-cdn.com/couchbase/forums/stylesheets/discourse-ai_563761dc59698b385e0a22720014aac74a53e956.css?__ws=www.couchbase.com" media="all" rel="stylesheet" data-target="discourse-ai" /> <link href="https://sea2.discourse-cdn.com/couchbase/forums/stylesheets/discourse-akismet_563761dc59698b385e0a22720014aac74a53e956.css?__ws=www.couchbase.com" media="all" rel="stylesheet" data-target="discourse-akismet" /> <link href="https://sea2.discourse-cdn.com/couchbase/forums/stylesheets/discourse-algolia_563761dc59698b385e0a22720014aac74a53e956.css?__ws=www.couchbase.com" media="all" rel="stylesheet" data-target="discourse-algolia" /> <link href="https://sea2.discourse-cdn.com/couchbase/forums/stylesheets/discourse-cakeday_563761dc59698b385e0a22720014aac74a53e956.css?__ws=www.couchbase.com" media="all" rel="stylesheet" data-target="discourse-cakeday" /> <link href="https://sea2.discourse-cdn.com/couchbase/forums/stylesheets/discourse-data-explorer_563761dc59698b385e0a22720014aac74a53e956.css?__ws=www.couchbase.com" media="all" rel="stylesheet" data-target="discourse-data-explorer" /> <link href="https://sea2.discourse-cdn.com/couchbase/forums/stylesheets/discourse-details_563761dc59698b385e0a22720014aac74a53e956.css?__ws=www.couchbase.com" media="all" rel="stylesheet" data-target="discourse-details" /> <link href="https://sea2.discourse-cdn.com/couchbase/forums/stylesheets/discourse-lazy-videos_563761dc59698b385e0a22720014aac74a53e956.css?__ws=www.couchbase.com" media="all" rel="stylesheet" data-target="discourse-lazy-videos" /> <link href="https://sea2.discourse-cdn.com/couchbase/forums/stylesheets/discourse-local-dates_563761dc59698b385e0a22720014aac74a53e956.css?__ws=www.couchbase.com" media="all" rel="stylesheet" data-target="discourse-local-dates" /> <link href="https://sea2.discourse-cdn.com/couchbase/forums/stylesheets/discourse-narrative-bot_563761dc59698b385e0a22720014aac74a53e956.css?__ws=www.couchbase.com" media="all" rel="stylesheet" data-target="discourse-narrative-bot" /> <link href="https://sea2.discourse-cdn.com/couchbase/forums/stylesheets/discourse-policy_563761dc59698b385e0a22720014aac74a53e956.css?__ws=www.couchbase.com" media="all" rel="stylesheet" data-target="discourse-policy" /> <link href="https://sea2.discourse-cdn.com/couchbase/forums/stylesheets/discourse-presence_563761dc59698b385e0a22720014aac74a53e956.css?__ws=www.couchbase.com" media="all" rel="stylesheet" data-target="discourse-presence" /> <link href="https://sea2.discourse-cdn.com/couchbase/forums/stylesheets/discourse-solved_563761dc59698b385e0a22720014aac74a53e956.css?__ws=www.couchbase.com" media="all" rel="stylesheet" data-target="discourse-solved" /> <link href="https://sea2.discourse-cdn.com/couchbase/forums/stylesheets/discourse-templates_563761dc59698b385e0a22720014aac74a53e956.css?__ws=www.couchbase.com" media="all" rel="stylesheet" data-target="discourse-templates" /> <link href="https://sea2.discourse-cdn.com/couchbase/forums/stylesheets/discourse-topic-voting_563761dc59698b385e0a22720014aac74a53e956.css?__ws=www.couchbase.com" media="all" rel="stylesheet" data-target="discourse-topic-voting" /> <link href="https://sea2.discourse-cdn.com/couchbase/forums/stylesheets/footnote_563761dc59698b385e0a22720014aac74a53e956.css?__ws=www.couchbase.com" media="all" rel="stylesheet" data-target="footnote" /> <link href="https://sea2.discourse-cdn.com/couchbase/forums/stylesheets/hosted-site_563761dc59698b385e0a22720014aac74a53e956.css?__ws=www.couchbase.com" media="all" rel="stylesheet" data-target="hosted-site" /> <link href="https://sea2.discourse-cdn.com/couchbase/forums/stylesheets/poll_563761dc59698b385e0a22720014aac74a53e956.css?__ws=www.couchbase.com" media="all" rel="stylesheet" data-target="poll" /> <link href="https://sea2.discourse-cdn.com/couchbase/forums/stylesheets/spoiler-alert_563761dc59698b385e0a22720014aac74a53e956.css?__ws=www.couchbase.com" media="all" rel="stylesheet" data-target="spoiler-alert" /> <link href="https://sea2.discourse-cdn.com/couchbase/forums/stylesheets/discourse-ai_desktop_563761dc59698b385e0a22720014aac74a53e956.css?__ws=www.couchbase.com" media="all" rel="stylesheet" data-target="discourse-ai_desktop" /> <link href="https://sea2.discourse-cdn.com/couchbase/forums/stylesheets/discourse-topic-voting_desktop_563761dc59698b385e0a22720014aac74a53e956.css?__ws=www.couchbase.com" media="all" rel="stylesheet" data-target="discourse-topic-voting_desktop" /> <link href="https://sea2.discourse-cdn.com/couchbase/forums/stylesheets/poll_desktop_563761dc59698b385e0a22720014aac74a53e956.css?__ws=www.couchbase.com" media="all" rel="stylesheet" data-target="poll_desktop" /> <link href="https://sea2.discourse-cdn.com/couchbase/forums/stylesheets/desktop_theme_12_3b3fd8c4cf21c520c859b53baf942db44093f4e2.css?__ws=www.couchbase.com" media="all" rel="stylesheet" data-target="desktop_theme" data-theme-id="12" data-theme-name="discourse clickable topic"/> <link href="https://sea2.discourse-cdn.com/couchbase/forums/stylesheets/desktop_theme_10_8a136efa246e4387f8bc9a18cd8aca12839b273c.css?__ws=www.couchbase.com" media="all" rel="stylesheet" data-target="desktop_theme" data-theme-id="10" data-theme-name="modern category + group boxes"/> <link href="https://sea2.discourse-cdn.com/couchbase/forums/stylesheets/desktop_theme_5_f89064f5c5038e962192a189b00e8ffe7e150ead.css?__ws=www.couchbase.com" media="all" rel="stylesheet" data-target="desktop_theme" data-theme-id="5" data-theme-name="mint"/> <link href="https://sea2.discourse-cdn.com/couchbase/forums/stylesheets/desktop_theme_16_ccee876e260988f1d597208e08638270643b1be5.css?__ws=www.couchbase.com" media="all" rel="stylesheet" data-target="desktop_theme" data-theme-id="16" data-theme-name="couchbase 2"/> <link href="https://sea2.discourse-cdn.com/couchbase/forums/stylesheets/desktop_theme_4_8596d76310cca4d0fce172f25ba0599a919f2544.css?__ws=www.couchbase.com" media="all" rel="stylesheet" data-target="desktop_theme" data-theme-id="4" data-theme-name="header alignment fix"/> <!-- OneTrust Cookies Consent Notice start for couchbase.com --> <script src="https://cdn.cookielaw.org/scripttemplates/otSDKStub.js" type="text/javascript" charset="UTF-8" data-domain-script="748511ff-10bf-44bf-88b8-36382e5b5fd9" nonce="FWlxLU2S7dUFGWTeGsnbgENmF"></script> <!-- OneTrust Cookies Consent Notice end for couchbase.com --><script defer="" src="https://sea2.discourse-cdn.com/couchbase/forums/theme-javascripts/87b4efff34091d9be9e0da05837c945fe6220398.js?__ws=www.couchbase.com" data-theme-id="17" nonce="FWlxLU2S7dUFGWTeGsnbgENmF"></script> <link rel="alternate nofollow" type="application/rss+xml" title="RSS feed of 'Transaction rollback did not happen on error'" href="https://www.couchbase.com/forums/t/transaction-rollback-did-not-happen-on-error/26315.rss" /> <meta property="og:site_name" content="Couchbase Forums" /> <meta property="og:type" content="website" /> <meta name="twitter:card" content="summary" /> <meta name="twitter:image" content="https://global.discourse-cdn.com/couchbase/original/2X/0/01f9ae109c030e7bf64d0812eaa8a3b08cf5ce60.png" /> <meta property="og:image" content="https://global.discourse-cdn.com/couchbase/original/2X/3/3d0d79fb182d067253be4666da0e1ec321b9536b.svg" /> <meta property="og:url" content="https://www.couchbase.com/forums/t/transaction-rollback-did-not-happen-on-error/26315" /> <meta name="twitter:url" content="https://www.couchbase.com/forums/t/transaction-rollback-did-not-happen-on-error/26315" /> <meta property="og:title" content="Transaction rollback did not happen on error" /> <meta name="twitter:title" content="Transaction rollback did not happen on error" /> <meta property="og:description" content="Hi, I am using couchbase for first-time. I have a use-case of inserting new documents to couchbase ( all or none). On exception in transaction block, rollback of already inserted documents did not happen. Can you please guide me on resolving this issue. INFO: [com.couchbase.transactions][TransactionsStarted] Transactions successfully started, regular cleanup enabled=true, lost cleanup enabled=true Transaction f41309d3-7495-4d9b-9a12-6d79f4213cb7 failed 19:14:24.941 1/main/f4130 starting..." /> <meta name="twitter:description" content="Hi, I am using couchbase for first-time. I have a use-case of inserting new documents to couchbase ( all or none). On exception in transaction block, rollback of already inserted documents did not happen. Can you please guide me on resolving this issue. INFO: [com.couchbase.transactions][TransactionsStarted] Transactions successfully started, regular cleanup enabled=true, lost cleanup enabled=true Transaction f41309d3-7495-4d9b-9a12-6d79f4213cb7 failed 19:14:24.941 1/main/f4130 starting..." /> <meta property="og:article:section" content="Java SDK" /> <meta property="og:article:section:color" content="7BBDCB" /> <meta name="twitter:label1" value="Reading time" /> <meta name="twitter:data1" value="2 mins 🕑" /> <meta name="twitter:label2" value="Likes" /> <meta name="twitter:data2" value="1 ❤" /> <meta property="article:published_time" content="2020-06-08T04:05:14+00:00" /> <meta property="og:ignore_canonical" content="true" /> <script type="application/ld+json">{"@context":"http://schema.org","@type":"QAPage","name":"Transaction rollback did not happen on error","mainEntity":{"@type":"Question","name":"Transaction rollback did not happen on error","text":"Hi,\n\nI am using couchbase for first-time. I have a use-case of inserting new documents to couchbase ( all or none). On exception in transaction block, rollback of already inserted documents did not happen. Can you please guide me on resolving this issue.\n\nINFO: [com.couchbase.transactions][Tran…","upvoteCount":0,"answerCount":0,"datePublished":"2020-06-08T04:05:14.451Z","author":{"@type":"Person","name":"afsar0204","url":"https://www.couchbase.com/forums/u/afsar0204"}}}</script> </head> <body class="crawler browser-update"> <header> <a href="/forums/"> Couchbase Forums </a> </header> <div id="main-outlet" class="wrap" role="main"> <div id="topic-title"> <h1> <a href="/forums/t/transaction-rollback-did-not-happen-on-error/26315">Transaction rollback did not happen on error</a> </h1> <div class="topic-category" itemscope itemtype="http://schema.org/BreadcrumbList"> <span itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"> <a href="/forums/c/java-sdk/5" class="badge-wrapper bullet" itemprop="item"> <span class='badge-category-bg' style='background-color: #7BBDCB'></span> <span class='badge-category clear-badge'> <span class='category-name' itemprop='name'>Java SDK</span> </span> </a> <meta itemprop="position" content="1" /> </span> </div> </div> <div itemscope itemtype='http://schema.org/DiscussionForumPosting'> <meta itemprop='headline' content='Transaction rollback did not happen on error'> <link itemprop='url' href='https://www.couchbase.com/forums/t/transaction-rollback-did-not-happen-on-error/26315'> <meta itemprop='datePublished' content='2020-06-08T04:05:14Z'> <meta itemprop='articleSection' content='Java SDK'> <meta itemprop='keywords' content=''> <div itemprop='publisher' itemscope itemtype="http://schema.org/Organization"> <meta itemprop='name' content='Couchbase Forums'> <div itemprop='logo' itemscope itemtype="http://schema.org/ImageObject"> <meta itemprop='url' content='https://global.discourse-cdn.com/couchbase/original/2X/0/01f9ae109c030e7bf64d0812eaa8a3b08cf5ce60.png'> </div> </div> <div id='post_1' class='topic-body crawler-post'> <div class='crawler-post-meta'> <span class="creator" itemprop="author" itemscope itemtype="http://schema.org/Person"> <a itemprop="url" href='https://www.couchbase.com/forums/u/afsar0204'><span itemprop='name'>afsar0204</span></a> </span> <link itemprop="mainEntityOfPage" href="https://www.couchbase.com/forums/t/transaction-rollback-did-not-happen-on-error/26315"> <span class="crawler-post-infos"> <time datetime='2020-06-08T04:05:14Z' class='post-time'> June 8, 2020, 4:05am </time> <meta itemprop='dateModified' content='2020-06-08T04:05:14Z'> <span itemprop='position'>1</span> </span> </div> <div class='post' itemprop='text'> <p>Hi,</p> <p>I am using couchbase for first-time. I have a use-case of inserting new documents to couchbase ( all or none). On exception in transaction block, rollback of already inserted documents did not happen. Can you please guide me on resolving this issue.</p> <p>INFO: [com.couchbase.transactions][TransactionsStarted] Transactions successfully started, regular cleanup enabled=true, lost cleanup enabled=true<br> Transaction f41309d3-7495-4d9b-9a12-6d79f4213cb7 failed<br> 19:14:24.941 1/main/f4130 starting attempt 0/f41309d3-7495-4d9b-9a12-6d79f4213cb7/b3575448-1ff6-4d22-a593-fbf97805e214<br> 19:14:24.941 1/main/f4130 config: atrs=1024, expiry=15000msecs durability=MAJORITY per-txn config: durability=Optional.empty<br> 19:14:25.006 1/main/f4130/b3575 caught exception ‘com.couchbase.client.core.error.DocumentExistsException: Document with the given id already exists {“completed”:true,“coreId”:“0x148bf9af00000003”,“idempotent”:false,“lastChannelId”:“148BF9AF00000003/000000002CD6B508”,“lastDispatchedFrom”:“127.0.0.1:62332”,“lastDispatchedTo”:“localhost:11210”,“requestId”:10,“requestType”:“InsertRequest”,“retried”:0,“service”:{“bucket”:“payments-metadata-dev”,“collection”:"_default",“documentId”:“osn3”,“opaque”:“0x23”,“scope”:"_default",“syncDurability”:{“empty”:true,“present”:false},“type”:“kv”},“status”:“EXISTS”,“timeoutMs”:2500,“timings”:{“dispatchMicros”:2248,“encodingMicros”:143,“totalMicros”:3308,“serverMicros”:0}}’ in runBlocking, rethrowing<br> 19:14:25.007 1/main/f4130/b3575 com.couchbase.client.java.AsyncUtils.block(AsyncUtils.java:51)<br> 19:14:25.007 1/main/f4130/b3575 com.couchbase.client.java.Collection.insert(Collection.java:381)<br> 19:14:25.007 1/main/f4130/b3575 pymts_batch.cb3_0_1.cb3.lambda$0(cb3.java:2148)<br> 19:14:25.007 1/main/f4130/b3575 com.couchbase.transactions.TransactionsReactive.lambda$null$26(TransactionsReactive.java:521)<br> 19:14:25.007 1/main/f4130/b3575 reactor.core.publisher.MonoRunnable.call(MonoRunnable.java:73)<br> 19:14:25.007 1/main/f4130/b3575 reactor.core.publisher.MonoRunnable.call(MonoRunnable.java:32)<br> 19:14:25.007 1/main/f4130/b3575 reactor.core.publisher.FluxSubscribeOnCallable$CallableSubscribeOnSubscription.run(FluxSubscribeOnCallable.java:225)<br> 19:14:25.007 1/main/f4130/b3575 reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:68)<br> 19:14:25.007 1/main/f4130/b3575 reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:28)<br> 19:14:25.007 1/main/f4130/b3575 java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)<br> 19:14:25.007 1/main/f4130/b3575 java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)<br> 19:14:25.007 1/main/f4130/b3575 java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)<br> 19:14:25.007 1/main/f4130/b3575 java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)<br> Jun 07, 2020 7:14:25 PM com.couchbase.client.core.cnc.LoggingEventConsumer$Slf4JLogger info<br> INFO: [com.couchbase.transactions.cleanup.lost][TransactionLogEvent] new cluster config with 1 buckets<br> Jun 07, 2020 7:14:25 PM com.couchbase.client.core.cnc.LoggingEventConsumer$Slf4JLogger info<br> INFO: [com.couchbase.transactions.cleanup.lost][TransactionLogEvent] will start cleaning lost transactions on bucket payments-metadata-dev<br> 19:14:25.007 1/main/f4130/b3575 java.base/java.lang.Thread.run(Thread.java:834)<br> Jun 07, 2020 7:14:25 PM com.couchbase.client.core.cnc.LoggingEventConsumer$Slf4JLogger info<br> INFO: [com.couchbase.core][BucketOpenedEvent][138ms] Opened bucket “payments-metadata-dev” {“coreId”:“0x148bf9af00000003”}<br> 19:14:25.012 1/main/f4130/b3575 exception DocumentExistsException should not be retried, wrapping in AttemptWrappedExceptionNoRetry, rollback=true<br> 19:14:25.012 1/main/f4130/<> hit error com.couchbase.transactions.error.internal.AttemptWrappedExceptionNoRetry: com.couchbase.client.core.error.DocumentExistsException: Document with the given id already exists {“completed”:true,“coreId”:“0x148bf9af00000003”,“idempotent”:false,“lastChannelId”:“148BF9AF00000003/000000002CD6B508”,“lastDispatchedFrom”:“127.0.0.1:62332”,“lastDispatchedTo”:“localhost:11210”,“requestId”:10,“requestType”:“InsertRequest”,“retried”:0,“service”:{“bucket”:“payments-metadata-dev”,“collection”:"_default",“documentId”:“osn3”,“opaque”:“0x23”,“scope”:"_default",“syncDurability”:{“empty”:true,“present”:false},“type”:“kv”},“status”:“EXISTS”,“timeoutMs”:2500,“timings”:{“dispatchMicros”:2248,“encodingMicros”:143,“totalMicros”:3308,“serverMicros”:0}}<br> 19:14:25.012 1/main/f4130/b3575 rolling back on error<br> 19:14:25.013 1/main/f4130/b3575 Skipping cleanup request as no ATR entry to remove (due to no mutations)<br> 19:14:25.018 1/main/f4130/b3575 added attempt TransactionAttempt{id=b3575,state=NOT_STARTED,atr=/} after error<br> 19:14:25.018 1/main/f4130/b3575 rollback AttemptContextReactive{id=b3575,state=ROLLED_BACK,isDone=true,atr=/,staged=<span class="chcklst-box fa fa-square-o fa-fw"></span>} expiryOvertimeMode=false<br> 19:14:25.019 1/main/f4130/b3575 Calling rollback when it’s had no mutations, so nothing to do<br> 19:14:25.021 1/main/f4130/b3575 AttemptWrappedExceptionNoRetry raised, wrapping original exception ‘com.couchbase.client.core.error.DocumentExistsException: Document with the given id already exists {“completed”:true,“coreId”:“0x148bf9af00000003”,“idempotent”:false,“lastChannelId”:“148BF9AF00000003/000000002CD6B508”,“lastDispatchedFrom”:“127.0.0.1:62332”,“lastDispatchedTo”:“localhost:11210”,“requestId”:10,“requestType”:“InsertRequest”,“retried”:0,“service”:{“bucket”:“payments-metadata-dev”,“collection”:"_default",“documentId”:“osn3”,“opaque”:“0x23”,“scope”:"_default",“syncDurability”:{“empty”:true,“present”:false},“type”:“kv”},“status”:“EXISTS”,“timeoutMs”:2500,“timings”:{“dispatchMicros”:2248,“encodingMicros”:143,“totalMicros”:3308,“serverMicros”:0}}’ in TransactionFailed<br> [statistics] disconnected</p> <p>Here is my Java code:</p> <p>Cluster cluster = Cluster.connect(“localhost”, “XXX”, “XXX”);<br> Bucket bucket = cluster.bucket(“XXX”);<br> Collection collection = bucket.defaultCollection();<br> Transactions transactions = Transactions.create(cluster, TransactionConfigBuilder.create().build());<br> try {<br> transactions.run((ctx) -> {</p> <pre><code> try{ File file1 = FileUtils.getFile("/Users/309399/apps/test/osn.txt"); LineIterator it = FileUtils.lineIterator(file1, "UTF-8"); while (it.hasNext()) { String line = it.nextLine(); String documentId = line.split(",")[0]; String osnPayload = line.split(",")[1]; JsonObject content = JsonObject.create().put("payload", osnPayload); MutationResult insertResult = collection.insert(documentId, content); } } catch(IOException ex){ ex.printStackTrace(); } }); </code></pre> <p>} catch (TransactionFailed e) {<br> System.err.println(“Transaction " + e.result().transactionId() + " failed”);</p> <pre><code>for (LogDefer err : e.result().log().logs()) { System.err.println(err.toString()); } </code></pre> <p>}</p> </div> <div itemprop="interactionStatistic" itemscope itemtype="http://schema.org/InteractionCounter"> <meta itemprop="interactionType" content="http://schema.org/LikeAction"/> <meta itemprop="userInteractionCount" content="0" /> <span class='post-likes'></span> </div> </div> <div id='post_2' itemprop='comment' itemscope itemtype='http://schema.org/Comment' class='topic-body crawler-post'> <div class='crawler-post-meta'> <span class="creator" itemprop="author" itemscope itemtype="http://schema.org/Person"> <a itemprop="url" href='https://www.couchbase.com/forums/u/WB'><span itemprop='name'>WB</span></a> </span> <span class="crawler-post-infos"> <time itemprop='datePublished' datetime='2020-06-08T15:54:07Z' class='post-time'> June 8, 2020, 3:54pm </time> <meta itemprop='dateModified' content='2020-06-08T15:54:07Z'> <span itemprop='position'>2</span> </span> </div> <div class='post' itemprop='text'> <p>Hi,<br> The issue is happening as you are performing ‘normal’ inserts inside the transaction block, and not using the transaction AttemptContext “ctx” to perform your inserts, here:</p> <pre><code class="lang-auto"> MutationResult insertResult = collection.insert(documentId, content); </code></pre> <p>Instead use something like this:<code> ctx.insert(collection, documentId, content);</code></p> <p>Hope this helps,<br> Will</p> </div> <div itemprop="interactionStatistic" itemscope itemtype="http://schema.org/InteractionCounter"> <meta itemprop="interactionType" content="http://schema.org/LikeAction"/> <meta itemprop="userInteractionCount" content="1" /> <span class='post-likes'>1 Like</span> </div> </div> <div id='post_3' itemprop='comment' itemscope itemtype='http://schema.org/Comment' class='topic-body crawler-post'> <div class='crawler-post-meta'> <span class="creator" itemprop="author" itemscope itemtype="http://schema.org/Person"> <a itemprop="url" href='https://www.couchbase.com/forums/u/afsar0204'><span itemprop='name'>afsar0204</span></a> </span> <span class="crawler-post-infos"> <time itemprop='datePublished' datetime='2020-06-08T18:20:14Z' class='post-time'> June 8, 2020, 6:20pm </time> <meta itemprop='dateModified' content='2020-06-08T18:20:14Z'> <span itemprop='position'>3</span> </span> </div> <div class='post' itemprop='text'> <p>Thanks Will, it worked as expected.</p> <p>11:16:11.670 1/main/3a356/<> hit error com.couchbase.transactions.error.internal.AttemptWrappedExceptionNoRetry: com.couchbase.client.core.error.DocumentExistsException: Document with the given id already exists {“documentId”:“osn3”}</p> <p>11:16:11.670 1/main/3a356/5ec3c rolling back on error</p> <p>11:16:11.671 1/main/3a356/5ec3c Adding cleanup request for _default/_txn:atr-636-<span class="hashtag">#35</span> to run in 15000 msecs</p> <p>11:16:11.674 1/main/3a356/5ec3c added attempt TransactionAttempt{id=5ec3c,state=PENDING,atrColl=com.couchbase.client.java.ReactiveCollection@3ecedf21/_txn:atr-636-<span class="hashtag">#35</span>} after error</p> <p>11:16:11.674 1/main/3a356/5ec3c rollback AttemptContextReactive{id=5ec3c,state=ROLLED_BACK,isDone=true,atr=_default/_txn:atr-636-<span class="hashtag">#35</span>,staged=[INSERT osn4, INSERT osn5]} expiryOvertimeMode=false</p> <p>11:16:11.678 1/main/3a356/5ec3c aborting AttemptContextReactive{id=5ec3c,state=ROLLED_BACK,isDone=true,atr=_default/_txn:atr-636-<span class="hashtag">#35</span>,staged=[INSERT osn4, INSERT osn5]}, expiryOvertimeMode=false</p> <p>11:16:11.690 1/main/3a356/5ec3c got ATR payments-metadata-dev/_default/_txn:atr-636-<span class="hashtag">#35</span> ATREntry{atr=payments-metadata-dev/_txn:atr-636-<span class="hashtag">#35</span>,attemptId=5ec3c0c0-c2ac-4194-a5a9-75ae0fbee621,state=PENDING,expires=Optional[15000]ms,[age=0ms,cas=1591640171626496000ns/1591640171626ms]<-Only Accurate If ATR Updated,inserted=Optional.empty,replaced=Optional.empty,removed=Optional.empty,start=Optional[1591640171626]ms}</p> <p>11:16:11.690 1/main/3a356/5ec3c aborting ATR payments-metadata-dev/_default/_txn:atr-636-<span class="hashtag">#35</span></p> <p>11:16:11.700 1/main/3a356/5ec3c aborted ATR payments-metadata-dev/_default/_txn:atr-636-<span class="hashtag">#35</span></p> <p>11:16:11.702 1/main/3a356/5ec3c deleting inserted doc osn4</p> <p>11:16:11.710 1/main/3a356/5ec3c deleted inserted doc osn4, mt Optional[mt{vbID=636, vbUUID=217152030880143, seqno=9, bucket=payments-metadata-dev}]</p> <p>11:16:11.711 1/main/3a356/5ec3c deleting inserted doc osn5</p> <p>11:16:11.726 1/main/3a356/5ec3c deleted inserted doc osn5, mt Optional[mt{vbID=379, vbUUID=90127317062542, seqno=5, bucket=payments-metadata-dev}]</p> <p>11:16:11.726 1/main/3a356/5ec3c marking ATR payments-metadata-dev/_default/_txn:atr-636-<span class="hashtag">#35</span> as rollback complete</p> <p>11:16:11.750 1/main/3a356/5ec3c rollback - atr rolled back</p> </div> <div itemprop="interactionStatistic" itemscope itemtype="http://schema.org/InteractionCounter"> <meta itemprop="interactionType" content="http://schema.org/LikeAction"/> <meta itemprop="userInteractionCount" content="0" /> <span class='post-likes'></span> </div> </div> <div id='post_4' itemprop='comment' itemscope itemtype='http://schema.org/Comment' class='topic-body crawler-post'> <div class='crawler-post-meta'> <span class="creator" itemprop="author" itemscope itemtype="http://schema.org/Person"> <a itemprop="url" href='https://www.couchbase.com/forums/u/WB'><span itemprop='name'>WB</span></a> </span> <span class="crawler-post-infos"> <time itemprop='datePublished' datetime='2020-06-08T18:34:41Z' class='post-time'> June 8, 2020, 6:34pm </time> <meta itemprop='dateModified' content='2020-06-08T18:34:41Z'> <span itemprop='position'>4</span> </span> </div> <div class='post' itemprop='text'> <p>That’s good to hear! No problem.</p> </div> <div itemprop="interactionStatistic" itemscope itemtype="http://schema.org/InteractionCounter"> <meta itemprop="interactionType" content="http://schema.org/LikeAction"/> <meta itemprop="userInteractionCount" content="0" /> <span class='post-likes'></span> </div> </div> </div> <div id="related-topics" class="more-topics__list " role="complementary" aria-labelledby="related-topics-title"> <h3 id="related-topics-title" class="more-topics__list-title"> Related topics </h3> <div class="topic-list-container" itemscope itemtype='http://schema.org/ItemList'> <meta itemprop='itemListOrder' content='http://schema.org/ItemListOrderDescending'> <table class='topic-list'> <thead> <tr> <th>Topic</th> <th></th> <th class="replies">Replies</th> <th class="views">Views</th> <th>Activity</th> </tr> </thead> <tbody> <tr class="topic-list-item" id="topic-list-item-33676"> <td class="main-link" itemprop='itemListElement' itemscope itemtype='http://schema.org/ListItem'> <meta itemprop='position' content='1'> <span class="link-top-line"> <a itemprop='url' href='https://www.couchbase.com/forums/t/cases-when-a-transaction-is-not-retried-but-it-would-succeed/33676' class='title raw-link raw-topic-link'>Cases when a transaction is not retried but it would succeed</a> </span> <div class="link-bottom-line"> <a href='/forums/c/java-sdk/5' class='badge-wrapper bullet'> <span class='badge-category-bg' style='background-color: #7BBDCB'></span> <span class='badge-category clear-badge'> <span class='category-name'>Java SDK</span> </span> </a> <div class="discourse-tags"> <a href='https://www.couchbase.com/forums/tag/java' class='discourse-tag'>java</a> , <a href='https://www.couchbase.com/forums/tag/sdk' class='discourse-tag'>sdk</a> </div> </div> </td> <td class="replies"> <span class='posts' title='posts'>6</span> </td> <td class="views"> <span class='views' title='views'>1550</span> </td> <td> June 1, 2022 </td> </tr> <tr class="topic-list-item" id="topic-list-item-33903"> <td class="main-link" itemprop='itemListElement' itemscope itemtype='http://schema.org/ListItem'> <meta itemprop='position' content='2'> <span class="link-top-line"> <a itemprop='url' href='https://www.couchbase.com/forums/t/couchbase-attempt-context-transaction-not-working-as-expected/33903' class='title raw-link raw-topic-link'>Couchbase attempt context transaction not working as expected</a> </span> <div class="link-bottom-line"> <a href='/forums/c/java-sdk/5' class='badge-wrapper bullet'> <span class='badge-category-bg' style='background-color: #7BBDCB'></span> <span class='badge-category clear-badge'> <span class='category-name'>Java SDK</span> </span> </a> <div class="discourse-tags"> </div> </div> </td> <td class="replies"> <span class='posts' title='posts'>1</span> </td> <td class="views"> <span class='views' title='views'>646</span> </td> <td> June 29, 2022 </td> </tr> <tr class="topic-list-item" id="topic-list-item-22785"> <td class="main-link" itemprop='itemListElement' itemscope itemtype='http://schema.org/ListItem'> <meta itemprop='position' content='3'> <span class="link-top-line"> <a itemprop='url' href='https://www.couchbase.com/forums/t/is-there-any-automatic-transaction-rollback-for-couch-base-document-so-that-we-can-restore-previous-version/22785' class='title raw-link raw-topic-link'>Is there any automatic transaction rollback for couch base document so that we can restore previous version</a> </span> <div class="link-bottom-line"> <a href='/forums/c/sql/16' class='badge-wrapper bullet'> <span class='badge-category-bg' style='background-color: #C71A25'></span> <span class='badge-category clear-badge'> <span class='category-name'>SQL++</span> </span> </a> <div class="discourse-tags"> <a href='https://www.couchbase.com/forums/tag/dot-net' class='discourse-tag'>dot-net</a> </div> </div> </td> <td class="replies"> <span class='posts' title='posts'>3</span> </td> <td class="views"> <span class='views' title='views'>1579</span> </td> <td> August 28, 2019 </td> </tr> <tr class="topic-list-item" id="topic-list-item-31345"> <td class="main-link" itemprop='itemListElement' itemscope itemtype='http://schema.org/ListItem'> <meta itemprop='position' content='4'> <span class="link-top-line"> <a itemprop='url' href='https://www.couchbase.com/forums/t/batch-insert-using-transactions/31345' class='title raw-link raw-topic-link'>Batch insert using transactions</a> </span> <div class="link-bottom-line"> <a href='/forums/c/net-sdk/6' class='badge-wrapper bullet'> <span class='badge-category-bg' style='background-color: #DD9933'></span> <span class='badge-category clear-badge'> <span class='category-name'>.NET SDK</span> </span> </a> <div class="discourse-tags"> <a href='https://www.couchbase.com/forums/tag/sdk' class='discourse-tag'>sdk</a> , <a href='https://www.couchbase.com/forums/tag/dot-net' class='discourse-tag'>dot-net</a> </div> </div> </td> <td class="replies"> <span class='posts' title='posts'>2</span> </td> <td class="views"> <span class='views' title='views'>1045</span> </td> <td> August 5, 2021 </td> </tr> <tr class="topic-list-item" id="topic-list-item-28006"> <td class="main-link" itemprop='itemListElement' itemscope itemtype='http://schema.org/ListItem'> <meta itemprop='position' content='5'> <span class="link-top-line"> <a itemprop='url' href='https://www.couchbase.com/forums/t/intermittently-couchbase-save-not-happening/28006' class='title raw-link raw-topic-link'>Intermittently: Couchbase Save Not Happening</a> </span> <div class="link-bottom-line"> <a href='/forums/c/java-sdk/5' class='badge-wrapper bullet'> <span class='badge-category-bg' style='background-color: #7BBDCB'></span> <span class='badge-category clear-badge'> <span class='category-name'>Java SDK</span> </span> </a> <div class="discourse-tags"> <a href='https://www.couchbase.com/forums/tag/query' class='discourse-tag'>query</a> </div> </div> </td> <td class="replies"> <span class='posts' title='posts'>1</span> </td> <td class="views"> <span class='views' title='views'>772</span> </td> <td> October 20, 2020 </td> </tr> </tbody> </table> </div> </div> </div> <footer class="container wrap"> <nav class='crawler-nav'> <ul> <li itemscope itemtype='http://schema.org/SiteNavigationElement'> <span itemprop='name'> <a href='/forums/' itemprop="url">Home </a> </span> </li> <li itemscope itemtype='http://schema.org/SiteNavigationElement'> <span itemprop='name'> <a href='/forums/categories' itemprop="url">Categories </a> </span> </li> <li itemscope itemtype='http://schema.org/SiteNavigationElement'> <span itemprop='name'> <a href='/forums/guidelines' itemprop="url">Guidelines </a> </span> </li> <li itemscope itemtype='http://schema.org/SiteNavigationElement'> <span itemprop='name'> <a href='https://www.couchbase.com/terms-of-use/' itemprop="url">Terms of Service </a> </span> </li> <li itemscope itemtype='http://schema.org/SiteNavigationElement'> <span itemprop='name'> <a href='https://www.couchbase.com/privacy-policy/' itemprop="url">Privacy Policy </a> </span> </li> </ul> </nav> <p class='powered-by-link'>Powered by <a href="https://www.discourse.org">Discourse</a>, best viewed with JavaScript enabled</p> </footer> <!-- EXPORTED TAGS --> <!-- Tags for Couchbase oneTag --> <!-- One Tag Conditional Container: Couchbase (6792) | Couchbase oneTag (5045) --> <script defer="" src="https://sea2.discourse-cdn.com/couchbase/forums/theme-javascripts/34713efacfccdc324338cc33fc0190f9dbf12b74.js?__ws=www.couchbase.com" data-theme-id="16" nonce="FWlxLU2S7dUFGWTeGsnbgENmF"></script> <div class="buorg"><div>Unfortunately, <a href="https://www.discourse.org/faq/#browser">your browser is unsupported</a>. Please <a href="https://browsehappy.com">switch to a supported browser</a> to view rich content, log in and reply.</div></div> </body> </html>