Skip to content

Commit 310ed26

Browse files
authored
Merge pull request #462 from aerospike/stage
v8.0.0
2 parents 8580877 + b741695 commit 310ed26

28 files changed

+351
-167
lines changed

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
# Change History
22

3+
## January 22 2025: v8.0.0
4+
5+
- **New Features**
6+
- [CLIENT-3257] Implement iterator support for `Recordset`.
7+
8+
- **Fixes**
9+
- [CLIENT-3275] Return an error when Transaction commit called, but transaction was already aborted.
10+
- [CLIENT-3295] Duplicate parsing of fields in RecordParser.ParseRecord.
11+
- [CLIENT-3261] New `OnLockingOnly` attribute for various write policies to write only if provisional does not exist.
12+
- [CLIENT-3227] Clarify that `BasePolicy.UseCompression` requires Enterprise Edition.
13+
- [CLIENT-3260] Add `MRT_ALREADY_LOCKED` and `MRT_MONITOR_EXISTS` error codes.
14+
- [CLIENT-3292][CLIENT-3293] Update dependencies due to Snyk CVE reports.
15+
- [CLIENT-3274] Fix Transaction related client exception inconsistency between clients.
16+
- [CLIENT-3207] Do not close/delete Transaction monitor record on abort/commit when a write command in that Transaction fails and is `inDoubt`.
17+
- [CLIENT-3283] Remove the txn instance from the copied write policy when adding Transaction monitor keys.
18+
- [CLIENT-3270] Normalize API reference language with server 8.0 site docs.
19+
- [CLIENT-3258] Transaction commit returns 'Failed to commit one or more record versions' error.
20+
321
## December 20 2024: v8.0.0-beta.2
422

523
- **New Features**

abort_status.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414

1515
package aerospike
1616

17-
// Multi-record transaction (MRT) abort status code.
17+
// Transaction abort status code.
1818
type AbortStatus string
1919

2020
const (
2121
AbortStatusOK AbortStatus = "Abort succeeded"
2222
AbortStatusAlreadyCommitted AbortStatus = "Already committed"
2323
AbortStatusAlreadyAborted AbortStatus = "Already aborted"
24-
AbortStatusRollBackAbandoned AbortStatus = "MRT client roll back abandoned. Server will eventually abort the MRT."
25-
AbortStatusCloseAbandoned AbortStatus = "MRT has been rolled back, but MRT client close was abandoned. Server will eventually close the MRT."
24+
AbortStatusRollBackAbandoned AbortStatus = "Transaction client roll back abandoned. Server will eventually abort the Transaction."
25+
AbortStatusCloseAbandoned AbortStatus = "Transaction has been rolled back, but Transaction client close was abandoned. Server will eventually close the Transaction."
2626
)

