File: checkpoint_daemon.result

package info (click to toggle)
tarantool 2.6.0-1.4
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 85,412 kB
  • sloc: ansic: 513,775; cpp: 69,493; sh: 25,650; python: 19,190; perl: 14,973; makefile: 4,178; yacc: 1,329; sql: 1,074; pascal: 620; ruby: 190; awk: 18; lisp: 7
file content (178 lines) | stat: -rw-r--r-- 3,481 bytes parent folder | download | duplicates (3)
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
175
176
177
178
fio = require 'fio'
---
...
errno = require 'errno'
---
...
fiber = require 'fiber'
---
...
env = require('test_run')
---
...
test_run = env.new()
---
...
test_run:cleanup_cluster()
---
...
default_checkpoint_count = box.cfg.checkpoint_count
---
...
default_checkpoint_interval = box.cfg.checkpoint_interval
---
...
box.cfg{checkpoint_interval = 0}
---
...
PERIOD = jit.os == 'Linux' and 0.03 or 1.5
---
...
WAIT_COND_TIMEOUT = 10
---
...
space = box.schema.space.create('checkpoint_daemon')
---
...
index = space:create_index('pk', { type = 'tree', parts = { 1, 'unsigned' }})
---
...
test_run:cmd("setopt delimiter ';'")
---
- true
...
-- wait_snapshot* functions update these variables.
snaps = {};
---
...
xlogs = {};
---
...
-- Wait until tarantool creates a snapshot containing current
-- data slice.
function wait_snapshot(timeout)
    snaps = {}
    xlogs = {}
    local signature_str = tostring(box.info.signature)
    signature_str = string.rjust(signature_str, 20, '0')
    local exp_snap_filename = string.format('%s.snap', signature_str)
    return test_run:wait_cond(function()
        snaps = fio.glob(fio.pathjoin(box.cfg.memtx_dir, '*.snap'))
        xlogs = fio.glob(fio.pathjoin(box.cfg.wal_dir, '*.xlog'))
        return fio.basename(snaps[#snaps]) == exp_snap_filename
    end, timeout)
end;
---
...
-- Wait until snapshots count will be equal to the
-- checkpoint_count option.
function wait_snapshot_gc(timeout)
    snaps = {}
    xlogs = {}
    return test_run:wait_cond(function()
        snaps = fio.glob(fio.pathjoin(box.cfg.memtx_dir, '*.snap'))
        xlogs = fio.glob(fio.pathjoin(box.cfg.wal_dir, '*.xlog'))
        return #snaps == box.cfg.checkpoint_count
    end, timeout)
end;
---
...
test_run:cmd("setopt delimiter ''");
---
- true
...
box.cfg{checkpoint_interval = PERIOD, checkpoint_count = 2 }
---
...
no = 1
---
...
row_count_per_wal = box.cfg.wal_max_size / 50
---
...
-- first xlog
for i = 1, row_count_per_wal + 10 do space:insert { no } no = no + 1 end
---
...
-- second xlog
for i = 1, row_count_per_wal + 10 do space:insert { no } no = no + 1 end
---
...
wait_snapshot(WAIT_COND_TIMEOUT)
---
- true
...
-- third xlog
for i = 1, row_count_per_wal + 10 do space:insert { no } no = no + 1 end
---
...
-- fourth xlog
for i = 1, row_count_per_wal + 10 do space:insert { no } no = no + 1 end
---
...
wait_snapshot(WAIT_COND_TIMEOUT)
---
- true
...
wait_snapshot_gc(WAIT_COND_TIMEOUT)
---
- true
...
#snaps == 2 or snaps
---
- true
...
#xlogs > 0
---
- true
...
-- gh-2780: check that a last snapshot mtime will be changed at
-- least two times.
test_run:cmd("setopt delimiter ';'")
---
- true
...
last_mtime = fio.stat(snaps[#snaps]).mtime;
---
...
mtime_changes_cnt = 0;
---
...
test_run:wait_cond(function()
    local mtime = fio.stat(snaps[#snaps]).mtime
    if mtime ~= last_mtime then
        mtime_changes_cnt = mtime_changes_cnt + 1
        last_mtime = mtime
    end
    return mtime_changes_cnt == 2
end, WAIT_COND_TIMEOUT);
---
- true
...
test_run:cmd("setopt delimiter ''");
---
- true
...
-- Check that checkpoint_count can't be < 1.
box.cfg{ checkpoint_count = 1 }
---
...
box.cfg{ checkpoint_count = 0 }
---
- error: 'Incorrect value for option ''checkpoint_count'': the value must not be less
    than one'
...
box.cfg.checkpoint_count
---
- 1
...
-- Restore default options.
box.cfg{checkpoint_count = default_checkpoint_count}
---
...
box.cfg{checkpoint_interval = default_checkpoint_interval}
---
...
space:drop()
---
...