File: view_delayed_wal.test.lua

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 (47 lines) | stat: -rw-r--r-- 1,882 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
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)')
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)
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)
fiber.sleep(0.1)
box.space.T1 ~= nil
box.space.V1 ~= nil

--
-- 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)')
box.execute('CREATE VIEW view2 AS SELECT * FROM t2')

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)
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)
fiber.sleep(0.1)
box.space._space:get{box.space.T2.id}['name']
box.space.V2

-- 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')