Skip to content
Snippets Groups Projects
Commit 19b5fb1c authored by Vladimir Davydov's avatar Vladimir Davydov
Browse files

vclock: fix big lsn handling

Fixes commit 8031071e ("Lightweight vclock_create and vclock_copy").

Closes #4033
parent 0d0f53aa
No related branches found
No related tags found
No related merge requests found
......@@ -165,7 +165,7 @@ vclock_get(const struct vclock *vclock, uint32_t replica_id)
*/
replica_id &= VCLOCK_MAX - 1;
/* Evaluate a bitmask to avoid branching. */
int64_t mask = 0 - ((vclock->map >> replica_id) & 0x1);
int64_t mask = 0ULL - ((vclock->map >> replica_id) & 0x1);
return mask & vclock->lsn[replica_id];
}
......
box.info.lsn
---
- 0
...
box.space._schema:delete('dummy')
---
...
box.info.lsn
---
- 123456789123
...
box.space._schema:delete('dummy')
---
...
box.snapshot()
---
- ok
...
box.info.lsn
---
- 123456789124
...
box.space._schema:delete('dummy')
---
...
box.snapshot()
---
- ok
...
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()")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment