1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
|
fio = require('fio')
---
...
xlog = require('xlog').pairs
---
...
env = require('test_run')
---
...
test_run = env.new()
---
...
test_run:cmd("setopt delimiter ';'")
---
- true
...
function read_xlog(file)
local val = {}
for k, v in xlog(file) do
table.insert(val, setmetatable(v, { __serialize = "map"}))
end
return val
end;
---
...
test_run:cmd("setopt delimiter ''");
---
- true
...
-- gh-2798 check for journal transaction encoding
_ = box.schema.space.create('test'):create_index('pk')
---
...
-- generate a new xlog
box.snapshot()
---
- ok
...
lsn = box.info.lsn
---
...
-- autocommit transaction
box.space.test:replace({1})
---
- [1]
...
-- one row transaction
box.begin() box.space.test:replace({2}) box.commit()
---
...
-- two row transaction
box.begin() for i = 3, 4 do box.space.test:replace({i}) end box.commit()
---
...
-- four row transaction
box.begin() for i = 5, 8 do box.space.test:replace({i}) end box.commit()
---
...
-- open a new xlog
box.snapshot()
---
- ok
...
-- read a previous one
lsn_str = tostring(lsn)
---
...
data = read_xlog(fio.pathjoin(box.cfg.wal_dir, string.rep('0', 20 - #lsn_str) .. tostring(lsn_str) .. '.xlog'))
---
...
-- check nothing changed for single row transactions
data[1].HEADER.tsn == nil and data[1].HEADER.commit == nil
---
- true
...
data[2].HEADER.tsn == nil and data[2].HEADER.commit == nil
---
- true
...
-- check two row transaction
data[3].HEADER.tsn == data[3].HEADER.lsn and data[3].HEADER.commit == nil
---
- true
...
data[4].HEADER.tsn == data[3].HEADER.tsn and data[4].HEADER.commit == true
---
- true
...
-- check four row transaction
data[5].HEADER.tsn == data[5].HEADER.lsn and data[5].HEADER.commit == nil
---
- true
...
data[6].HEADER.tsn == data[5].HEADER.tsn and data[6].HEADER.commit == nil
---
- true
...
data[7].HEADER.tsn == data[5].HEADER.tsn and data[7].HEADER.commit == nil
---
- true
...
data[8].HEADER.tsn == data[5].HEADER.tsn and data[8].HEADER.commit == true
---
- true
...
box.space.test:drop()
---
...
|