Tarantool development patches archive
 help / color / mirror / Atom feed
* [PATCH] vclock: fix big lsn handling
@ 2019-03-07 14:58 Vladimir Davydov
  2019-03-07 16:11 ` Vladimir Davydov
  0 siblings, 1 reply; 2+ messages in thread
From: Vladimir Davydov @ 2019-03-07 14:58 UTC (permalink / raw)
  To: tarantool-patches

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

Closes #4033
---
https://github.com/tarantool/tarantool/issues/4033
https://github.com/tarantool/tarantool/commits/dv/gh-4033-fix-crash-on-big-lsn

 src/box/vclock.h             |  2 +-
 test/xlog-py/big_lsn.result  | 29 +++++++++++++++++++++++++++++
 test/xlog-py/big_lsn.test.py | 39 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 69 insertions(+), 1 deletion(-)
 create mode 100644 test/xlog-py/big_lsn.result
 create mode 100644 test/xlog-py/big_lsn.test.py

diff --git a/src/box/vclock.h b/src/box/vclock.h
index 1a174c1e..f9633ac9 100644
--- a/src/box/vclock.h
+++ b/src/box/vclock.h
@@ -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];
 }
 
diff --git a/test/xlog-py/big_lsn.result b/test/xlog-py/big_lsn.result
new file mode 100644
index 00000000..b370773f
--- /dev/null
+++ b/test/xlog-py/big_lsn.result
@@ -0,0 +1,29 @@
+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
+...
diff --git a/test/xlog-py/big_lsn.test.py b/test/xlog-py/big_lsn.test.py
new file mode 100644
index 00000000..c6a31d97
--- /dev/null
+++ b/test/xlog-py/big_lsn.test.py
@@ -0,0 +1,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()")
-- 
2.11.0

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] vclock: fix big lsn handling
  2019-03-07 14:58 [PATCH] vclock: fix big lsn handling Vladimir Davydov
@ 2019-03-07 16:11 ` Vladimir Davydov
  0 siblings, 0 replies; 2+ messages in thread
From: Vladimir Davydov @ 2019-03-07 16:11 UTC (permalink / raw)
  To: tarantool-patches

On Thu, Mar 07, 2019 at 05:58:58PM +0300, Vladimir Davydov wrote:
> Fixes commit 8031071efa94 ("Lightweight vclock_create and vclock_copy").
> 
> Closes #4033
> ---
> https://github.com/tarantool/tarantool/issues/4033
> https://github.com/tarantool/tarantool/commits/dv/gh-4033-fix-crash-on-big-lsn
> 
>  src/box/vclock.h             |  2 +-
>  test/xlog-py/big_lsn.result  | 29 +++++++++++++++++++++++++++++
>  test/xlog-py/big_lsn.test.py | 39 +++++++++++++++++++++++++++++++++++++++
>  3 files changed, 69 insertions(+), 1 deletion(-)
>  create mode 100644 test/xlog-py/big_lsn.result
>  create mode 100644 test/xlog-py/big_lsn.test.py
> 
> diff --git a/src/box/vclock.h b/src/box/vclock.h
> index 1a174c1e..f9633ac9 100644
> --- a/src/box/vclock.h
> +++ b/src/box/vclock.h
> @@ -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];
>  }

Trivial. Pushed to 2.1 and 1.10.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-03-07 16:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-07 14:58 [PATCH] vclock: fix big lsn handling Vladimir Davydov
2019-03-07 16:11 ` Vladimir Davydov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox