diff --git a/src/box/errcode.h b/src/box/errcode.h index a3c2fae75a5854c974d13bf656f40ba58d7d4d65..3489064611a585cf1d29b27262d3f0f06c429ece 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 071122b8dd6204e291dc347ed9b6e77519172d53..6090ddc736bae04be35f1bb64eaae7805a5ebaf3 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 3e85cc24bd3f6c6302fa4b3b7d69d033c5b5226f..1c1fece5f2e65398f94914023cb51ed53e1dc13c 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 37dcab80385fd7bb78d10e833c20a59515440814..9cd619bdcde110e48f8af08e09a44ed4c66130f2 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()')