* [Tarantool-patches] [PATCH] net.box: fix fetching of schema of an old version
@ 2020-04-01 20:45 Alexander Turenko
2020-04-02 21:20 ` Alexander Turenko
` (2 more replies)
0 siblings, 3 replies; 14+ messages in thread
From: Alexander Turenko @ 2020-04-01 20:45 UTC (permalink / raw)
To: Vladislav Shpilevoy; +Cc: tarantool-patches
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.
Follows up #4307
Fixes #4691
---
https://github.com/tarantool/tarantool/issues/4691
https://github.com/tarantool/tarantool/tree/Totktonada/gh-4691-net-box-connect-schema-2-1-3
src/box/lua/net_box.lua | 9 ++
...4691-net-box-connect-schema-2-1-3.test.lua | 93 ++++++++++++++++++
test/box-tap/no_auto_schema_upgrade.lua | 30 ++++++
.../snap/2.1.3/00000000000000000000.snap | Bin 0 -> 4466 bytes
4 files changed, 132 insertions(+)
create mode 100755 test/box-tap/gh-4691-net-box-connect-schema-2-1-3.test.lua
create mode 100644 test/box-tap/no_auto_schema_upgrade.lua
create mode 100644 test/box-tap/snap/2.1.3/00000000000000000000.snap
diff --git a/src/box/lua/net_box.lua b/src/box/lua/net_box.lua
index 3f611c027..d3ccc0fc6 100644
--- a/src/box/lua/net_box.lua
+++ b/src/box/lua/net_box.lua
@@ -53,6 +53,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}
@@ -779,6 +780,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])
@@ -793,6 +801,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
diff --git a/test/box-tap/gh-4691-net-box-connect-schema-2-1-3.test.lua b/test/box-tap/gh-4691-net-box-connect-schema-2-1-3.test.lua
new file mode 100755
index 000000000..565f7da7b
--- /dev/null
+++ b/test/box-tap/gh-4691-net-box-connect-schema-2-1-3.test.lua
@@ -0,0 +1,93 @@
+#!/usr/bin/env tarantool
+
+--
+-- gh-4691: net.box fails to connect to tarantool-2.2+ server with
+-- a schema of version 2.1.3 or below (w/o _vcollation system
+-- space).
+--
+-- Tarantool does not update a schema automatically when an
+-- instance is in a replication cluster, because it may break
+-- instances that are run under an old tarantool version. It is
+-- quite usual to have non-upgraded instances for some time,
+-- because upgrade is usually performed step-by-step.
+--
+-- net.box leans on a server version from greeting to determine
+-- whether _vcollation system view should exist and reports an
+-- error if fetching of the space fails. This causes the problem:
+-- a version may be 2.2+, but _vcollation does not exists, because
+-- schema upgrade is not performed yet. The fix of gh-4691 allows
+-- the server to respond ER_NO_SUCH_SPACE for the query.
+--
+
+local test_run = require('test_run').new()
+local net_box = require('net.box')
+local tap = require('tap')
+
+local function before_all()
+ local opts = {
+ 'script = "box-tap/no_auto_schema_upgrade.lua"',
+ 'workdir = "box-tap/snap/2.1.3"',
+ 'return_listen_uri = True',
+ }
+ local opts_str = table.concat(opts, ', ')
+ local cmd = 'create server schema_2_1_3 with %s'
+ local uri = test_run:cmd(cmd:format(opts_str))
+ test_run:cmd('start server schema_2_1_3')
+
+ -- Create 'test' space with 'unicode_ci' index part.
+ --
+ -- We need it to verify that net.box will expose collation_id
+ -- for an index key part when collation names information is
+ -- not available.
+ --
+ -- Note: read_only = false on reconfiguration does not lead to
+ -- a schema upgrading.
+ test_run:eval('schema_2_1_3', ([[
+ box.cfg{read_only = false}
+ box.schema.create_space('test')
+ box.space.test:create_index('pk', {parts =
+ {{field = 1, type = 'string', collation = 'unicode_ci'}}})
+ box.cfg{read_only = true}
+ ]]):gsub('\n', ' '))
+ return uri
+end
+
+local function test_connect_schema_2_1_3(test, uri)
+ test:plan(3)
+
+ local connection = net_box.connect(uri)
+
+ -- Connection is alive.
+ test:ok(connection:is_connected(), 'connection is alive')
+
+ -- Space metainfo is correct: collation_id is exposed when
+ -- collation name information is not available.
+ local key_part = connection.space.test.index[0].parts[1]
+ test:is(key_part.collation, nil,
+ 'collation names are not available')
+ test:is(type(key_part.collation_id), 'number',
+ 'collation numeric ids are exposed')
+
+ connection:close()
+end
+
+local function after_all()
+ -- Drop 'test' space.
+ test_run:eval('schema_2_1_3', ([[
+ box.cfg{read_only = false}
+ box.space.test:drop()
+ box.cfg{read_only = true}
+ ]]):gsub('\n', ' '))
+
+ test_run:cmd('stop server schema_2_1_3')
+ test_run:cmd('cleanup server schema_2_1_3')
+ test_run:cmd('delete server schema_2_1_3')
+end
+
+local uri = before_all()
+local test = tap.test('gh-4691-net-box-connect-schema-2-1-3')
+test:plan(1)
+test:test('connect_schema_2_1_3', test_connect_schema_2_1_3, uri)
+after_all()
+
+os.exit(test:check() and 0 or 1)
diff --git a/test/box-tap/no_auto_schema_upgrade.lua b/test/box-tap/no_auto_schema_upgrade.lua
new file mode 100644
index 000000000..b693637ac
--- /dev/null
+++ b/test/box-tap/no_auto_schema_upgrade.lua
@@ -0,0 +1,30 @@
+#!/usr/bin/env tarantool
+
+--
+-- This instance is intended to be used with existing snapshot
+-- from a previous tarantool version. It does not perform
+-- automatic schema upgrade.
+--
+-- Having tarantool in this state allows us to create test cases
+-- for net.box, relay, applier connected to an instance in such
+-- state or test behaviour of the instance itself.
+--
+-- There are two ways to disable automatic schema upgrade: set
+-- 'replication' box.cfg(<...>) option or set 'read_only' option.
+-- Use the latter one, because it is simpler.
+--
+
+box.cfg({
+ listen = os.getenv('LISTEN'),
+ read_only = true,
+})
+
+-- Give 'guest' user read/write accesses to all spaces.
+--
+-- Note: reconfiguration with read_only = false does not lead to
+-- schema upgrading.
+box.cfg{read_only = false}
+box.schema.user.grant('guest', 'read, write', 'universe')
+box.cfg{read_only = true}
+
+require('console').listen(os.getenv('ADMIN'))
diff --git a/test/box-tap/snap/2.1.3/00000000000000000000.snap b/test/box-tap/snap/2.1.3/00000000000000000000.snap
new file mode 100644
index 0000000000000000000000000000000000000000..c8eecc0b4cc6b7bc0ee8634b3d51081662331da7
GIT binary patch
literal 4466
zcmV-&5smIsPC-x#FfK7O3RY!ub7^mGIv_GGF)lMLFfC^@IAk|uHe)qp3Q2BrbYX5|
zWjY{XVm320F*!LcWn(ruEi^D=Gc7qXF*YqSH8o{6F=jb9Vq`N4RzqxWV{1AfdwmKD
z)w&D1%@Fzk&U17FP^AC>0000ewJ-euP>qKG%9u1FMi7Wt+W-In0001RFet(YFVtK2
zf0sfAlW(K}05f&SC}m1UnJL<qD>qlp#0`(NKMrfvA;5%fHx*vF9_)X%KG)6BV<!?E
z0vZAX0%X>5EyrZ=%@KovY>ovN;GC*}otzV93`v3!Ly})CAlnMUpgS*MWIGDJpqjkx
zx>WFOaq*(bEfi={j^5JJMUz>$XmWxrn$%>AMGHw@$wHD=CLqbS3YPz=T>0P0%KvRs
zl@E^uR3dO1asNKY!JF%^N8CRM`iy5v69f|E{6GXbJ1~Xk83a5tJ-{>1QXI&6X_m7R
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+g>z;=Z*7316trcCT;bq#s&zwSF)Z^=$SI<*EZiw=$SI<*EZiw=$X><Bt1OY
zi)d2D73&(CPK{95-J^G9-olOyRBWR>4CObB0t?7~dtaWO1*<;d!(RvbN#bKDAJq`8
E?c6t5<^TWy
literal 0
HcmV?d00001
--
2.25.0
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Tarantool-patches] [PATCH] net.box: fix fetching of schema of an old version
2020-04-01 20:45 [Tarantool-patches] [PATCH] net.box: fix fetching of schema of an old version Alexander Turenko
@ 2020-04-02 21:20 ` Alexander Turenko
2020-04-03 22:53 ` Vladislav Shpilevoy
2020-04-20 6:58 ` Alexander Turenko
2 siblings, 0 replies; 14+ messages in thread
From: Alexander Turenko @ 2020-04-02 21:20 UTC (permalink / raw)
To: Vladislav Shpilevoy; +Cc: tarantool-patches
On Wed, Apr 01, 2020 at 11:45:21PM +0300, Alexander Turenko wrote:
> 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.
>
> Follows up #4307
> Fixes #4691
> ---
>
> https://github.com/tarantool/tarantool/issues/4691
> https://github.com/tarantool/tarantool/tree/Totktonada/gh-4691-net-box-connect-schema-2-1-3
Forgot to add the changelog entry.
```
## Bugs fixed
### Lua
* net.box: fixed inability to connect 2.2.1+ server before
box.schema.upgrade() is called on the server (gh-4691)
```
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Tarantool-patches] [PATCH] net.box: fix fetching of schema of an old version
2020-04-01 20:45 [Tarantool-patches] [PATCH] net.box: fix fetching of schema of an old version Alexander Turenko
2020-04-02 21:20 ` Alexander Turenko
@ 2020-04-03 22:53 ` Vladislav Shpilevoy
2020-04-03 23:38 ` Alexander Turenko
2020-04-20 6:58 ` Alexander Turenko
2 siblings, 1 reply; 14+ messages in thread
From: Vladislav Shpilevoy @ 2020-04-03 22:53 UTC (permalink / raw)
To: Alexander Turenko; +Cc: tarantool-patches
Hi! Thanks for the patch!
On 01/04/2020 22:45, Alexander Turenko wrote:
> 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.
>
> Follows up #4307
> Fixes #4691
> ---
>
> https://github.com/tarantool/tarantool/issues/4691
> https://github.com/tarantool/tarantool/tree/Totktonada/gh-4691-net-box-connect-schema-2-1-3
>
> src/box/lua/net_box.lua | 9 ++
> ...4691-net-box-connect-schema-2-1-3.test.lua | 93 ++++++++++++++++++
> test/box-tap/no_auto_schema_upgrade.lua | 30 ++++++
> .../snap/2.1.3/00000000000000000000.snap | Bin 0 -> 4466 bytes
> 4 files changed, 132 insertions(+)
> create mode 100755 test/box-tap/gh-4691-net-box-connect-schema-2-1-3.test.lua
We have xlog/upgrade suite specifically for these tests. With
already designed processes, where and how to store old snaps, etc.
See xlog/upgrade/how_to_add_new_test.md.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Tarantool-patches] [PATCH] net.box: fix fetching of schema of an old version
2020-04-03 22:53 ` Vladislav Shpilevoy
@ 2020-04-03 23:38 ` Alexander Turenko
2020-04-04 17:40 ` Vladislav Shpilevoy
0 siblings, 1 reply; 14+ messages in thread
From: Alexander Turenko @ 2020-04-03 23:38 UTC (permalink / raw)
To: Vladislav Shpilevoy; +Cc: tarantool-patches
On Sat, Apr 04, 2020 at 12:53:53AM +0200, Vladislav Shpilevoy wrote:
> Hi! Thanks for the patch!
>
> On 01/04/2020 22:45, Alexander Turenko wrote:
> > 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.
> >
> > Follows up #4307
> > Fixes #4691
> > ---
> >
> > https://github.com/tarantool/tarantool/issues/4691
> > https://github.com/tarantool/tarantool/tree/Totktonada/gh-4691-net-box-connect-schema-2-1-3
> >
> > src/box/lua/net_box.lua | 9 ++
> > ...4691-net-box-connect-schema-2-1-3.test.lua | 93 ++++++++++++++++++
> > test/box-tap/no_auto_schema_upgrade.lua | 30 ++++++
> > .../snap/2.1.3/00000000000000000000.snap | Bin 0 -> 4466 bytes
> > 4 files changed, 132 insertions(+)
> > create mode 100755 test/box-tap/gh-4691-net-box-connect-schema-2-1-3.test.lua
>
> We have xlog/upgrade suite specifically for these tests. With
> already designed processes, where and how to store old snaps, etc.
> See xlog/upgrade/how_to_add_new_test.md.
Not exactly.
I want to test the case when an instance is NOT upgraded. So 'upgrade'
directory name for snaps would be misleading.
I also think that we should move from using compare-against-output
tests. I'll not insist on this during review, but personally I will
create new tests using pytest-like (phpunit-like, maven-failsafe-like,
luatest-like) way (it is our TAP13 tests or at least near to them). I
can summarize cons and pros if you want (don't sure whether I did it
already somewhere).
We can move 'snap' directory upward (right into test/) and use it for
snapshots for all test suites. Or keep them per-suite. However see the
next paragraph re fill.lua.
I prefer to feed initial schema and data right from a test to keep them
near to actual usage in test cases (within one file). Sometimes it eases
reading of test cases, especially when you're not much familiar with a
testing system. I don't much like the approach with fill.lua script (at
least for data corresponds to test cases).
WBR, Alexander Turenko.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Tarantool-patches] [PATCH] net.box: fix fetching of schema of an old version
2020-04-03 23:38 ` Alexander Turenko
@ 2020-04-04 17:40 ` Vladislav Shpilevoy
2020-04-05 12:05 ` Alexander Turenko
0 siblings, 1 reply; 14+ messages in thread
From: Vladislav Shpilevoy @ 2020-04-04 17:40 UTC (permalink / raw)
To: Alexander Turenko; +Cc: tarantool-patches
>>> https://github.com/tarantool/tarantool/issues/4691
>>> https://github.com/tarantool/tarantool/tree/Totktonada/gh-4691-net-box-connect-schema-2-1-3
>>>
>>> src/box/lua/net_box.lua | 9 ++
>>> ...4691-net-box-connect-schema-2-1-3.test.lua | 93 ++++++++++++++++++
>>> test/box-tap/no_auto_schema_upgrade.lua | 30 ++++++
>>> .../snap/2.1.3/00000000000000000000.snap | Bin 0 -> 4466 bytes
>>> 4 files changed, 132 insertions(+)
>>> create mode 100755 test/box-tap/gh-4691-net-box-connect-schema-2-1-3.test.lua
>>
>> We have xlog/upgrade suite specifically for these tests. With
>> already designed processes, where and how to store old snaps, etc.
>> See xlog/upgrade/how_to_add_new_test.md.
>
>
> I want to test the case when an instance is NOT upgraded. So 'upgrade'
> directory name for snaps would be misleading.
The test and the bug are still upgrade related. 'xlog/upgrade' is not
called 'xlog/upgrade_called'. It is called just 'upgrade'. For all cases
when an old snapshot is used to start a new tarantool.
> I also think that we should move from using compare-against-output
> tests.
This is not about tap vs diff. It is about having all upgrade related
tests in one place, and organized in one way, with how to fill them, with
how to store xlogs and snapshots in the repository.
> I'll not insist on this during review, but personally I will
> create new tests using pytest-like (phpunit-like, maven-failsafe-like,
> luatest-like) way (it is our TAP13 tests or at least near to them). I
> can summarize cons and pros if you want (don't sure whether I did it
> already somewhere).
Don't really want to discuss this again, everything was said already
1000 times or more.
> We can move 'snap' directory upward (right into test/) and use it for
> snapshots for all test suites. Or keep them per-suite. However see the
> next paragraph re fill.lua.
This is a bad idea, because different upgrade-related tests usually
need some specific data stored in the old snapshot. If you merge data,
needed by many tests, into one snapshot, you will violate the policy of
one-bug-one-test. Because many tests will start to depend on each other.
> I prefer to feed initial schema and data right from a test to keep them
> near to actual usage in test cases (within one file).
This makes impossible to test bugs, which appear only when you bootstrap
from the old snapshot.
> Sometimes it eases
> reading of test cases, especially when you're not much familiar with a
> testing system.
You are now creating a second way of testing upgrade. This is definitely
not a simplification of the testing system.
> I don't much like the approach with fill.lua script (at
> least for data corresponds to test cases).
fill.lua is inevitable, when you need to test bootstrap from an old
snapshot having some data in it before you start tarantool, and you want
to know what data is stored here exactly.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Tarantool-patches] [PATCH] net.box: fix fetching of schema of an old version
2020-04-04 17:40 ` Vladislav Shpilevoy
@ 2020-04-05 12:05 ` Alexander Turenko
2020-04-05 16:41 ` Vladislav Shpilevoy
0 siblings, 1 reply; 14+ messages in thread
From: Alexander Turenko @ 2020-04-05 12:05 UTC (permalink / raw)
To: Vladislav Shpilevoy; +Cc: tarantool-patches
On Sat, Apr 04, 2020 at 07:40:44PM +0200, Vladislav Shpilevoy wrote:
> >>> https://github.com/tarantool/tarantool/issues/4691
> >>> https://github.com/tarantool/tarantool/tree/Totktonada/gh-4691-net-box-connect-schema-2-1-3
> >>>
> >>> src/box/lua/net_box.lua | 9 ++
> >>> ...4691-net-box-connect-schema-2-1-3.test.lua | 93 ++++++++++++++++++
> >>> test/box-tap/no_auto_schema_upgrade.lua | 30 ++++++
> >>> .../snap/2.1.3/00000000000000000000.snap | Bin 0 -> 4466 bytes
> >>> 4 files changed, 132 insertions(+)
> >>> create mode 100755 test/box-tap/gh-4691-net-box-connect-schema-2-1-3.test.lua
> >>
> >> We have xlog/upgrade suite specifically for these tests. With
> >> already designed processes, where and how to store old snaps, etc.
> >> See xlog/upgrade/how_to_add_new_test.md.
> >
> >
> > I want to test the case when an instance is NOT upgraded. So 'upgrade'
> > directory name for snaps would be misleading.
>
> The test and the bug are still upgrade related. 'xlog/upgrade' is not
> called 'xlog/upgrade_called'. It is called just 'upgrade'. For all cases
> when an old snapshot is used to start a new tarantool.
I disagree here. 'upgrade' is not something about working upward an old
snapshot.
>
> > I also think that we should move from using compare-against-output
> > tests.
>
> This is not about tap vs diff. It is about having all upgrade related
> tests in one place, and organized in one way, with how to fill them, with
> how to store xlogs and snapshots in the repository.
But I still want to test it using TAP13 test. test/xlog is the test
suite that is fed to the console.
>
> > I'll not insist on this during review, but personally I will
> > create new tests using pytest-like (phpunit-like, maven-failsafe-like,
> > luatest-like) way (it is our TAP13 tests or at least near to them). I
> > can summarize cons and pros if you want (don't sure whether I did it
> > already somewhere).
>
> Don't really want to discuss this again, everything was said already
> 1000 times or more.
I'm too.
>
> > We can move 'snap' directory upward (right into test/) and use it for
> > snapshots for all test suites. Or keep them per-suite. However see the
> > next paragraph re fill.lua.
>
> This is a bad idea, because different upgrade-related tests usually
> need some specific data stored in the old snapshot. If you merge data,
> needed by many tests, into one snapshot, you will violate the policy of
> one-bug-one-test. Because many tests will start to depend on each other.
Ouch, okay, fill.lua is called on the old tarantool version (on which
you generate a snapshot). It is okay for my case to disable autoupgrade
and insert the data using the new tarantool version. I guess it is okay
too for most of cases. Your case with upgrade of a sequence can be
tested this way too.
Inserting necessary data right from a test seems to be more sane
approach: you don't need to jump over several files to look at the test
case at whole: its data and code.
This way also splits snapshot from test data. The snapshot contains just
what appears after box.cfg() + box.snapshot() on an old tarantool
version. No surprises.
>
> > I prefer to feed initial schema and data right from a test to keep them
> > near to actual usage in test cases (within one file).
>
> This makes impossible to test bugs, which appear only when you bootstrap
> from the old snapshot.
Any example? Your case with a sequence upgrade can be tested with
inserting data using the new tarantool version.
We just need to start tarantool of the new version on the old snapshot
in the read-only mode to disable autoupgrading, enable read-write,
insert necessary data. Then we can either test the instance on the old
schema or call upgrade and test it after upgrade.
>
> > Sometimes it eases
> > reading of test cases, especially when you're not much familiar with a
> > testing system.
>
> You are now creating a second way of testing upgrade. This is definitely
> not a simplification of the testing system.
Nope. Again, I don't test upgrade here.
But, yep, I want to enforce several properties and so I'm unable to use
the way you proposed to run tarantool on an old schema:
* A test is the script with TAP13 output, so it should be inside
a corresponding test suite.
* A test inserts all needed data right from the test file. The instance
file just calls box.cfg() and give guest user accesses. It is highly
reusable so.
>
> > I don't much like the approach with fill.lua script (at
> > least for data corresponds to test cases).
>
> fill.lua is inevitable, when you need to test bootstrap from an old
> snapshot having some data in it before you start tarantool, and you want
> to know what data is stored here exactly.
I would call for examples.
But anyway, we can keep both ways and use fill.lua when it is not
possible to feed initial data for a test using the new tarantool
version.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Tarantool-patches] [PATCH] net.box: fix fetching of schema of an old version
2020-04-05 12:05 ` Alexander Turenko
@ 2020-04-05 16:41 ` Vladislav Shpilevoy
2020-04-06 11:39 ` Alexander Turenko
0 siblings, 1 reply; 14+ messages in thread
From: Vladislav Shpilevoy @ 2020-04-05 16:41 UTC (permalink / raw)
To: Alexander Turenko; +Cc: tarantool-patches
On 05/04/2020 14:05, Alexander Turenko wrote:
> On Sat, Apr 04, 2020 at 07:40:44PM +0200, Vladislav Shpilevoy wrote:
>>>>> https://github.com/tarantool/tarantool/issues/4691
>>>>> https://github.com/tarantool/tarantool/tree/Totktonada/gh-4691-net-box-connect-schema-2-1-3
>>>>>
>>>>> src/box/lua/net_box.lua | 9 ++
>>>>> ...4691-net-box-connect-schema-2-1-3.test.lua | 93 ++++++++++++++++++
>>>>> test/box-tap/no_auto_schema_upgrade.lua | 30 ++++++
>>>>> .../snap/2.1.3/00000000000000000000.snap | Bin 0 -> 4466 bytes
>>>>> 4 files changed, 132 insertions(+)
>>>>> create mode 100755 test/box-tap/gh-4691-net-box-connect-schema-2-1-3.test.lua
>>>>
>>>> We have xlog/upgrade suite specifically for these tests. With
>>>> already designed processes, where and how to store old snaps, etc.
>>>> See xlog/upgrade/how_to_add_new_test.md.
>>>
>>>
>>> I want to test the case when an instance is NOT upgraded. So 'upgrade'
>>> directory name for snaps would be misleading.
>>
>> The test and the bug are still upgrade related. 'xlog/upgrade' is not
>> called 'xlog/upgrade_called'. It is called just 'upgrade'. For all cases
>> when an old snapshot is used to start a new tarantool.
>
> I disagree here. 'upgrade' is not something about working upward an old
> snapshot.
It is. Because you won't work on the old snapshot forever. You are
going to upgrade anyway. Your bug is for when upgrade is started but
not finished. Because Tarantools are new, but upgrade() is not called
yet.
>>> I also think that we should move from using compare-against-output
>>> tests.
>>
>> This is not about tap vs diff. It is about having all upgrade related
>> tests in one place, and organized in one way, with how to fill them, with
>> how to store xlogs and snapshots in the repository.
>
> But I still want to test it using TAP13 test. test/xlog is the test
> suite that is fed to the console.
Well, I also want many things different, but also I don't want to break
what works, and I want to be consistent. Currently this patch basically
proposes to throw away the just started to work xlog/upgrade suite, which
was disabled for a long time. And it makes upgrade tests inconsistent.
>>> We can move 'snap' directory upward (right into test/) and use it for
>>> snapshots for all test suites. Or keep them per-suite. However see the
>>> next paragraph re fill.lua.
>>
>> This is a bad idea, because different upgrade-related tests usually
>> need some specific data stored in the old snapshot. If you merge data,
>> needed by many tests, into one snapshot, you will violate the policy of
>> one-bug-one-test. Because many tests will start to depend on each other.
>
> Ouch, okay, fill.lua is called on the old tarantool version (on which
> you generate a snapshot). It is okay for my case to disable autoupgrade
> and insert the data using the new tarantool version. I guess it is okay
> too for most of cases. Your case with upgrade of a sequence can be
> tested this way too.
No, it can't. Unless you tried and actually managed to reproduce this.
Because I just tried your way. I made checkout to 2.1, took an empty
snapshot (00000000000000000000.snap). Took 2.2 before the sequence fix
(that commit: 13de917a0e3b8affb693d041663c174d9ec7fcc9). Then I started
Tarantool in read-only mode:
box.cfg{read_only = true}
Then I check the upgrade is not called:
tarantool> box.space._schema:select{}
---
- - ['cluster', '9990ec84-1f65-4452-aa39-3c06c1aac709']
- ['max_id', 511]
- ['version', 2, 1, 3]
...
tarantool> _TARANTOOL
---
- 2.2.2-40-g13de917a0
...
Then I made it read_only false to be able to create a sequence:
tarantool> box.cfg{read_only = false}
2020-04-05 18:14:27.256 [23941] main/102/interactive I> set 'read_only' configuration option to false
---
...
Then I created a space with sequence, like described in the ticket:
https://github.com/tarantool/tarantool/issues/4771
tarantool> box.schema.create_space('s')
---
- engine: memtx
... -- snipped
- created
...
tarantool> box.space.s:create_index('pk', {parts = {{1, 'integer'}}, sequence = true})
---
- parts:
... -- snipped
name: pk
...
Then I called upgrade:
tarantool> box.schema.upgrade()
2020-04-05 18:15:54.580 [23941] main/102/interactive I> add sequence field to space _space_sequence
2020-04-05 18:15:54.581 [23941] main/102/interactive I> create space _ck_constraint
2020-04-05 18:15:54.581 [23941] main/102/interactive I> create index primary on _ck_constraint
2020-04-05 18:15:54.582 [23941] main/102/interactive I> create view _vcollation...
2020-04-05 18:15:54.583 [23941] main/102/interactive I> create index primary on _vcollation
2020-04-05 18:15:54.583 [23941] main/102/interactive I> create index name on _vcollation
2020-04-05 18:15:54.583 [23941] main/102/interactive I> grant read access to 'public' role for _vcollation view
2020-04-05 18:15:54.584 [23941] main/102/interactive I> Update _func format
2020-04-05 18:15:54.602 [23941] main/102/interactive I> Create _func_index space
2020-04-05 18:15:54.603 [23941] main/102/interactive I> set schema version to 2.2.1
---
...
So even though in your particular case it is ok, it is very
artificial, and can't be applied to all tests.
> Inserting necessary data right from a test seems to be more sane
> approach: you don't need to jump over several files to look at the test
> case at whole: its data and code.
It may look simpler (even though for me, honestly, the test in the
patch does not look simple). But it does not mean anything it is right.
As I said, I consider that test too artificial.
> This way also splits snapshot from test data. The snapshot contains just
> what appears after box.cfg() + box.snapshot() on an old tarantool
> version. No surprises.
For having test data we use fill.lua. I don't see any surprises here.
What you put into fill.lua, you will see after bootstrap.
>>> I prefer to feed initial schema and data right from a test to keep them
>>> near to actual usage in test cases (within one file).
>>
>> This makes impossible to test bugs, which appear only when you bootstrap
>> from the old snapshot.
>
> Any example? Your case with a sequence upgrade can be tested with
> inserting data using the new tarantool version.
As I already showed above, it can't. At least without manual change
of _sequence/_space_sequence/_sequence_data (but this I didn't check),
which would make the test artificial, not real.
So if you want examples, first is this:
https://github.com/tarantool/tarantool/issues/4771
Second is this:
https://github.com/tarantool/tarantool/issues/2950
The problem was that space formats started being validated, and you
couldn't insert bad data even if you didn't call upgrade yet. Because
alter.cc already parsed existing formats, and turned on format validation.
Idea is to insert bad data on the old version, and bootstrap a new
version on that. From what I remember, fix was to add a check in
alter.cc that wouldn't turn on validation in case you have an old record
in _schema.
> We just need to start tarantool of the new version on the old snapshot
> in the read-only mode to disable autoupgrading, enable read-write,
> insert necessary data. Then we can either test the instance on the old
> schema or call upgrade and test it after upgrade.
This does not work, in case your 'necessary data' will be inserted
or validated differently due to alter.cc or any other internal changes.
>>> Sometimes it eases
>>> reading of test cases, especially when you're not much familiar with a
>>> testing system.
>>
>> You are now creating a second way of testing upgrade. This is definitely
>> not a simplification of the testing system.
>
> Nope. Again, I don't test upgrade here.
>
> But, yep, I want to enforce several properties and so I'm unable to use
> the way you proposed to run tarantool on an old schema:
>
> * A test is the script with TAP13 output, so it should be inside
> a corresponding test suite.
Tap or diff has nothing to do with that. It is not a blocker.
> * A test inserts all needed data right from the test file. The instance
> file just calls box.cfg() and give guest user accesses. It is highly
> reusable so.
This is also not a blocker to write a test on this issue.
On the summary, all 'blockers' are subjective, and don't really
block anything. It is the same as I would refuse to patch luajit code,
because I personally prefer Tarantool's code style.
>>> I don't much like the approach with fill.lua script (at
>>> least for data corresponds to test cases).
>>
>> fill.lua is inevitable, when you need to test bootstrap from an old
>> snapshot having some data in it before you start tarantool, and you want
>> to know what data is stored here exactly.
>
> I would call for examples.
See two examples above.
> But anyway, we can keep both ways and use fill.lua when it is not
> possible to feed initial data for a test using the new tarantool
> version.
Okey, you can omit fill.lua, but I want upgrade-related tests in
one place. Or organized in one way in maximum two places, if you are
so desperate to use tap.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Tarantool-patches] [PATCH] net.box: fix fetching of schema of an old version
2020-04-05 16:41 ` Vladislav Shpilevoy
@ 2020-04-06 11:39 ` Alexander Turenko
2020-04-09 21:30 ` Vladislav Shpilevoy
2020-04-19 16:22 ` Alexander Turenko
0 siblings, 2 replies; 14+ messages in thread
From: Alexander Turenko @ 2020-04-06 11:39 UTC (permalink / raw)
To: Vladislav Shpilevoy; +Cc: tarantool-patches
> >> The test and the bug are still upgrade related. 'xlog/upgrade' is not
> >> called 'xlog/upgrade_called'. It is called just 'upgrade'. For all cases
> >> when an old snapshot is used to start a new tarantool.
> >
> > I disagree here. 'upgrade' is not something about working upward an old
> > snapshot.
>
> It is. Because you won't work on the old snapshot forever. You are
> going to upgrade anyway. Your bug is for when upgrade is started but
> not finished. Because Tarantools are new, but upgrade() is not called
> yet.
It is like "sooner or later a user will use feature X after Y, so let's
call Y as X". I understood your point, but still think that the name
'upgrade' is misleading. More general 'snap' or 'snapshots' looks better
for me.
In fact upgrade may break old connectors (say, due to unicode_ci
collation of _func on 2.2) and I guess the old schema may be kept for
quite long time so.
> > Ouch, okay, fill.lua is called on the old tarantool version (on which
> > you generate a snapshot). It is okay for my case to disable autoupgrade
> > and insert the data using the new tarantool version. I guess it is okay
> > too for most of cases. Your case with upgrade of a sequence can be
> > tested this way too.
>
> No, it can't. Unless you tried and actually managed to reproduce this.
> Because I just tried your way. I made checkout to 2.1, took an empty
> snapshot (00000000000000000000.snap). Took 2.2 before the sequence fix
> (that commit: 13de917a0e3b8affb693d041663c174d9ec7fcc9). Then I started
> Tarantool in read-only mode:
>
> <...snipped steps to reproduce...>
>
> So even though in your particular case it is ok, it is very
> artificial, and can't be applied to all tests.
You're right. I missed that we'll unable to reproduce the problem if
we'll call fixed upgrade script (from a new tarantool version).
> Okey, you can omit fill.lua, but I want upgrade-related tests in
> one place. Or organized in one way in maximum two places, if you are
> so desperate to use tap.
I'll rework the patch to keep snapshots together. Don't sure about
feeding initial data in my case (from fill.lua or from a test): I'll
took a time to think around.
It seems logical to move snapshots out from test suites, since they will
be used across the test suites. What do you think?
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Tarantool-patches] [PATCH] net.box: fix fetching of schema of an old version
2020-04-06 11:39 ` Alexander Turenko
@ 2020-04-09 21:30 ` Vladislav Shpilevoy
2020-04-19 16:23 ` Alexander Turenko
2020-04-19 16:22 ` Alexander Turenko
1 sibling, 1 reply; 14+ messages in thread
From: Vladislav Shpilevoy @ 2020-04-09 21:30 UTC (permalink / raw)
To: Alexander Turenko; +Cc: tarantool-patches
>>> Ouch, okay, fill.lua is called on the old tarantool version (on which
>>> you generate a snapshot). It is okay for my case to disable autoupgrade
>>> and insert the data using the new tarantool version. I guess it is okay
>>> too for most of cases. Your case with upgrade of a sequence can be
>>> tested this way too.
>>
>> No, it can't. Unless you tried and actually managed to reproduce this.
>> Because I just tried your way. I made checkout to 2.1, took an empty
>> snapshot (00000000000000000000.snap). Took 2.2 before the sequence fix
>> (that commit: 13de917a0e3b8affb693d041663c174d9ec7fcc9). Then I started
>> Tarantool in read-only mode:
>>
>> <...snipped steps to reproduce...>
>>
>> So even though in your particular case it is ok, it is very
>> artificial, and can't be applied to all tests.
>
> You're right. I missed that we'll unable to reproduce the problem if
> we'll call fixed upgrade script (from a new tarantool version).
>
>> Okey, you can omit fill.lua, but I want upgrade-related tests in
>> one place. Or organized in one way in maximum two places, if you are
>> so desperate to use tap.
>
> I'll rework the patch to keep snapshots together. Don't sure about
> feeding initial data in my case (from fill.lua or from a test): I'll
> took a time to think around.
I am ok with feeding data however you want, suitable for a particular
ticket. But what I consider important is having such tests organized in
one way. With the same folder structure, file naming, isolation.
Although your snapshot is 'pure'. Zero snapshot with no data. Probably
such snapshot could be shared by multiple tests via a symbolic link, if
needed.
> It seems logical to move snapshots out from test suites, since they will
> be used across the test suites. What do you think?
It is not always the case. A snapshot is ok to use across tests only if
it is not related to any particular test more than to others. Only empty
snapshots satisfy that criteria. The reason is that we are obligated to
keep tests isolated from each other. And if you use one non-empty snapshot
for multiple tests, the policy will be violated.
I don't like doing file-per-bug tests, but for snapshots it is fair. Because
otherwise such a snapshot quickly becomes a pile of unmaintainable garbage,
like xlog/upgrade snapshots were beforehand.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Tarantool-patches] [PATCH] net.box: fix fetching of schema of an old version
2020-04-06 11:39 ` Alexander Turenko
2020-04-09 21:30 ` Vladislav Shpilevoy
@ 2020-04-19 16:22 ` Alexander Turenko
2020-04-19 17:02 ` Vladislav Shpilevoy
1 sibling, 1 reply; 14+ messages in thread
From: Alexander Turenko @ 2020-04-19 16:22 UTC (permalink / raw)
To: Vladislav Shpilevoy; +Cc: tarantool-patches
On Mon, Apr 06, 2020 at 02:39:37PM +0300, Alexander Turenko wrote:
> > >> The test and the bug are still upgrade related. 'xlog/upgrade' is not
> > >> called 'xlog/upgrade_called'. It is called just 'upgrade'. For all cases
> > >> when an old snapshot is used to start a new tarantool.
> > >
> > > I disagree here. 'upgrade' is not something about working upward an old
> > > snapshot.
> >
> > It is. Because you won't work on the old snapshot forever. You are
> > going to upgrade anyway. Your bug is for when upgrade is started but
> > not finished. Because Tarantools are new, but upgrade() is not called
> > yet.
>
> It is like "sooner or later a user will use feature X after Y, so let's
> call Y as X". I understood your point, but still think that the name
> 'upgrade' is misleading. More general 'snap' or 'snapshots' looks better
> for me.
>
> In fact upgrade may break old connectors (say, due to unicode_ci
> collation of _func on 2.2) and I guess the old schema may be kept for
> quite long time so.
We should agree on some name for directory(-ies) with snapshots for
testing purposes.
I think that stored snapshots may be used to test various scenarious:
* Start from a snapshot with old schema and data, then call upgrade and
test a scenario.
* Start from a snapshot with old schema and some data, then test a
scenario.
* Start from a snapshot that is broken by a past upgrade (see #4804),
then test a scenario.
* Start from a broken snapshot and test a scenario:
- A snapshot that violates some constraint (and so is hard to be
generated on demand), see #4797.
- A snapshot that has broken metainformation: instance uuid, vclock.
So I would prefer a name that is more general then 'upgrade': 'snap',
'snapshots'.
Aren't this convince you?
WBR, Alexander Turenko.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Tarantool-patches] [PATCH] net.box: fix fetching of schema of an old version
2020-04-09 21:30 ` Vladislav Shpilevoy
@ 2020-04-19 16:23 ` Alexander Turenko
2020-04-19 17:02 ` Vladislav Shpilevoy
0 siblings, 1 reply; 14+ messages in thread
From: Alexander Turenko @ 2020-04-19 16:23 UTC (permalink / raw)
To: Vladislav Shpilevoy; +Cc: tarantool-patches
> > It seems logical to move snapshots out from test suites, since they will
> > be used across the test suites. What do you think?
>
> It is not always the case. A snapshot is ok to use across tests only if
> it is not related to any particular test more than to others. Only empty
> snapshots satisfy that criteria. The reason is that we are obligated to
> keep tests isolated from each other. And if you use one non-empty snapshot
> for multiple tests, the policy will be violated.
(Continued snap/upgrade discussion in the sibling email thread.)
How about this directory structure?
test/
|
+- snap/
|
+- how_to_add_new_test.md
|
+- xlog/
| |
| +- gh-4771-upgrade-sequence/
| |
| +- fill.lua
| +- 2.1.3/
| |
| +- *.snap
|
+- box-tap/
|
+- gh-4691-net-box-connect-schema-2-1-3/
|
+- fill.lua
+- 2.1.3/
|
+- *.snap
Key points:
* All snapshots are in one place: it is easier to keep them right
structured.
* Snapshots are organized on per-test basis.
Alternative:
test/
|
+- xlog/
| |
| +- snap/
| |
| +- how_to_add_new_test.md
| |
| +- gh-4771-upgrade-sequence/
| |
| +- fill.lua
| +- 2.1.3/
| |
| +- *.snap
|
+- box-tap/
|
+- snap/
|
+- how_to_add_new_test.md -> ../../xlog/snap/how_to_add_new_test.md
|
+- gh-4691-net-box-connect-schema-2-1-3/
|
+- fill.lua
+- 2.1.3/
|
+- *.snap
Key points:
* All snapshots organized as same structured subtrees.
* Same as above, snapshots are organized on per-test basis.
WBR, Alexander Turenko.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Tarantool-patches] [PATCH] net.box: fix fetching of schema of an old version
2020-04-19 16:22 ` Alexander Turenko
@ 2020-04-19 17:02 ` Vladislav Shpilevoy
0 siblings, 0 replies; 14+ messages in thread
From: Vladislav Shpilevoy @ 2020-04-19 17:02 UTC (permalink / raw)
To: Alexander Turenko; +Cc: tarantool-patches
On 19/04/2020 18:22, Alexander Turenko wrote:
> On Mon, Apr 06, 2020 at 02:39:37PM +0300, Alexander Turenko wrote:
>>>>> The test and the bug are still upgrade related. 'xlog/upgrade' is not
>>>>> called 'xlog/upgrade_called'. It is called just 'upgrade'. For all cases
>>>>> when an old snapshot is used to start a new tarantool.
>>>>
>>>> I disagree here. 'upgrade' is not something about working upward an old
>>>> snapshot.
>>>
>>> It is. Because you won't work on the old snapshot forever. You are
>>> going to upgrade anyway. Your bug is for when upgrade is started but
>>> not finished. Because Tarantools are new, but upgrade() is not called
>>> yet.
>>
>> It is like "sooner or later a user will use feature X after Y, so let's
>> call Y as X". I understood your point, but still think that the name
>> 'upgrade' is misleading. More general 'snap' or 'snapshots' looks better
>> for me.
>>
>> In fact upgrade may break old connectors (say, due to unicode_ci
>> collation of _func on 2.2) and I guess the old schema may be kept for
>> quite long time so.
>
> We should agree on some name for directory(-ies) with snapshots for
> testing purposes.
>
> I think that stored snapshots may be used to test various scenarious:
>
> * Start from a snapshot with old schema and data, then call upgrade and
> test a scenario.
> * Start from a snapshot with old schema and some data, then test a
> scenario.
> * Start from a snapshot that is broken by a past upgrade (see #4804),
> then test a scenario.
> * Start from a broken snapshot and test a scenario:
> - A snapshot that violates some constraint (and so is hard to be
> generated on demand), see #4797.
> - A snapshot that has broken metainformation: instance uuid, vclock.
>
> So I would prefer a name that is more general then 'upgrade': 'snap',
> 'snapshots'.
>
> Aren't this convince you?
>
> WBR, Alexander Turenko.
Snap looks ok. If it will be used consistently and everywhere.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Tarantool-patches] [PATCH] net.box: fix fetching of schema of an old version
2020-04-19 16:23 ` Alexander Turenko
@ 2020-04-19 17:02 ` Vladislav Shpilevoy
0 siblings, 0 replies; 14+ messages in thread
From: Vladislav Shpilevoy @ 2020-04-19 17:02 UTC (permalink / raw)
To: Alexander Turenko; +Cc: tarantool-patches
On 19/04/2020 18:23, Alexander Turenko wrote:
>>> It seems logical to move snapshots out from test suites, since they will
>>> be used across the test suites. What do you think?
>>
>> It is not always the case. A snapshot is ok to use across tests only if
>> it is not related to any particular test more than to others. Only empty
>> snapshots satisfy that criteria. The reason is that we are obligated to
>> keep tests isolated from each other. And if you use one non-empty snapshot
>> for multiple tests, the policy will be violated.
>
> (Continued snap/upgrade discussion in the sibling email thread.)
>
> How about this directory structure?
>
> test/
> |
> +- snap/
> |
> +- how_to_add_new_test.md
> |
> +- xlog/
> | |
> | +- gh-4771-upgrade-sequence/
> | |
> | +- fill.lua
> | +- 2.1.3/
> | |
> | +- *.snap
> |
> +- box-tap/
> |
> +- gh-4691-net-box-connect-schema-2-1-3/
> |
> +- fill.lua
> +- 2.1.3/
> |
> +- *.snap
>
> Key points:
>
> * All snapshots are in one place: it is easier to keep them right
> structured.
> * Snapshots are organized on per-test basis.
>
> Alternative:
>
> test/
> |
> +- xlog/
> | |
> | +- snap/
> | |
> | +- how_to_add_new_test.md
> | |
> | +- gh-4771-upgrade-sequence/
> | |
> | +- fill.lua
> | +- 2.1.3/
> | |
> | +- *.snap
> |
> +- box-tap/
> |
> +- snap/
> |
> +- how_to_add_new_test.md -> ../../xlog/snap/how_to_add_new_test.md
> |
> +- gh-4691-net-box-connect-schema-2-1-3/
> |
> +- fill.lua
> +- 2.1.3/
> |
> +- *.snap
>
> Key points:
>
> * All snapshots organized as same structured subtrees.
> * Same as above, snapshots are organized on per-test basis.
>
> WBR, Alexander Turenko.
Both options look good to me.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Tarantool-patches] [PATCH] net.box: fix fetching of schema of an old version
2020-04-01 20:45 [Tarantool-patches] [PATCH] net.box: fix fetching of schema of an old version Alexander Turenko
2020-04-02 21:20 ` Alexander Turenko
2020-04-03 22:53 ` Vladislav Shpilevoy
@ 2020-04-20 6:58 ` Alexander Turenko
2 siblings, 0 replies; 14+ messages in thread
From: Alexander Turenko @ 2020-04-20 6:58 UTC (permalink / raw)
To: Vladislav Shpilevoy; +Cc: tarantool-patches
On Wed, Apr 01, 2020 at 11:45:21PM +0300, Alexander Turenko wrote:
> 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.
>
> Follows up #4307
> Fixes #4691
> ---
>
> https://github.com/tarantool/tarantool/issues/4691
> https://github.com/tarantool/tarantool/tree/Totktonada/gh-4691-net-box-connect-schema-2-1-3
Pushed to Totktonada/gh-4691-net-box-connect-schema-2-1-3-no-test
without tests to include into 2.4.1.
CCed Kirill.
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2020-04-20 6:58 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-01 20:45 [Tarantool-patches] [PATCH] net.box: fix fetching of schema of an old version Alexander Turenko
2020-04-02 21:20 ` Alexander Turenko
2020-04-03 22:53 ` Vladislav Shpilevoy
2020-04-03 23:38 ` Alexander Turenko
2020-04-04 17:40 ` Vladislav Shpilevoy
2020-04-05 12:05 ` Alexander Turenko
2020-04-05 16:41 ` Vladislav Shpilevoy
2020-04-06 11:39 ` Alexander Turenko
2020-04-09 21:30 ` Vladislav Shpilevoy
2020-04-19 16:23 ` Alexander Turenko
2020-04-19 17:02 ` Vladislav Shpilevoy
2020-04-19 16:22 ` Alexander Turenko
2020-04-19 17:02 ` Vladislav Shpilevoy
2020-04-20 6:58 ` Alexander Turenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox