Skip to content

Commit

Permalink
net.box: fix fetching of schema of an old version
Browse files Browse the repository at this point in the history
After 2.2.0-633-gaa0964ae1 ('net.box: fix schema fetching from 1.10/2.1
servers') net.box expects that _vcollation system view exists on a
tarantool server of 2.2.1+ version. This is however not always so: a
server may be run on a new version of tarantool, but work on a schema of
an old version.

The situation with non last schema is usual for replication cluster in
process of upgrading: all instances run on the new version of tarantool
first (no auto-upgrade is performed by tarantools in a cluster). Then
box.schema.upgrade() should be called, but the instances should be
operable even before the call.

Before the commit net.box was unable to connect a server if it is run on
a schema without _vcollation system view (say, 2.1.3), but the server
executable is of 2.2.1 version or newer.

Note: I trim tests from the commit to polish them a bit more, but
include the fix itself to 2.4.1 release.

Follows up #4307
Fixes #4691
  • Loading branch information
Totktonada authored and kyukhin committed Apr 20, 2020
1 parent 335f80a commit 06edcbe
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/box/lua/net_box.lua
Expand Up @@ -56,6 +56,7 @@ local E_UNKNOWN = box.error.UNKNOWN
local E_NO_CONNECTION = box.error.NO_CONNECTION
local E_TIMEOUT = box.error.TIMEOUT
local E_PROC_LUA = box.error.PROC_LUA
local E_NO_SUCH_SPACE = box.error.NO_SUCH_SPACE

-- utility tables
local is_final_state = {closed = 1, error = 1}
Expand Down Expand Up @@ -803,6 +804,13 @@ local function create_transport(host, port, user, password, callback,
local status = hdr[IPROTO_STATUS_KEY]
local response_schema_version = hdr[IPROTO_SCHEMA_VERSION_KEY]
if status ~= 0 then
-- No _vcollation space (server has an old
-- schema version).
local errno = band(status, IPROTO_ERRNO_MASK)
if id == select3_id and errno == E_NO_SUCH_SPACE then
peer_has_vcollation = false
goto continue
end
local body
body, body_end = decode(body_rpos)
return error_sm(E_NO_CONNECTION, body[IPROTO_ERROR_KEY])
Expand All @@ -817,6 +825,7 @@ local function create_transport(host, port, user, password, callback,
body, body_end = decode(body_rpos)
response[id] = body[IPROTO_DATA_KEY]
end
::continue::
until response[select1_id] and response[select2_id] and
(not peer_has_vcollation or response[select3_id])
-- trick: response[select3_id] is nil when the key is nil
Expand Down

0 comments on commit 06edcbe

Please sign in to comment.