File: view_delayed_wal.result

package info (click to toggle)
tarantool 2.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 85,364 kB
  • sloc: ansic: 513,760; cpp: 69,489; sh: 25,650; python: 19,190; perl: 14,973; makefile: 4,173; yacc: 1,329; sql: 1,074; pascal: 620; ruby: 190; awk: 18; lisp: 7
file content (112 lines) | stat: -rw-r--r-- 2,201 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
test_run = require('test_run').new()
---
...
engine = test_run:get_cfg('engine')
---
...
_ = box.space._session_settings:update('sql_default_engine', {{'=', 2, engine}})
---
...
fiber = require('fiber')
---
...
-- View reference counters are incremented before firing
-- on_commit triggers (i.e. before being written into WAL), so
-- it is impossible to drop a space referenced by a created, but
-- *still* not yet committed view.
--
box.execute('CREATE TABLE t1(id INT PRIMARY KEY)')
---
- row_count: 1
...
function create_view() box.execute('CREATE VIEW v1 AS SELECT * FROM t1') end
---
...
function drop_index_t1() box.space._index:delete{box.space.T1.id, 0} end
---
...
function drop_space_t1() box.space._space:delete{box.space.T1.id} end
---
...
box.error.injection.set("ERRINJ_WAL_DELAY", true)
---
- ok
...
f1 = fiber.create(create_view)
---
...
f2 = fiber.create(drop_index_t1)
---
...
f3 = fiber.create(drop_space_t1)
---
...
box.error.injection.set("ERRINJ_WAL_DELAY", false)
---
- ok
...
fiber.sleep(0.1)
---
...
box.space.T1 ~= nil
---
- true
...
box.space.V1 ~= nil
---
- true
...
--
-- In the same way, we have to drop all referenced spaces before
-- dropping view, since view reference counter of space to be
-- dropped is checked before firing on_commit trigger.
--
box.execute('CREATE TABLE t2 (id INT PRIMARY KEY)')
---
- row_count: 1
...
box.execute('CREATE VIEW view2 AS SELECT * FROM t2')
---
- row_count: 1
...
function drop_view() box.space._space:delete{box.space.VIEW2.id} end
---
...
function drop_index_t2() box.space._index:delete{box.space.T2.id, 0} end
---
...
function drop_space_t2() box.space._space:delete{box.space.T2.id} end
---
...
box.error.injection.set("ERRINJ_WAL_DELAY", true)
---
- ok
...
f1 = fiber.create(drop_index_t2)
---
...
f2 = fiber.create(drop_space_t2)
---
...
f3 = fiber.create(drop_view)
---
...
box.error.injection.set("ERRINJ_WAL_DELAY", false)
---
- ok
...
fiber.sleep(0.1)
---
...
box.space._space:get{box.space.T2.id}['name']
---
- T2
...
box.space.V2
---
- null
...
-- Since deletion via Lua doesn't remove entry from
-- SQL data dictionary we have to restart instance to clean up.
--
test_run:cmd('restart server default with cleanup=1')