batch_attr.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ func (ba *batchAttr) setRead(rp *BatchPolicy) {
115115
case ReadModeSCAllowUnavailable:
116116
ba.infoAttr = _INFO3_SC_READ_TYPE | _INFO3_SC_READ_RELAX
117117
}
118+
ba.txnAttr = 0
118119
ba.expiration = uint32(rp.ReadTouchTTLPercent)
119120
ba.generation = 0
120121
ba.hasWrite = false
@@ -142,6 +143,7 @@ func (ba *batchAttr) setBatchRead(rp *BatchReadPolicy) {
142143
case ReadModeSCAllowUnavailable:
143144
ba.infoAttr = _INFO3_SC_READ_TYPE | _INFO3_SC_READ_RELAX
144145
}
146+
ba.txnAttr = 0
145147
ba.expiration = uint32(rp.ReadTouchTTLPercent)
146148
ba.generation = 0
147149
ba.hasWrite = false
@@ -174,6 +176,7 @@ func (ba *batchAttr) setBatchWrite(wp *BatchWritePolicy) {
174176
ba.readAttr = 0
175177
ba.writeAttr = _INFO2_WRITE | _INFO2_RESPOND_ALL_OPS
176178
ba.infoAttr = 0
179+
ba.txnAttr = 0
177180
ba.expiration = wp.Expiration
178181
ba.hasWrite = true
179182
ba.sendKey = wp.SendKey
@@ -209,6 +212,10 @@ func (ba *batchAttr) setBatchWrite(wp *BatchWritePolicy) {
209212
ba.writeAttr |= _INFO2_DURABLE_DELETE
210213
}
211214

215+
if wp.OnLockingOnly {
216+
ba.txnAttr |= _INFO4_MRT_ON_LOCKING_ONLY
217+
}
218+
212219
if wp.CommitLevel == COMMIT_MASTER {
213220
ba.infoAttr |= _INFO3_COMMIT_MASTER
214221
}
@@ -251,6 +258,7 @@ func (ba *batchAttr) setBatchUDF(up *BatchUDFPolicy) {
251258
ba.readAttr = 0
252259
ba.writeAttr = _INFO2_WRITE
253260
ba.infoAttr = 0
261+
ba.txnAttr = 0
254262
ba.expiration = up.Expiration
255263
ba.generation = 0
256264
ba.hasWrite = true
@@ -260,6 +268,10 @@ func (ba *batchAttr) setBatchUDF(up *BatchUDFPolicy) {
260268
ba.writeAttr |= _INFO2_DURABLE_DELETE
261269
}
262270

271+
if up.OnLockingOnly {
272+
ba.txnAttr |= _INFO4_MRT_ON_LOCKING_ONLY
273+
}
274+
263275
if up.CommitLevel == COMMIT_MASTER {
264276
ba.infoAttr |= _INFO3_COMMIT_MASTER
265277
}
@@ -270,6 +282,7 @@ func (ba *batchAttr) setBatchDelete(dp *BatchDeletePolicy) {
270282
ba.readAttr = 0
271283
ba.writeAttr = _INFO2_WRITE | _INFO2_RESPOND_ALL_OPS | _INFO2_DELETE
272284
ba.infoAttr = 0
285+
ba.txnAttr = 0
273286
ba.expiration = 0
274287
ba.hasWrite = true
275288
ba.sendKey = dp.SendKey

batch_command.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func (cmd *batchCommand) retryBatch(ifc batcher, cluster *Cluster, deadline time
9090

9191
cmd.splitRetry = true
9292

93-
// Run batch requests sequentially in same thread.
93+
// Run batch requests sequentially in same goroutine.
9494
var ferr Error
9595
for _, batchNode := range batchNodes {
9696
command := ifc.cloneBatchCommand(batchNode)

batch_udf_policy.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ type BatchUDFPolicy struct {
4343
// Valid for Aerospike Server Enterprise Edition 3.10+ only.
4444
DurableDelete bool
4545

46+
// Execute the write command only if the record is not already locked by this transaction.
47+
// If this field is true and the record is already locked by this transaction, the command
48+
// will return an error with the [types.MRT_ALREADY_LOCKED] error code.
49+
//
50+
// This field is useful for safely retrying non-idempotent writes as an alternative to simply
51+
// aborting the transaction.
52+
//
53+
// Default: false
54+
OnLockingOnly bool
55+
4656
// SendKey determines to whether send user defined key in addition to hash digest on both reads and writes.
4757
// If true and the UDF writes a record, the key will be stored with the record on the server.
4858
// The default is to not send the user defined key.

batch_write_policy.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ type BatchWritePolicy struct {
6767
// Valid for Aerospike Server Enterprise Edition 3.10+ only.
6868
DurableDelete bool
6969

70+
// Execute the write command only if the record is not already locked by this transaction.
71+
// If this field is true and the record is already locked by this transaction, the command
72+
// will return an error with the [types.MRT_ALREADY_LOCKED] error code.
73+
//
74+
// This field is useful for safely retrying non-idempotent writes as an alternative to simply
75+
// aborting the transaction.
76+
//
77+
// Default: false
78+
OnLockingOnly bool
79+
7080
// SendKey determines to whether send user defined key in addition to hash digest on both reads and writes.
7181
// If the key is sent on a write, the key will be stored with the record on
7282
// the server.

client.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ type Client struct {
6161
DefaultAdminPolicy *AdminPolicy
6262
// DefaultInfoPolicy is used for all info commands without a specific policy.
6363
DefaultInfoPolicy *InfoPolicy
64-
// Default multi-record transaction (MRT) policy when verifying record versions in a batch on a commit.
64+
// Default transaction policy when verifying record versions in a batch on a commit.
6565
DefaultTxnVerifyPolicy *TxnVerifyPolicy
66-
// Default multi-record transaction (MRT) policy when rolling the transaction records forward (commit)
66+
// Default transaction policy when rolling the transaction records forward (commit)
6767
// or back (abort) in a batch.
6868
DefaultTxnRollPolicy *TxnRollPolicy
6969
}
@@ -1474,7 +1474,7 @@ func (clnt *Client) Commit(txn *Txn) (CommitStatus, Error) {
14741474
case TxnStateCommitted:
14751475
return CommitStatusAlreadyCommitted, nil
14761476
case TxnStateAborted:
1477-
return CommitStatusAlreadyAborted, nil
1477+
return CommitStatusAlreadyAborted, newError(types.TXN_ALREADY_ABORTED, "Transaction already aborted")
14781478
}
14791479
}
14801480

@@ -1491,7 +1491,7 @@ func (clnt *Client) Abort(txn *Txn) (AbortStatus, Error) {
14911491
case TxnStateVerified:
14921492
return tr.Abort(&clnt.GetDefaultTxnRollPolicy().BatchPolicy)
14931493
case TxnStateCommitted:
1494-
return AbortStatusAlreadyCommitted, nil
1494+
return AbortStatusAlreadyCommitted, newError(types.TXN_ALREADY_COMMITTED, "Transaction already committed")
14951495
case TxnStateAborted:
14961496
return AbortStatusAlreadyAborted, nil
14971497
}

command.go

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,14 @@ const (
8686
// See Below
8787
_INFO3_SC_READ_RELAX int = (1 << 7)
8888

89-
// Send MRT version to the server to be verified.
89+
// Send Transaction version to the server to be verified.
9090
_INFO4_MRT_VERIFY_READ = (1 << 0)
91-
// Roll forward MRT.
91+
// Roll forward Transaction.
9292
_INFO4_MRT_ROLL_FORWARD = (1 << 1)
93-
// Roll back MRT.
93+
// Roll back Transaction.
9494
_INFO4_MRT_ROLL_BACK = (1 << 2)
95+
// Must be able to lock record in transaction.
96+
_INFO4_MRT_ON_LOCKING_ONLY = (1 << 4)
9597

9698
// Interpret SC_READ bits in info3.
9799
//
@@ -626,7 +628,7 @@ func (cmd *baseCommand) sizeTxn(key *Key, txn *Txn, hasWrite bool) int {
626628

627629
func (cmd *baseCommand) sizeTxnBatch(txn *Txn, ver *uint64, hasWrite bool) {
628630
if txn != nil {
629-
cmd.dataOffset++ // Add info4 byte for MRT.
631+
cmd.dataOffset++ // Add info4 byte for Transaction.
630632
cmd.dataOffset += int(8 + _FIELD_HEADER_SIZE)
631633

632634
if ver != nil {
@@ -2892,6 +2894,7 @@ func (cmd *baseCommand) writeHeaderWrite(policy *WritePolicy, writeAttr, fieldCo
28922894
generation := uint32(0)
28932895
readAttr := 0
28942896
infoAttr := 0
2897+
txnAttr := 0
28952898

28962899
switch policy.RecordExistsAction {
28972900
case UPDATE:
@@ -2923,6 +2926,10 @@ func (cmd *baseCommand) writeHeaderWrite(policy *WritePolicy, writeAttr, fieldCo
29232926
writeAttr |= _INFO2_DURABLE_DELETE
29242927
}
29252928

2929+
if policy.OnLockingOnly {
2930+
txnAttr |= _INFO4_MRT_ON_LOCKING_ONLY
2931+
}
2932+
29262933
// if (policy.Xdr) {
29272934
// readAttr |= _INFO1_XDR;
29282935
// }
@@ -2932,7 +2939,7 @@ func (cmd *baseCommand) writeHeaderWrite(policy *WritePolicy, writeAttr, fieldCo
29322939
cmd.dataBuffer[9] = byte(readAttr)
29332940
cmd.dataBuffer[10] = byte(writeAttr)
29342941
cmd.dataBuffer[11] = byte(infoAttr)
2935-
cmd.dataBuffer[12] = 0 // unused
2942+
cmd.dataBuffer[12] = byte(txnAttr)
29362943
cmd.dataBuffer[13] = 0 // clear the result code
29372944
cmd.dataOffset = 14
29382945
cmd.WriteUint32(generation)
@@ -2954,6 +2961,7 @@ func (cmd *baseCommand) writeHeaderReadWrite(policy *WritePolicy, args *operateA
29542961
readAttr := args.readAttr
29552962
writeAttr := args.writeAttr
29562963
infoAttr := 0
2964+
txnAttr := 0
29572965
operationCount := len(args.operations)
29582966

29592967
switch policy.RecordExistsAction {
@@ -2986,6 +2994,10 @@ func (cmd *baseCommand) writeHeaderReadWrite(policy *WritePolicy, args *operateA
29862994
writeAttr |= _INFO2_DURABLE_DELETE
29872995
}
29882996

2997+
if policy.OnLockingOnly {
2998+
txnAttr |= _INFO4_MRT_ON_LOCKING_ONLY
2999+
}
3000+
29893001
// if (policy.xdr) {
29903002
// readAttr |= _INFO1_XDR;
29913003
// }
@@ -3013,7 +3025,7 @@ func (cmd *baseCommand) writeHeaderReadWrite(policy *WritePolicy, args *operateA
30133025
cmd.dataBuffer[9] = byte(readAttr)
30143026
cmd.dataBuffer[10] = byte(writeAttr)
30153027
cmd.dataBuffer[11] = byte(infoAttr)
3016-
cmd.dataBuffer[12] = 0 // unused
3028+
cmd.dataBuffer[12] = byte(txnAttr)
30173029
cmd.dataBuffer[13] = 0 // clear the result code
30183030
cmd.dataOffset = 14
30193031
cmd.WriteUint32(generation)
@@ -3113,7 +3125,7 @@ func (cmd *baseCommand) writeKeyAttr(
31133125
cmd.WriteByte(byte(attr.readAttr))
31143126
cmd.WriteByte(byte(attr.writeAttr))
31153127
cmd.WriteByte(byte(attr.infoAttr))
3116-
cmd.WriteByte(0) // unused
3128+
cmd.WriteByte(byte(attr.txnAttr))
31173129
cmd.WriteByte(0) // clear the result code
31183130
cmd.WriteUint32(attr.generation)
31193131
cmd.WriteUint32(attr.expiration)

commit_error.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414

1515
package aerospike
1616

17-
// Multi-record transaction (MRT) error status.
17+
// Transaction error status.
1818
type CommitError string
1919

2020
const (
21-
CommitErrorVerifyFail CommitError = "MRT verify failed. MRT aborted."
22-
CommitErrorVerifyFailCloseAbandoned CommitError = "MRT verify failed. MRT aborted. MRT client close abandoned. Server will eventually close the MRT."
23-
CommitErrorVerifyFailAbortAbandoned CommitError = "MRT verify failed. MRT client abort abandoned. Server will eventually abort the MRT."
24-
CommitErrorMarkRollForwardAbandoned CommitError = "MRT client mark roll forward abandoned. Server will eventually abort the MRT."
21+
CommitErrorVerifyFail CommitError = "Transaction verify failed. Transaction aborted."
22+
CommitErrorVerifyFailCloseAbandoned CommitError = "Transaction verify failed. Transaction aborted. Transaction client close abandoned. Server will eventually close the Transaction."
23+
CommitErrorVerifyFailAbortAbandoned CommitError = "Transaction verify failed. Transaction client abort abandoned. Server will eventually abort the Transaction."
24+
CommitErrorMarkRollForwardAbandoned CommitError = "Transaction client mark roll forward abandoned. Server will eventually abort the Transaction."
2525
)

commit_status.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414

1515
package aerospike
1616

17-
// Multi-record transaction (MRT) commit status code.
17+
// Transaction commit status code.
1818
type CommitStatus string
1919

2020
const (
2121
CommitStatusOK CommitStatus = "Commit succeeded"
2222
CommitStatusUnverified CommitStatus = "Commit process was disrupted on client side and unverified"
2323
CommitStatusAlreadyCommitted CommitStatus = "Already committed"
2424
CommitStatusAlreadyAborted CommitStatus = "Already aborted"
25-
CommitStatusRollForwardAbandoned CommitStatus = "MRT client roll forward abandoned. Server will eventually commit the MRT."
26-
CommitStatusCloseAbandoned CommitStatus = "MRT has been rolled forward, but MRT client close was abandoned. Server will eventually close the MRT."
25+
CommitStatusRollForwardAbandoned CommitStatus = "Transaction client roll forward abandoned. Server will eventually commit the Transaction."
26+
CommitStatusCloseAbandoned CommitStatus = "Transaction has been rolled forward, but Transaction client close was abandoned. Server will eventually close the Transaction."
2727
)

0 commit comments

Comments
 (0)