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 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
|
-- Issue 3105: Test logging of request with broken lsn before panicking
-- Two cases are covered: Recovery and Joining a new replica
env = require('test_run')
---
...
test_run = env.new()
---
...
test_run:cleanup_cluster()
---
...
fio = require('fio')
---
...
-- Testing case of panic on recovery
test_run:cmd('create server panic with script="xlog/panic.lua"')
---
- true
...
test_run:cmd('start server panic')
---
- true
...
test_run:switch('panic')
---
- true
...
box.space._schema:replace{"t0", "v0"}
---
- ['t0', 'v0']
...
lsn = box.info.vclock[1]
---
...
box.error.injection.set("ERRINJ_WAL_BREAK_LSN", lsn + 1)
---
- ok
...
box.space._schema:replace{"t0", "v1"}
---
- ['t0', 'v1']
...
box.error.injection.set("ERRINJ_WAL_BREAK_LSN", -1)
---
- ok
...
test_run:switch('default')
---
- true
...
test_run:cmd('stop server panic')
---
- true
...
dirname = fio.pathjoin(fio.cwd(), "panic")
---
...
xlogs = fio.glob(dirname .. "/*.xlog")
---
...
fio.unlink(xlogs[#xlogs])
---
- true
...
test_run:cmd('start server panic with crash_expected=True')
---
- false
...
-- Check that log contains the mention of broken LSN and the request printout
filename = fio.pathjoin(fio.cwd(), 'panic.log')
---
...
str = string.format("LSN for 1 is used twice or COMMIT order is broken: confirmed: 1, new: 1, req: .*")
---
...
found = test_run:grep_log(nil, str, 256, {filename = filename})
---
...
(found:gsub('^.*, req: ', ''):gsub('lsn: %d+', 'lsn: <lsn>'))
---
- '{type: ''REPLACE'', replica_id: 1, lsn: <lsn>, space_id: 272, index_id: 0, tuple:
["t0", "v1"]}'
...
test_run:cmd('cleanup server panic')
---
- true
...
test_run:cmd('delete server panic')
---
- true
...
-- Testing case of panic on joining a new replica
box.schema.user.grant('guest', 'replication')
---
...
_ = box.schema.space.create('test', {id = 9000})
---
...
_ = box.space.test:create_index('pk')
---
...
box.space.test:auto_increment{'v0'}
---
- [1, 'v0']
...
-- Inject a broken LSN in the final join stage.
lsn = -1
---
...
box.error.injection.set("ERRINJ_REPLICA_JOIN_DELAY", true)
---
- ok
...
fiber = require('fiber')
---
...
test_run:cmd("setopt delimiter ';'")
---
- true
...
_ = fiber.create(function()
test_run:wait_cond(function() return box.info.replication[2] ~= nil end)
lsn = box.info.vclock[1]
box.error.injection.set("ERRINJ_RELAY_BREAK_LSN", lsn + 1)
box.space.test:auto_increment{'v1'}
box.error.injection.set("ERRINJ_REPLICA_JOIN_DELAY", false)
end);
---
...
test_run:cmd("setopt delimiter ''");
---
- true
...
test_run:cmd('create server replica with rpl_master=default, script="xlog/replica.lua"')
---
- true
...
test_run:cmd('start server replica with crash_expected=True')
---
- false
...
box.error.injection.set("ERRINJ_RELAY_BREAK_LSN", -1)
---
- ok
...
-- Check that log contains the mention of broken LSN and the request printout
filename = fio.pathjoin(fio.cwd(), 'replica.log')
---
...
str = string.format("LSN for 1 is used twice or COMMIT order is broken: confirmed: %d, new: %d, req: .*", lsn, lsn)
---
...
found = test_run:grep_log(nil, str, 256, {filename = filename})
---
...
(found:gsub('^.*, req: ', ''):gsub('lsn: %d+', 'lsn: <lsn>'))
---
- '{type: ''INSERT'', replica_id: 1, lsn: <lsn>, space_id: 9000, index_id: 0, tuple:
[2, "v1"]}'
...
test_run:cmd('cleanup server replica')
---
- true
...
test_run:cmd('delete server replica')
---
- true
...
box.space.test:drop()
---
...
box.schema.user.revoke('guest', 'replication')
---
...
|