You should be able to run the script via the cbq-shell if you’ve a local CE install.
Try manually first to verify perhaps?
e.g.
cbq> begin work;
{
"requestID": "d6c5eda7-568a-4ff2-801c-959379821b15",
"signature": "json",
"results": [
{
"nodeUUID": "366d019c74290d2af974b7cd3092d54f",
"txid": "addde394-92b4-4a1e-8af8-ae543c6cbb25"
}
],
"status": "success",
"metrics": {
"elapsedTime": "79.642764ms",
"executionTime": "73.807839ms",
"resultCount": 1,
"resultSize": 118,
"serviceLoad": 3,
"transactionElapsedTime": "27.281911ms",
"transactionRemainingTime": "1m59.97270126s"
}
}
cbq> set transaction isolation level read committed;
{
"requestID": "a77ca0df-eb95-4db1-9fad-5dc1102a0542",
"signature": "json",
"results": [
],
"status": "success",
"metrics": {
"elapsedTime": "1.221257ms",
"executionTime": "964.277µs",
"resultCount": 0,
"resultSize": 0,
"serviceLoad": 0,
"transactionElapsedTime": "6.821475895s",
"transactionRemainingTime": "1m53.178507012s"
}
}
cbq> rollback;
{
"requestID": "56a62937-964c-4000-9f16-f4196c3b13a2",
"signature": "json",
"results": [
],
"status": "success",
"metrics": {
"elapsedTime": "2.997623ms",
"executionTime": "2.816776ms",
"resultCount": 0,
"resultSize": 0,
"serviceLoad": 0,
"transactionElapsedTime": "13.764240079s"
}
}
Or via the rest end point - https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/transactions.html#query-tools - but in particular the BEGIN WORK responds with a txid
value. This must be supplied to the REST endpoint with each subsequent request that is part of the transaction.
e.g:
$ /usr/bin/curl -su $UID_PWD http://192.168.2.22:8093/query/service -d 'pretty=true&txtimeout=75s&statement=begin work'
{
"requestID": "062a5521-2e31-4482-9a4e-702e63f71fac",
"signature": "json",
"results": [
{
"nodeUUID": "366d019c74290d2af974b7cd3092d54f",
"txid": "75f64e0b-d015-4520-8325-a08336962337"
}
],
"status": "success",
"metrics": {
"elapsedTime": "28.824627ms",
"executionTime": "28.699877ms",
"resultCount": 1,
"resultSize": 118,
"serviceLoad": 3,
"transactionElapsedTime": "28.186275ms",
"transactionRemainingTime": "1m14.971797119s"
}
}
$ /usr/bin/curl -su $UID_PWD http://192.168.2.22:8093/query/service -d 'pretty=true&statement=set transaction isolation level read committed&txid=75f64e0b-d015-4520-8325-a08336962337'
{
"requestID": "fff35c7f-e83a-4eb3-94d3-4afd1f668c1c",
"signature": "json",
"results": [
],
"status": "success",
"metrics": {
"elapsedTime": "377.148µs",
"executionTime": "320.811µs",
"resultCount": 0,
"resultSize": 0,
"serviceLoad": 0,
"transactionElapsedTime": "41.811171264s",
"transactionRemainingTime": "33.188822407s"
}
}
$ /usr/bin/curl -su $UID_PWD http://192.168.2.22:8093/query/service -d 'pretty=true&statement=rollback&txid=75f64e0b-d015-4520-8325-a08336962337'
{
"requestID": "6b1bb647-8ff8-41c0-aeb4-8289005e842d",
"signature": "json",
"results": [
],
"status": "success",
"metrics": {
"elapsedTime": "794.224µs",
"executionTime": "592.333µs",
"resultCount": 0,
"resultSize": 0,
"serviceLoad": 0,
"transactionElapsedTime": "56.515037121s"
}
}
Could you verify either of these approaches work for you?
FWIW, I verified on:
cbq> select ds_version();
{
"requestID": "e2e6a017-de02-4699-8b76-8066e502b2a8",
"signature": {
"$1": "string"
},
"results": [
{
"$1": "7.6.2-3721-community"
And confirmed in the Query Workbench:
[
{
"_sequence_num": 1,
"_sequence_query": "begin work;",
"_sequence_query_status": "success",
"_sequence_result": [
{
"txid": "5d729712-2e08-49ef-85ea-db6cf58c6540"
}
]
},
{
"_sequence_num": 2,
"_sequence_query": "\nset transaction isolation level read committed;",
"_sequence_query_status": "success",
"_sequence_result": {
"results": []
}
},
{
"_sequence_num": 3,
"_sequence_query": "\nrollback;",
"_sequence_query_status": "success",
"_sequence_result": {
"results": []
}
}
]