You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// TODO: see https://docs.couchbase.com/java-sdk/current/howtos/distributed-acid-transactions-from-the-sdk.html#:~:text=The%20lambda%20gets%20passed%20an%20AttemptContext%20object%2C%20generally%20referred%20to%20as%20ctx%20here.
`get` will cause the transaction to fail with `TransactionFailed` (after rolling back any changes, of course).
102
+
`get` will cause the transaction to fail with `TransactionFailedError` (after rolling back any changes, of course).
107
103
It is provided as a convenience method so the developer does not have to check the `Optional` if the document must exist for the transaction to succeed.
108
104
109
105
Gets will 'read your own writes', e.g. this will succeed:
@@ -113,15 +109,16 @@ Gets will 'read your own writes', e.g. this will succeed:
<1> As with the 'Read Your Own Writes' example, here the insert is only staged, and so it is not visible to other transactions or non-transactional actors.
176
178
<2> But the SELECT can view it, as the insert was in the same transaction.
177
179
178
180
=== Query Options
179
-
Query options can be provided via `TransactionsQueryOptions`, which provides a subset of the options in the Node.js SDK's `QueryOptions`.
181
+
182
+
Query options can be provided via `TransactionQueryOptions`, which provides a subset of the options in the Node.js SDK's `QueryOptions`.
This section is optional reading, and only for those looking to maximize transactions performance.
196
-
197
-
After the first query statement in a transaction, subsequent Key-Value operations in the lambda are converted into N1QL and executed by the query service rather than the Key-Value data service.
198
-
The operation will behave identically, and this implementation detail can largely be ignored, except for this caveat:
199
-
200
-
* These converted Key-Value operations are likely to be slightly slower, as the query service is optimised for statements involving multiple documents.
201
-
Those looking for the maximum possible performance are recommended to put Key-Value operations before the first query in the lambda, if possible.
// A complete version of this example is available on our https://github.com/couchbaselabs/couchbase-transactions-nodejs-examples[GitHub transactions examples page].
There are three errors that Couchbase transactions can raise to the application: `TransactionFailedError`, `TransactionExpiredError` and `TransactionCommitAmbiguousError`.
287
291
288
-
// TODO: this partial below has a lot of Java specifics in it
|`cleanupWindow`|60 seconds|This determines how long a cleanup 'run' is; that is, how frequently this client will check its subset of ATR documents. It is perfectly valid for the application to change this setting, which is at a conservative default. Decreasing this will cause expiration transactions to be found more swiftly (generally, within this cleanup window), with the tradeoff of increasing the number of reads per second used for the scanning process.
328
+
|`disableLostAttemptCleanup`|true|This is the thread that takes part in the distributed cleanup process described above, that cleans up expired transactions created by any client. It is strongly recommended that it is left enabled.
329
+
|`disableClientAttemptCleanup`|true|This thread is for cleaning up transactions created just by this client. The client will preferentially aim to send any transactions it creates to this thread, leaving transactions for the distributed cleanup process only when it is forced to (for example, on an application crash). It is strongly recommended that it is left enabled.
330
+
|===
312
331
313
332
=== Monitoring Cleanup
314
333
315
334
To monitor cleanup, increase the verbosity on the logging.
316
335
317
-
//TODO: once events are available, re-add the below
336
+
//TODO: once events are available, re-add the below with relevant examples
@@ -380,7 +399,7 @@ There are two rules the application needs to follow:
380
399
381
400
* The first mutation must be performed alone, in serial.
382
401
This is because the first mutation also triggers the creation of metadata for the transaction.
383
-
* All concurrent operations must be allowed to complete fully, so the transaction library can track which operations need to be rolled back in the event of failure.
402
+
* All concurrent operations must be allowed to complete fully, so the transaction can track which operations need to be rolled back in the event of failure.
384
403
This means the application must 'swallow' the error, but record that an error occurred, and then at the end of the concurrent operations, if an error occurred, throw an error to cause the transaction to retry.
385
404
386
405
// TODO: update this for node
@@ -437,5 +456,4 @@ This means the application must 'swallow' the error, but record that an error oc
437
456
//The transaction expiry timer (which is configurable) will begin ticking once the transaction starts, and is not paused while the transaction is in a deferred state.
438
457
439
458
440
-
// TODO: this partial points to the java examples repo
0 commit comments