aerospike 5.13.1 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/binding.gyp +7 -0
- package/examples/mrtAbort.js +58 -0
- package/examples/mrtCommit.js +57 -0
- package/examples/run.js +2 -0
- package/lib/abort_status.js +28 -0
- package/lib/aerospike.js +53 -0
- package/lib/binding/glibc@2.31/node-v108-linux-arm64/aerospike.node +0 -0
- package/lib/binding/glibc@2.31/node-v108-linux-x64/aerospike.node +0 -0
- package/lib/binding/glibc@2.31/node-v115-linux-arm64/aerospike.node +0 -0
- package/lib/binding/glibc@2.31/node-v115-linux-x64/aerospike.node +0 -0
- package/lib/binding/glibc@2.31/node-v127-linux-arm64/aerospike.node +0 -0
- package/lib/binding/glibc@2.31/node-v127-linux-x64/aerospike.node +0 -0
- package/lib/binding/glibc@2.31/node-v131-linux-arm64/aerospike.node +0 -0
- package/lib/binding/glibc@2.31/node-v131-linux-x64/aerospike.node +0 -0
- package/lib/binding/glibc@2.35/node-v108-linux-arm64/aerospike.node +0 -0
- package/lib/binding/glibc@2.35/node-v108-linux-x64/aerospike.node +0 -0
- package/lib/binding/glibc@2.35/node-v115-linux-arm64/aerospike.node +0 -0
- package/lib/binding/glibc@2.35/node-v115-linux-x64/aerospike.node +0 -0
- package/lib/binding/glibc@2.35/node-v127-linux-arm64/aerospike.node +0 -0
- package/lib/binding/glibc@2.35/node-v127-linux-x64/aerospike.node +0 -0
- package/lib/binding/glibc@2.35/node-v131-linux-arm64/aerospike.node +0 -0
- package/lib/binding/glibc@2.35/node-v131-linux-x64/aerospike.node +0 -0
- package/lib/binding/node-v108-darwin-arm64/aerospike.node +0 -0
- package/lib/binding/node-v108-darwin-x64/aerospike.node +0 -0
- package/lib/binding/node-v115-darwin-arm64/aerospike.node +0 -0
- package/lib/binding/node-v115-darwin-x64/aerospike.node +0 -0
- package/lib/binding/node-v127-darwin-arm64/aerospike.node +0 -0
- package/lib/binding/node-v127-darwin-x64/aerospike.node +0 -0
- package/lib/binding/node-v131-darwin-arm64/aerospike.node +0 -0
- package/lib/binding/node-v131-darwin-x64/aerospike.node +0 -0
- package/lib/client.js +45 -2
- package/lib/commands/index.js +2 -0
- package/lib/commit_status.js +30 -0
- package/lib/policies/base_policy.js +2 -0
- package/lib/status.js +36 -0
- package/lib/transaction.js +161 -0
- package/lib/transaction_pool.js +106 -0
- package/lib/txn_capacity.js +25 -0
- package/lib/txn_state.js +27 -0
- package/package.json +3 -2
- package/scripts/build-package.sh-cclient-output.log +8 -0
- package/src/include/async.h +8 -1
- package/src/include/client.h +2 -0
- package/src/include/conversions.h +7 -0
- package/src/include/enums.h +4 -1
- package/src/include/transaction.h +65 -0
- package/src/main/aerospike.cc +17 -1
- package/src/main/async.cc +28 -0
- package/src/main/client.cc +2 -0
- package/src/main/commands/transaction_abort.cc +60 -0
- package/src/main/commands/transaction_commit.cc +61 -0
- package/src/main/enums/abort_status.cc +39 -0
- package/src/main/enums/commit_status.cc +41 -0
- package/src/main/enums/status.cc +8 -0
- package/src/main/enums/txn_capacity.cc +37 -0
- package/src/main/enums/txn_state.cc +38 -0
- package/src/main/policy.cc +6 -0
- package/src/main/transaction.cc +176 -0
- package/src/main/util/conversions.cc +43 -0
- package/ts-test/package-lock.json +20 -9
- package/ts-test/package.json +1 -1
- package/ts-test/tests/batch_read.ts +12 -12
- package/ts-test/tests/batch_write.ts +2 -0
- package/ts-test/tests/client.ts +1 -1
- package/ts-test/tests/get.ts +6 -6
- package/ts-test/tests/mrt_api.ts +231 -0
- package/ts-test/tests/mrt_backward_compatible.ts +100 -0
- package/ts-test/tests/mrt_functionality.ts +175 -0
- package/ts-test/tests/operate.ts +6 -6
- package/ts-test/tests/query.ts +7 -2
- package/ts-test/tests/scan.ts +4 -2
- package/ts-test/tests/stats.ts +1 -1
- package/ts-test/tests/test_helper.ts +17 -0
- package/typings/index.d.ts +705 -4
package/README.md
CHANGED
|
@@ -340,6 +340,10 @@ To run all the test cases:
|
|
|
340
340
|
|
|
341
341
|
npm test
|
|
342
342
|
|
|
343
|
+
To run a specific tests, use:
|
|
344
|
+
|
|
345
|
+
npm test --testfile=filename.js
|
|
346
|
+
|
|
343
347
|
Note: make sure your server has TTL enabled for the `test` namespace ([Namespace Retention Configuration](https://docs.aerospike.com/server/operations/configure/namespace/retention)) to allow all tests to run correctly.
|
|
344
348
|
|
|
345
349
|
To run the tests and also report on test coverage:
|
package/binding.gyp
CHANGED
|
@@ -67,6 +67,7 @@
|
|
|
67
67
|
'sources': [
|
|
68
68
|
'src/main/aerospike.cc',
|
|
69
69
|
'src/main/client.cc',
|
|
70
|
+
'src/main/transaction.cc',
|
|
70
71
|
'src/main/config.cc',
|
|
71
72
|
'src/main/events.cc',
|
|
72
73
|
'src/main/cdt_ctx.cc',
|
|
@@ -125,11 +126,17 @@
|
|
|
125
126
|
'src/main/commands/scan_background.cc',
|
|
126
127
|
'src/main/commands/scan_pages.cc',
|
|
127
128
|
'src/main/commands/select_async.cc',
|
|
129
|
+
'src/main/commands/transaction_abort.cc',
|
|
130
|
+
'src/main/commands/transaction_commit.cc',
|
|
128
131
|
'src/main/commands/truncate.cc',
|
|
129
132
|
'src/main/commands/user_create.cc',
|
|
130
133
|
'src/main/commands/user_drop.cc',
|
|
131
134
|
'src/main/commands/udf_register.cc',
|
|
132
135
|
'src/main/commands/udf_remove.cc',
|
|
136
|
+
'src/main/enums/abort_status.cc',
|
|
137
|
+
'src/main/enums/commit_status.cc',
|
|
138
|
+
'src/main/enums/txn_state.cc',
|
|
139
|
+
'src/main/enums/txn_capacity.cc',
|
|
133
140
|
'src/main/enums/predicates.cc',
|
|
134
141
|
'src/main/enums/bitwise_enum.cc',
|
|
135
142
|
'src/main/enums/hll_enum.cc',
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright 2013-2024 Aerospike, Inc.
|
|
4
|
+
//
|
|
5
|
+
// Licensed under the Apache License, Version 2.0 (the "License")
|
|
6
|
+
// you may not use this file except in compliance with the License.
|
|
7
|
+
// You may obtain a copy of the License at
|
|
8
|
+
//
|
|
9
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
//
|
|
11
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
// See the License for the specific language governing permissions and
|
|
15
|
+
// limitations under the License.
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
//
|
|
18
|
+
const Aerospike = require('aerospike')
|
|
19
|
+
const shared = require('./shared')
|
|
20
|
+
|
|
21
|
+
shared.runner()
|
|
22
|
+
|
|
23
|
+
async function mrtAbort (client, argv) {
|
|
24
|
+
// sconst record1 = { abc: 123 }
|
|
25
|
+
const record2 = { def: 456 }
|
|
26
|
+
|
|
27
|
+
const mrt = new Aerospike.Transaction()
|
|
28
|
+
|
|
29
|
+
const policy = {
|
|
30
|
+
txn: mrt
|
|
31
|
+
}
|
|
32
|
+
const keyList = []
|
|
33
|
+
for (let i = 0; i < argv.keys.length; i++) {
|
|
34
|
+
keyList.push(new Aerospike.Key(argv.namespace, argv.set, argv.keys[i]))
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
for (let i = 0; i < keyList.length; i++) {
|
|
38
|
+
await client.put(keyList[i], record2, policy)
|
|
39
|
+
await client.get(keyList[i], policy)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
console.log(keyList)
|
|
43
|
+
|
|
44
|
+
console.log('aborting multi-record transaction with %d operations.', keyList.length * 2)
|
|
45
|
+
await client.abort(mrt)
|
|
46
|
+
console.info('multi-record transaction has been aborted.')
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
exports.command = 'mrtAbort <keys..>'
|
|
50
|
+
exports.describe = 'Abort a multi-record transaction'
|
|
51
|
+
exports.handler = shared.run(mrtAbort)
|
|
52
|
+
exports.builder = {
|
|
53
|
+
keys: {
|
|
54
|
+
desc: 'Provide keys for the records in the multi-record transaction',
|
|
55
|
+
type: 'array',
|
|
56
|
+
group: 'Command:'
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright 2013-2024 Aerospike, Inc.
|
|
4
|
+
//
|
|
5
|
+
// Licensed under the Apache License, Version 2.0 (the "License")
|
|
6
|
+
// you may not use this file except in compliance with the License.
|
|
7
|
+
// You may obtain a copy of the License at
|
|
8
|
+
//
|
|
9
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
//
|
|
11
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
// See the License for the specific language governing permissions and
|
|
15
|
+
// limitations under the License.
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
//
|
|
18
|
+
const Aerospike = require('aerospike')
|
|
19
|
+
const shared = require('./shared')
|
|
20
|
+
|
|
21
|
+
shared.runner()
|
|
22
|
+
|
|
23
|
+
async function mrtCommit (client, argv) {
|
|
24
|
+
// const record1 = { abc: 123 }
|
|
25
|
+
const record2 = { def: 456 }
|
|
26
|
+
|
|
27
|
+
const mrt = new Aerospike.Transaction()
|
|
28
|
+
|
|
29
|
+
const policy = {
|
|
30
|
+
txn: mrt
|
|
31
|
+
}
|
|
32
|
+
const keyList = []
|
|
33
|
+
for (let i = 0; i < argv.keys.length; i++) {
|
|
34
|
+
keyList.push(new Aerospike.Key(argv.namespace, argv.set, argv.keys[i]))
|
|
35
|
+
}
|
|
36
|
+
for (let i = 0; i < argv.keys.length; i++) {
|
|
37
|
+
await client.put(keyList[i], record2, policy)
|
|
38
|
+
await client.get(keyList[i], policy)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
console.log(keyList)
|
|
42
|
+
|
|
43
|
+
console.log('committing multi-record transaction with %d operations.', keyList.length * 2)
|
|
44
|
+
await client.commit(mrt)
|
|
45
|
+
console.info('multi-record transaction has been committed.')
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
exports.command = 'mrtCommit <keys..>'
|
|
49
|
+
exports.describe = 'Commit a multi-record transaction'
|
|
50
|
+
exports.handler = shared.run(mrtCommit)
|
|
51
|
+
exports.builder = {
|
|
52
|
+
keys: {
|
|
53
|
+
desc: 'Provide keys for the records in the multi-record transaction',
|
|
54
|
+
type: 'array',
|
|
55
|
+
group: 'Command:'
|
|
56
|
+
}
|
|
57
|
+
}
|
package/examples/run.js
CHANGED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright 2024 Aerospike, Inc.
|
|
3
|
+
//
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the 'License')
|
|
5
|
+
// you may not use this file except in compliance with the License.
|
|
6
|
+
// You may obtain a copy of the License at
|
|
7
|
+
//
|
|
8
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//
|
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
// distributed under the License is distributed on an 'AS IS' BASIS,
|
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
// See the License for the specific language governing permissions and
|
|
14
|
+
// limitations under the License.
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
'use strict'
|
|
18
|
+
|
|
19
|
+
const as = require('bindings')('aerospike.node')
|
|
20
|
+
const abortStatus = as.abortStatus
|
|
21
|
+
|
|
22
|
+
module.exports = {
|
|
23
|
+
OK: abortStatus.OK,
|
|
24
|
+
ALREADY_COMMITTED: abortStatus.ALREADY_COMMITTED,
|
|
25
|
+
ALREADY_ABORTED: abortStatus.ALREADY_ABORTED,
|
|
26
|
+
ROLL_BACK_ABANDONED: abortStatus.ROLL_BACK_ABANDONED,
|
|
27
|
+
CLOSE_ABANDONED: abortStatus.CLOSE_ABANDONED
|
|
28
|
+
}
|
package/lib/aerospike.js
CHANGED
|
@@ -19,7 +19,11 @@
|
|
|
19
19
|
const as = require('bindings')('aerospike.node')
|
|
20
20
|
const AerospikeError = require('./error')
|
|
21
21
|
const EventLoop = require('./event_loop')
|
|
22
|
+
const TransactionPool = require('./transaction_pool')
|
|
22
23
|
|
|
24
|
+
const _transactionPool = new TransactionPool()
|
|
25
|
+
|
|
26
|
+
exports._transactionPool = _transactionPool
|
|
23
27
|
/**
|
|
24
28
|
* @module aerospike
|
|
25
29
|
*
|
|
@@ -238,6 +242,39 @@ exports.Config = require('./config')
|
|
|
238
242
|
*/
|
|
239
243
|
exports.Double = require('./double')
|
|
240
244
|
|
|
245
|
+
/**
|
|
246
|
+
* Multi-record transaction (MRT) class. All commands in the same MRT must use the same namespace.
|
|
247
|
+
*
|
|
248
|
+
* note: By default, open transactions are destroyed when the final client in a process is closed.
|
|
249
|
+
* If you need your transaction to persist after the last client has been closed, provide `false` for the
|
|
250
|
+
* destroy Transactions argument in {@link Client#close} (see example below).
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
*
|
|
254
|
+
* const Aerospike = require('aerospike')
|
|
255
|
+
*
|
|
256
|
+
* // INSERT HOSTNAME AND PORT NUMBER OF AEROSPIKE SERVER NODE HERE!
|
|
257
|
+
* var config = {
|
|
258
|
+
* hosts: '192.168.33.10:3000',
|
|
259
|
+
* }
|
|
260
|
+
* Aerospike.connect(config)
|
|
261
|
+
* .then(client => {
|
|
262
|
+
* // client is ready to accept commands
|
|
263
|
+
* console.log("Connected. Now Closing Connection.")
|
|
264
|
+
* client.close()
|
|
265
|
+
* })
|
|
266
|
+
* .catch(error => {
|
|
267
|
+
* client.close(
|
|
268
|
+
* false, // do not release the event loop
|
|
269
|
+
* false // do not destroy open transactions
|
|
270
|
+
* )
|
|
271
|
+
* console.error('Failed to connect to cluster: %s', error.message)
|
|
272
|
+
* })
|
|
273
|
+
*
|
|
274
|
+
* @summary {@link Transaction} class
|
|
275
|
+
*/
|
|
276
|
+
exports.Transaction = require('./transaction')
|
|
277
|
+
|
|
241
278
|
/**
|
|
242
279
|
* Representation of a GeoJSON value. Since GeoJSON values are JSON objects
|
|
243
280
|
* they need to be wrapped in the {@link GeoJSON} class so that the client can
|
|
@@ -701,6 +738,22 @@ exports.setupGlobalCommandQueue = function (policy) {
|
|
|
701
738
|
*/
|
|
702
739
|
exports.batchType = require('./batch_type')
|
|
703
740
|
|
|
741
|
+
/**
|
|
742
|
+
* The {@link module:aerospike/commit_status|aerospike/commit_status}
|
|
743
|
+
* module contains a list of commit statuses.
|
|
744
|
+
*
|
|
745
|
+
* @summary {@link module:aerospike/commit_status|aerospike/commit_status} module
|
|
746
|
+
*/
|
|
747
|
+
exports.commitStatus = require('./commit_status')
|
|
748
|
+
|
|
749
|
+
/**
|
|
750
|
+
* The {@link module:aerospike/abortStatus|aerospike/abort_status}
|
|
751
|
+
* module contains a list of abort statuses.
|
|
752
|
+
*
|
|
753
|
+
* @summary {@link module:aerospike/abortStatus|aerospike/abort_status} module
|
|
754
|
+
*/
|
|
755
|
+
exports.abortStatus = require('./abort_status')
|
|
756
|
+
|
|
704
757
|
/**
|
|
705
758
|
* The {@link module:aerospike/privilegeCode|aerospike/privilege_code}
|
|
706
759
|
* module is comprised of permission codes which define the type of
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/lib/client.js
CHANGED
|
@@ -22,6 +22,10 @@ const EventEmitter = require('events')
|
|
|
22
22
|
|
|
23
23
|
const as = require('bindings')('aerospike.node')
|
|
24
24
|
const AerospikeError = require('./error')
|
|
25
|
+
const abortStatus = require('./abort_status')
|
|
26
|
+
const commitStatus = require('./commit_status')
|
|
27
|
+
const txnState = require('./txn_state')
|
|
28
|
+
const Transaction = require('./transaction')
|
|
25
29
|
const Context = require('./cdt_context')
|
|
26
30
|
const Commands = require('./commands')
|
|
27
31
|
const Config = require('./config')
|
|
@@ -35,6 +39,7 @@ const utils = require('./utils')
|
|
|
35
39
|
|
|
36
40
|
// number of client instances currently connected to any Aerospike cluster
|
|
37
41
|
let _connectedClients = 0
|
|
42
|
+
const { _transactionPool } = require('./aerospike')
|
|
38
43
|
|
|
39
44
|
// callback function for cluster events (node added/removed, etc.)
|
|
40
45
|
function eventsCallback (event) {
|
|
@@ -211,6 +216,40 @@ Client.prototype.getNodes = function () {
|
|
|
211
216
|
return this.as_client.getNodes()
|
|
212
217
|
}
|
|
213
218
|
|
|
219
|
+
Client.prototype.abort = function (transaction, callback) {
|
|
220
|
+
_transactionPool.tendTransactions()
|
|
221
|
+
if (transaction instanceof Transaction) {
|
|
222
|
+
if (transaction.getState() === txnState.COMMITTED) {
|
|
223
|
+
return abortStatus.ALREADY_COMMITTED
|
|
224
|
+
} else if (transaction.getState() === txnState.ABORTED) {
|
|
225
|
+
return abortStatus.ALREADY_ABORTED
|
|
226
|
+
} else if (transaction.getDestroyed() === true) {
|
|
227
|
+
throw new AerospikeError('The object has been destroyed, please create a new transaction.')
|
|
228
|
+
}
|
|
229
|
+
} else {
|
|
230
|
+
throw new AerospikeError('transaction must be an instance of class Transaction.')
|
|
231
|
+
}
|
|
232
|
+
const cmd = new Commands.TransactionAbort(this, [transaction.transaction], callback)
|
|
233
|
+
return cmd.execute()
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
Client.prototype.commit = function (transaction, callback) {
|
|
237
|
+
_transactionPool.tendTransactions()
|
|
238
|
+
if (transaction instanceof Transaction) {
|
|
239
|
+
if (transaction.getState() === txnState.COMMITTED) {
|
|
240
|
+
return commitStatus.ALREADY_COMMITTED
|
|
241
|
+
} else if (transaction.getState() === txnState.ABORTED) {
|
|
242
|
+
return commitStatus.ALREADY_ABORTED
|
|
243
|
+
} else if (transaction.getDestroyed() === true) {
|
|
244
|
+
throw new AerospikeError('The object has been destroyed, please create a new transaction.')
|
|
245
|
+
}
|
|
246
|
+
} else {
|
|
247
|
+
throw new AerospikeError('transaction must be an instance of class Transaction.')
|
|
248
|
+
}
|
|
249
|
+
const cmd = new Commands.TransactionCommit(this, [transaction.transaction], callback)
|
|
250
|
+
return cmd.execute()
|
|
251
|
+
}
|
|
252
|
+
|
|
214
253
|
/**
|
|
215
254
|
* @function Client#contextToBase64
|
|
216
255
|
*
|
|
@@ -1711,7 +1750,8 @@ Client.prototype.batchSelect = function (keys, bins, policy, callback) {
|
|
|
1711
1750
|
*
|
|
1712
1751
|
* @summary Closes the client connection to the cluster.
|
|
1713
1752
|
*
|
|
1714
|
-
* @param {boolean} [releaseEventLoop=false] - Whether to release the event loop handle after the client is closed.
|
|
1753
|
+
* @param {boolean} [releaseEventLoop=false] - Whether to release the event loop handle after the last client is closed.
|
|
1754
|
+
* @param {boolean} [destroyTransactions=true] - Whether to destroy any open transactions after the last client is closed.
|
|
1715
1755
|
*
|
|
1716
1756
|
* @see module:aerospike.releaseEventLoop
|
|
1717
1757
|
*
|
|
@@ -1734,13 +1774,16 @@ Client.prototype.batchSelect = function (keys, bins, policy, callback) {
|
|
|
1734
1774
|
* console.error('Failed to connect to cluster: %s', error.message)
|
|
1735
1775
|
* })
|
|
1736
1776
|
*/
|
|
1737
|
-
Client.prototype.close = function (releaseEventLoop = false) {
|
|
1777
|
+
Client.prototype.close = function (releaseEventLoop = false, destroyTransactions = true) {
|
|
1738
1778
|
if (this.isConnected(false)) {
|
|
1739
1779
|
this.connected = false
|
|
1740
1780
|
this.as_client.close()
|
|
1741
1781
|
_connectedClients -= 1
|
|
1742
1782
|
}
|
|
1743
1783
|
if (_connectedClients === 0) {
|
|
1784
|
+
if (destroyTransactions) {
|
|
1785
|
+
_transactionPool.removeAllTransactions()
|
|
1786
|
+
}
|
|
1744
1787
|
if (releaseEventLoop) {
|
|
1745
1788
|
EventLoop.releaseEventLoop()
|
|
1746
1789
|
} else {
|
package/lib/commands/index.js
CHANGED
|
@@ -70,6 +70,8 @@ exports.ScanPages = class ScanPagesCommand extends StreamCommand('scanPages') {
|
|
|
70
70
|
exports.ScanBackground = class ScanBackgroundCommand extends QueryBackgroundBaseCommand('scanBackground') { }
|
|
71
71
|
exports.ScanOperate = class ScanOperateCommand extends QueryBackgroundBaseCommand('scanBackground') { }
|
|
72
72
|
exports.Select = class SelectCommand extends ReadRecordCommand('selectAsync') { }
|
|
73
|
+
exports.TransactionAbort = class TransactionAbortCommand extends Command('transactionAbort') { }
|
|
74
|
+
exports.TransactionCommit = class TransactionCommitCommand extends Command('transactionCommit') { }
|
|
73
75
|
exports.Truncate = class TruncateCommand extends Command('truncate') { }
|
|
74
76
|
exports.UdfRegister = class UdfRegisterCommand extends Command('udfRegister') { }
|
|
75
77
|
exports.UdfRemove = class UdfRemoveCommand extends Command('udfRemove') { }
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright 2024 Aerospike, Inc.
|
|
3
|
+
//
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the 'License')
|
|
5
|
+
// you may not use this file except in compliance with the License.
|
|
6
|
+
// You may obtain a copy of the License at
|
|
7
|
+
//
|
|
8
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//
|
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
// distributed under the License is distributed on an 'AS IS' BASIS,
|
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
// See the License for the specific language governing permissions and
|
|
14
|
+
// limitations under the License.
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
'use strict'
|
|
18
|
+
|
|
19
|
+
const as = require('bindings')('aerospike.node')
|
|
20
|
+
const commitStatus = as.commitStatus
|
|
21
|
+
|
|
22
|
+
module.exports = {
|
|
23
|
+
OK: commitStatus.OK,
|
|
24
|
+
ALREADY_COMMITTED: commitStatus.ALREADY_COMMITTED,
|
|
25
|
+
ALREADY_ABORTED: commitStatus.ALREADY_ABORTED,
|
|
26
|
+
VERIFY_FAILED: commitStatus.VERIFY_FAILED,
|
|
27
|
+
MARK_ROLL_FORWARD_ABANDONED: commitStatus.MARK_ROLL_FORWARD_ABANDONED,
|
|
28
|
+
ROLL_FORWARD_ABANDONED: commitStatus.ROLL_FORWARD_ABANDONED,
|
|
29
|
+
CLOSE_ABANDONED: commitStatus.CLOSE_ABANDONED
|
|
30
|
+
}
|
package/lib/status.js
CHANGED
|
@@ -24,6 +24,12 @@ const as = require('bindings')('aerospike.node')
|
|
|
24
24
|
* @description Database operation error codes.
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Multi-record transaction failed.
|
|
29
|
+
* @const {number}
|
|
30
|
+
*/
|
|
31
|
+
exports.TXN_FAILED = exports.AEROSPIKE_TXN_FAILED = as.status.AEROSPIKE_TXN_FAILED
|
|
32
|
+
|
|
27
33
|
/**
|
|
28
34
|
* One or more keys failed in a batch.
|
|
29
35
|
* @const {number}
|
|
@@ -303,6 +309,8 @@ exports.FILTERED_OUT = exports.AEROSPIKE_FILTERED_OUT = as.status.AEROSPIKE_FILT
|
|
|
303
309
|
*/
|
|
304
310
|
exports.LOST_CONFLICT = exports.AEROSPIKE_LOST_CONFLICT = as.status.AEROSPIKE_LOST_CONFLICT
|
|
305
311
|
|
|
312
|
+
exports.XDR_KEY_BUSY = exports.AEROSPIKE_XDR_KEY_BUSY = as.status.AEROSPIKE_XDR_KEY_BUSY
|
|
313
|
+
|
|
306
314
|
/**
|
|
307
315
|
* There are no more records left for query.
|
|
308
316
|
* @const {number}
|
|
@@ -441,6 +449,13 @@ exports.ROLE_VIOLATION = exports.AEROSPIKE_ROLE_VIOLATION = as.status.AEROSPIKE_
|
|
|
441
449
|
*/
|
|
442
450
|
exports.ERR_UDF = exports.AEROSPIKE_ERR_UDF = as.status.AEROSPIKE_ERR_UDF
|
|
443
451
|
|
|
452
|
+
exports.MRT_BLOCKED = exports.AEROSPIKE_MRT_BLOCKED = as.status.AEROSPIKE_MRT_BLOCKED
|
|
453
|
+
exports.MRT_VERSION_MISMATCH = exports.AEROSPIKE_MRT_VERSION_MISMATCH = as.status.AEROSPIKE_MRT_VERSION_MISMATCH
|
|
454
|
+
exports.MRT_EXPIRED = exports.AEROSPIKE_MRT_EXPIRED = as.status.AEROSPIKE_MRT_EXPIRED
|
|
455
|
+
exports.MRT_TOO_MANY_WRITES = exports.AEROSPIKE_MRT_TOO_MANY_WRITES = as.status.AEROSPIKE_MRT_TOO_MANY_WRITES
|
|
456
|
+
exports.MRT_COMMITTED = exports.AEROSPIKE_MRT_COMMITTED = as.status.AEROSPIKE_MRT_COMMITTED
|
|
457
|
+
exports.MRT_ABORTED = exports.AEROSPIKE_MRT_ABORTED = as.status.AEROSPIKE_MRT_ABORTED
|
|
458
|
+
|
|
444
459
|
/**
|
|
445
460
|
* Batch functionality has been disabled.
|
|
446
461
|
* @const {number}
|
|
@@ -553,6 +568,9 @@ exports.ERR_LUA_FILE_NOT_FOUND = exports.AEROSPIKE_ERR_LUA_FILE_NOT_FOUND = as.s
|
|
|
553
568
|
exports.getMessage = function (code) {
|
|
554
569
|
/* istanbul ignore next */
|
|
555
570
|
switch (code) {
|
|
571
|
+
case exports.TXN_FAILED:
|
|
572
|
+
return 'Multi-record transaction failed.'
|
|
573
|
+
|
|
556
574
|
case exports.ERR_INVALID_NODE:
|
|
557
575
|
return 'Node invalid or could not be found.'
|
|
558
576
|
|
|
@@ -727,6 +745,24 @@ exports.getMessage = function (code) {
|
|
|
727
745
|
case exports.ERR_UDF:
|
|
728
746
|
return 'Generic UDF error.'
|
|
729
747
|
|
|
748
|
+
case exports.MRT_BLOCKED:
|
|
749
|
+
return 'MRT record blocked by a different transaction.'
|
|
750
|
+
|
|
751
|
+
case exports.MRT_VERSION_MISMATCH:
|
|
752
|
+
return 'MRT read version mismatch identified during commit. Some other command changed the record outside of the transaction.'
|
|
753
|
+
|
|
754
|
+
case exports.MRT_EXPIRED:
|
|
755
|
+
return 'MRT deadline reached without a successful commit or abort.'
|
|
756
|
+
|
|
757
|
+
case exports.MRT_TOO_MANY_WRITES:
|
|
758
|
+
return 'MRT write command limit (4096) exceeded.'
|
|
759
|
+
|
|
760
|
+
case exports.MRT_COMMITTED:
|
|
761
|
+
return 'MRT was already committed.'
|
|
762
|
+
|
|
763
|
+
case exports.MRT_ABORTED:
|
|
764
|
+
return 'MRT was already aborted.'
|
|
765
|
+
|
|
730
766
|
case exports.ERR_BATCH_DISABLED:
|
|
731
767
|
return 'Batch functionality has been disabled.'
|
|
732
768
|
|