File: big_lsn.test.py

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 (39 lines) | stat: -rw-r--r-- 993 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
import os

#
# Check that Tarantool handles huge LSNs well (gh-4033).
#

# Fill an empty directory.
server.stop()
server.deploy()
server.admin("box.info.lsn")
server.admin("box.space._schema:delete('dummy')")
server.stop()

# Bump the instance vclock by tweaking the last xlog.
old_lsn = 1
new_lsn = 123456789123
wal_dir = os.path.join(server.vardir, server.name)
old_wal = os.path.join(wal_dir, "%020d.xlog" % old_lsn)
new_wal = os.path.join(wal_dir, "%020d.xlog" % new_lsn)
with open(old_wal, "r+") as f:
    s = f.read()
    s = s.replace("VClock: {1: %d}" % old_lsn,
                  "VClock: {1: %d}" % new_lsn)
    f.seek(0)
    f.write(s)
os.rename(old_wal, new_wal)

# Recover and make a snapshot.
server.start()
server.admin("box.info.lsn")
server.admin("box.space._schema:delete('dummy')")
server.admin("box.snapshot()")
server.stop()

# Try one more time.
server.start()
server.admin("box.info.lsn")
server.admin("box.space._schema:delete('dummy')")
server.admin("box.snapshot()")