From 72f1a5821d447896b38295a6c604d6e87a5dfdd2 Mon Sep 17 00:00:00 2001 From: Roman Tsisyk <roman@tsisyk.com> Date: Mon, 2 Feb 2015 19:37:19 +0300 Subject: [PATCH] Fix #707: Master crashes on JOIN if it doesn't have snapshot files --- src/box/errcode.h | 1 + src/box/recovery.cc | 2 ++ test/replication/cluster.result | 4 ++++ test/replication/cluster.test.py | 13 +++++++++++++ 4 files changed, 20 insertions(+) diff --git a/src/box/errcode.h b/src/box/errcode.h index a3c2fae75a..3489064611 100644 --- a/src/box/errcode.h +++ b/src/box/errcode.h @@ -144,6 +144,7 @@ struct errcode_record { /* 90 */_(ER_ROLE_GRANTED, 2, "User '%s' already has role '%s'") \ /* 91 */_(ER_PRIV_NOT_GRANTED, 2, "User '%s' does not have %s access on %s '%s'") \ /* 92 */_(ER_ROLE_NOT_GRANTED, 2, "User '%s' does not have role '%s'") \ + /* 93 */_(ER_MISSING_SNAPSHOT, 2, "Can't find snapshot") \ /* * !IMPORTANT! Please follow instructions at start of the file diff --git a/src/box/recovery.cc b/src/box/recovery.cc index 071122b8dd..6090ddc736 100644 --- a/src/box/recovery.cc +++ b/src/box/recovery.cc @@ -354,6 +354,8 @@ recover_snap(struct recovery_state *r) * have created it from a bootstrap copy. */ struct vclock *res = vclockset_last(&r->snap_dir.index); + if (res == NULL) + tnt_raise(ClientError, ER_MISSING_SNAPSHOT); int64_t signature = vclock_signature(res); struct xlog *snap = xlog_open(&r->snap_dir, signature, NONE); diff --git a/test/replication/cluster.result b/test/replication/cluster.result index 3e85cc24bd..1c1fece5f2 100644 --- a/test/replication/cluster.result +++ b/test/replication/cluster.result @@ -22,6 +22,10 @@ box.schema.user.grant('guest', 'replication') --- ... ok - join with granted role +------------------------------------------------------------- +gh-707: Master crashes on JOIN if it does not have snapshot files +------------------------------------------------------------- +ok - join without snapshots box.schema.user.revoke('guest', 'replication') --- ... diff --git a/test/replication/cluster.test.py b/test/replication/cluster.test.py index 37dcab8038..9cd619bdcd 100644 --- a/test/replication/cluster.test.py +++ b/test/replication/cluster.test.py @@ -3,6 +3,7 @@ import sys import re import yaml import uuid +import glob from lib.tarantool_server import TarantoolServer ## Get cluster uuid @@ -68,6 +69,18 @@ server.admin("box.schema.user.grant('guest', 'replication')") server.sql.py_con.close() # re-connect with new permissions server_id = check_join('join with granted role') server.sql.py_con.space('_cluster').delete(server_id) + +print '-------------------------------------------------------------' +print 'gh-707: Master crashes on JOIN if it does not have snapshot files' +print '-------------------------------------------------------------' + +for k in glob.glob(os.path.join(server.vardir, '*.snap')): + os.unlink(k) + +rows = list(server.sql.py_con.join(replica_uuid)) +print len(rows) == 1 and rows[0].return_message.find('snapshot') >= 0 and \ + 'ok' or 'not ok', '-', 'join without snapshots' + server.admin("box.schema.user.revoke('guest', 'replication')") server.admin('box.snapshot()') -- GitLab