Skip to content

Commit a02282f

Browse files
committed
retry on conflict 1
1 parent 3fd9cd4 commit a02282f

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

process/elasticproc/operations/serialize.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (op *operationsProcessor) prepareSerializedDataForAScResult(
3030
index string,
3131
selfShardID uint32,
3232
) ([]byte, []byte, error) {
33-
metaData := []byte(fmt.Sprintf(`{"update":{"_index":"%s","_id":"%s"}}%s`, index, converters.JsonEscape(scr.Hash), "\n"))
33+
metaData := []byte(fmt.Sprintf(`{"update":{"_index":"%s","_id":"%s", "retry_on_conflict":3 }}%s`, index, converters.JsonEscape(scr.Hash), "\n"))
3434
marshaledSCR, err := json.Marshal(scr)
3535
if err != nil {
3636
return nil, nil, err

process/elasticproc/operations/serialize_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func TestOperationsProcessor_SerializeSCRS(t *testing.T) {
2626
buffSlice := data.NewBufferSlice(data.DefaultMaxBulkSize)
2727
err := op.SerializeSCRs(scrs, buffSlice, "operations", 0)
2828
require.Nil(t, err)
29-
require.Equal(t, `{"update":{"_index":"operations","_id":""}}
29+
require.Equal(t, `{"update":{"_index":"operations","_id":"", "retry_on_conflict":3 }}
3030
{"script":{"source":"return"},"upsert":{"uuid":"","nonce":0,"gasLimit":0,"gasPrice":0,"value":"","valueNum":0,"sender":"","receiver":"","senderShard":0,"receiverShard":1,"prevTxHash":"","originalTxHash":"","callType":"","timestamp":0,"epoch":0}}
3131
{ "index" : { "_index":"operations","_id" : "" } }
3232
{"uuid":"","nonce":0,"gasLimit":0,"gasPrice":0,"value":"","valueNum":0,"sender":"","receiver":"","senderShard":2,"receiverShard":0,"prevTxHash":"","originalTxHash":"","callType":"","timestamp":0,"epoch":0}

process/elasticproc/transactions/serialize.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func (tdp *txsDatabaseProcessor) SerializeReceipts(receipts []*data.Receipt, buf
5050
// SerializeTransactionsFeeData will serialize transactions fee data
5151
func (tdp *txsDatabaseProcessor) SerializeTransactionsFeeData(txHashRefund map[string]*data.FeeData, buffSlice *data.BufferSlice, index string) error {
5252
for txHash, feeData := range txHashRefund {
53-
meta := []byte(fmt.Sprintf(`{"update":{ "_index":"%s","_id":"%s"}}%s`, index, converters.JsonEscape(txHash), "\n"))
53+
meta := []byte(fmt.Sprintf(`{"update":{ "_index":"%s","_id":"%s", "retry_on_conflict":3}}%s`, index, converters.JsonEscape(txHash), "\n"))
5454

5555
var codeToExecute string
5656
if feeData.GasRefunded != 0 {
@@ -142,7 +142,7 @@ func (tdp *txsDatabaseProcessor) SerializeTransactions(
142142

143143
func serializeTxHashStatus(buffSlice *data.BufferSlice, txHashStatusInfo map[string]*outport.StatusInfo, index string) error {
144144
for txHash, statusInfo := range txHashStatusInfo {
145-
metaData := []byte(fmt.Sprintf(`{"update":{ "_index":"%s","_id":"%s"}}%s`, index, txHash, "\n"))
145+
metaData := []byte(fmt.Sprintf(`{"update":{ "_index":"%s","_id":"%s", "retry_on_conflict":3}}%s`, index, txHash, "\n"))
146146

147147
newTx := &data.Transaction{
148148
Status: statusInfo.Status,
@@ -186,7 +186,7 @@ func prepareSerializedDataForATransaction(
186186
selfShardID uint32,
187187
index string,
188188
) ([]byte, []byte, error) {
189-
metaData := []byte(fmt.Sprintf(`{"update":{ "_index":"%s", "_id":"%s"}}%s`, index, converters.JsonEscape(tx.Hash), "\n"))
189+
metaData := []byte(fmt.Sprintf(`{"update":{ "_index":"%s", "_id":"%s", "retry_on_conflict":3}}%s`, index, converters.JsonEscape(tx.Hash), "\n"))
190190
marshaledTx, err := json.Marshal(tx)
191191
if err != nil {
192192
return nil, nil, err

process/elasticproc/transactions/serialize_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func TestSerializeTransactionCrossShardTxSource(t *testing.T) {
104104
}}, map[string]*outport.StatusInfo{}, 0, buffSlice, "transactions")
105105
require.Nil(t, err)
106106

107-
expectedBuff := `{"update":{ "_index":"transactions", "_id":"txHash"}}
107+
expectedBuff := `{"update":{ "_index":"transactions", "_id":"txHash", "retry_on_conflict":3}}
108108
{"script":{"source":"return"},"upsert":{"uuid":"","miniBlockHash":"","nonce":0,"round":0,"value":"","valueNum":0,"receiver":"","sender":"","receiverShard":1,"senderShard":0,"gasPrice":0,"gasLimit":0,"gasUsed":0,"fee":"","feeNum":0,"data":null,"signature":"","timestamp":0,"status":"","searchOrder":0,"version":1,"epoch":0}}
109109
`
110110
require.Equal(t, expectedBuff, buffSlice.Buffers()[0].String())
@@ -145,7 +145,7 @@ func TestTxsDatabaseProcessor_SerializeTransactionWithRefund(t *testing.T) {
145145
err := (&txsDatabaseProcessor{}).SerializeTransactionsFeeData(txHashRefund, buffSlice, "transactions")
146146
require.Nil(t, err)
147147

148-
expectedBuff := `{"update":{ "_index":"transactions","_id":"txHash"}}
148+
expectedBuff := `{"update":{ "_index":"transactions","_id":"txHash", "retry_on_conflict":3}}
149149
{"scripted_upsert": true, "script": {"source": "if ('create' == ctx.op) {ctx.op = 'noop'} else {ctx._source.fee = params.fee;ctx._source.feeNum = params.feeNum;ctx._source.gasUsed = params.gasUsed;}","lang": "painless","params": {"fee": "100000", "gasUsed": 5000, "feeNum": 5e-15, "gasRefunded": 0}},"upsert": {}}
150150
`
151151
require.Equal(t, expectedBuff, buffSlice.Buffers()[0].String())

0 commit comments

Comments
 (0)