Skip to content
Snippets Groups Projects
Commit 41589229 authored by Ilya Markov's avatar Ilya Markov Committed by Vladimir Davydov
Browse files

wal: Update request header after sequence update

When tuple in insert/replace request has NULL value
in the field incremented by sequence,
request body is changed, NULL is replaced by value taken from
sequence.
But request header is not updated.
So Redo log, which takes body from header if header exists,
writes the old version of request to wal.

Fixed this with updating header value after handling the sequence.

Closes #3247
parent 01b8ebc3
No related branches found
No related tags found
No related merge requests found
......@@ -195,5 +195,14 @@ request_handle_sequence(struct request *request, struct space *space)
if (likely(mp_read_int64(&key, &value) == 0))
return sequence_update(seq, value);
}
/*
* As the request body was changed, we have to update body in header.
*/
struct xrow_header *row = request->header;
if (row != NULL) {
row->bodycnt = xrow_encode_dml(request, row->body);
if (row->bodycnt < 0)
return -1;
}
return 0;
}
......@@ -135,6 +135,66 @@ test_timeout()
---
- true
...
-- gh-3247 - Sequence-generated value is not replicated in case
-- the request was sent via iproto.
test_run:cmd("switch autobootstrap1")
---
- true
...
net_box = require('net.box')
---
...
_ = box.schema.space.create('space1')
---
...
_ = box.schema.sequence.create('seq')
---
...
_ = box.space.space1:create_index('primary', {sequence = true} )
---
...
_ = box.space.space1:create_index('secondary', {parts = {2, 'unsigned'}})
---
...
box.schema.user.grant('guest', 'read,write', 'space', 'space1')
---
...
c = net_box.connect(box.cfg.listen)
---
...
c.space.space1:insert{box.NULL, "data"} -- fails, but bumps sequence value
---
- error: 'Tuple field 2 type does not match one required by operation: expected unsigned'
...
c.space.space1:insert{box.NULL, 1, "data"}
---
- [2, 1, 'data']
...
box.space.space1:select{}
---
- - [2, 1, 'data']
...
vclock = test_run:get_vclock("autobootstrap1")
---
...
_ = test_run:wait_vclock("autobootstrap2", vclock)
---
...
test_run:cmd("switch autobootstrap2")
---
- true
...
box.space.space1:select{}
---
- - [2, 1, 'data']
...
test_run:cmd("switch autobootstrap1")
---
- true
...
box.space.space1:drop()
---
...
test_run:cmd("switch default")
---
- true
......
......@@ -55,6 +55,27 @@ function test_timeout()
end ;
test_run:cmd("setopt delimiter ''");
test_timeout()
-- gh-3247 - Sequence-generated value is not replicated in case
-- the request was sent via iproto.
test_run:cmd("switch autobootstrap1")
net_box = require('net.box')
_ = box.schema.space.create('space1')
_ = box.schema.sequence.create('seq')
_ = box.space.space1:create_index('primary', {sequence = true} )
_ = box.space.space1:create_index('secondary', {parts = {2, 'unsigned'}})
box.schema.user.grant('guest', 'read,write', 'space', 'space1')
c = net_box.connect(box.cfg.listen)
c.space.space1:insert{box.NULL, "data"} -- fails, but bumps sequence value
c.space.space1:insert{box.NULL, 1, "data"}
box.space.space1:select{}
vclock = test_run:get_vclock("autobootstrap1")
_ = test_run:wait_vclock("autobootstrap2", vclock)
test_run:cmd("switch autobootstrap2")
box.space.space1:select{}
test_run:cmd("switch autobootstrap1")
box.space.space1:drop()
test_run:cmd("switch default")
test_run:drop_cluster(SERVERS)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment