Transactions Support for Eventing

Hello,

With the latest versions of Couchbase and Couchbase SDKs, support for transactions has been provided for both N1QL Statements as well as KV Ops.

What is the current state of support for transactions within the Eventing service on the latest version of couchbase? If not supported, is it on the roadmap? or is it generally advised to make a CURL to an internal API that can facilitate that transaction business logic there.

Best,
Alex Frye

N1QL javascript udf supports transactions see if that can be option to add your logic. cc @Marco_Greco

Is there a docs page reference with an example of this?

Java Script udf : You searched for java script udf - The Couchbase Blog
If accessable UDFs with transactions examples : py-tpcc/tpccfuncswithN1QL.js at py3 · couchbaselabs/py-tpcc · GitHub

As mentioned in the blog From N1QL to JavaScript and Back - Part 3: Iterating over Documents and DML - The Couchbase Blog DML statements examples you can add

var qb = BEGIN WORK;
var qc = COMMIT WORK;
var qr = ROLLBACK WORK;

Hey Alex one thing to be aware of in Eventing transactions “begin work”, “commit work”, and “rollback work” currently can “leak” some unexpected mutations so that you might get extra document(s) that are unexpected on a update/insert or on a delete so you have to be very careful about when you use transactions and eventing together.

Of course we plan to fix this but there is no definitive roadmap or release time for this I’m pushing to get it fixed sooner than later hope this helps.

@jon.strabala
What do you mean by “leak” unexpected mutations?
As in, eventing may pick up the uncommitted transaction state and process the mutation?

Also, are there any solutions for KV and transactions? Looks like the solution provided are for DML Query Statements Only. SDKs have the ability to perform both KV and Query operations within a ctx context.

sample from NodeJS sdk

cluster.transactions().run(async (ctx) => {
  await ctx.insert(collection, 'docId', {})
})

Hi @alex.frye

Yes as you surmised:

I will DM you the complete details

Best

Jon Strabala
Principal Product Manager - Server‌

Hi @jon.strabala , is this topic fixed in any version of Couchbase or is still present in the version 7.2? I see this in the documentation “All Couchbase services only see committed data. Uncommitted transaction modifications (i.e. dirty data) are never visible to any Couchbase service.”
Many thanks in advance

Can you send me the link, I’m pretty sure Eventing still leaks intermittent transaction mutations. Once I read the do I’ll retest and get back to (and get the docs updated if they are incorrect)