Skip to content

Commit 4c54f66

Browse files
patiencedaursergepetrenkoEvgeniy Osintsev
authored
Update the upgrade instructions (#3080)
* Add note about caveats when upgrading from 1.6 to 1.10 * Update the upgrading instructions * Add instructions on checking status before upgrade * Add instruction on direct upgrade from 1.6 to 2.x * Add explicit box.schema.upgrade description to the reference * Bring indents in accordance with the style guide This PR adapts the following instructions from tarantool/wiki, written by Serge Petrenko: https://github.com/tarantool/tarantool/wiki/Caveats-when-upgrading-from-tarantool-1.6 https://github.com/tarantool/tarantool/wiki/Fix-wrong-order-of-decimals-and-doubles-in-indices Resolves #3042 Resolves #1807 Resolves #836 Co-authored-by: Serge Petrenko <[email protected]> Co-authored-by: Evgeniy Osintsev <[email protected]>
1 parent 7d8eb7d commit 4c54f66

File tree

10 files changed

+385
-130
lines changed

10 files changed

+385
-130
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Versions later that 1.6 have incompatible :ref:`.snap <internals-snapshot>` and
2+
:ref:`.xlog <internals-wal>` file formats: 1.6 files are
3+
supported during upgrade, but you won’t be able to return to 1.6 after running
4+
under 1.10 or 2.x for a while. A few configuration parameters are also renamed.
5+
6+
To perform a **live** upgrade from Tarantool 1.6 to a more recent version,
7+
like :doc:`2.8.4 </release/2.8.4>`, :doc:`2.10.1 </release/2.10.1>` and such,
8+
it is necessary to take an intermediate step by upgrading 1.6 -> **1.10** -> 2.x.
9+
This is the only way to perform the upgrade **without downtime**.
10+
11+
However, a direct upgrade of a replica set from 1.6 to 2.x is also possible, but only
12+
**with downtime**.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
local fiber = require('fiber')
2+
local decimal = require('decimal')
3+
4+
local function isnan(val)
5+
return type(val) == 'number' and val ~= val
6+
end
7+
8+
local function isinf(val)
9+
return val == math.huge or val == -math.huge
10+
end
11+
12+
local function vinyl(id)
13+
return box.space[id].engine == 'vinyl'
14+
end
15+
16+
require_rebuild = {}
17+
local iters = 0
18+
for _, v in box.space._index:pairs({512, 0}, {iterator='GE'}) do
19+
local id = v[1]
20+
iters = iters + 1
21+
if iters % 1000 == 0 then
22+
fiber.yield()
23+
end
24+
if vinyl(id) then
25+
local format = v[6]
26+
local check_fields = {}
27+
for _, fmt in pairs(v[6]) do
28+
if fmt[2] == 'number' or fmt[2] == 'scalar' then
29+
table.insert(check_fields, fmt[1] + 1)
30+
end
31+
end
32+
local have_decimal = {}
33+
local have_nan = {}
34+
if #check_fields > 0 then
35+
for k, tuple in box.space[id]:pairs() do
36+
for _, i in pairs(check_fields) do
37+
iters = iters + 1
38+
if iters % 1000 == 0 then
39+
fiber.yield()
40+
end
41+
have_decimal[i] = have_decimal[i] or
42+
decimal.is_decimal(tuple[i])
43+
have_nan[i] = have_nan[i] or isnan(tuple[i]) or
44+
isinf(tuple[i])
45+
if have_decimal[i] and have_nan[i] then
46+
table.insert(require_rebuild, v)
47+
goto out
48+
end
49+
end
50+
end
51+
end
52+
end
53+
::out::
54+
end
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
local log = require('log')
2+
3+
local function rebuild_index(idx)
4+
local index_name = idx[3]
5+
local space_name = box.space[idx[1]].name
6+
log.info("Rebuilding index %s on space %s", index_name, space_name)
7+
if (idx[2] == 0) then
8+
log.error("Cannot rebuild primary index %s on space %s. Please, "..
9+
"recreate the space manually", index_name, space_name)
10+
return
11+
end
12+
log.info("Deleting index %s on space %s", index_name, space_name)
13+
local v = box.space._index:delete{idx[1], idx[2]}
14+
if v == nil then
15+
log.error("Couldn't find index %s on space %s", index_name, space_name)
16+
return
17+
end
18+
log.info("Done")
19+
log.info("Creating index %s on space %s", index_name, space_name)
20+
box.space._index:insert(v)
21+
end
22+
23+
for _, idx in pairs(require_rebuild) do
24+
rebuild_index(idx)
25+
end
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
1. Pick any read-only instance in the replica set.
2+
3+
2. Upgrade this replica to the new Tarantool version. See details in
4+
:ref:`Upgrading Tarantool on a standalone instance <admin-upgrades_instance>`.
5+
This requires stopping the instance for a while,
6+
which won't interrupt the replica set operation.
7+
When the upgraded replica is up again, it will synchronize with the other instances in the replica set
8+
so that the data are consistent across all the instances.
9+
10+
3. Make sure the upgraded replica is running and connected to the rest of the replica set just fine.
11+
To do this, run ``box.info.replication`` in the instance's console
12+
and check the output table for values like ``upstream``, ``downstream``, and ``lag``.
13+
14+
For each instance ``id``, there are ``upstream`` and ``downstream`` values.
15+
Both of them should have the value ``follow``, except on the instance where you run this code.
16+
This means that the replicas are connected and there are no errors in the data flow.
17+
18+
The value of the ``lag`` field can be less or equal than ``box.cfg.replication_timeout``,
19+
but it can also be moderately larger.
20+
For example, if ``box.cfg.replication_timeout`` is 1 second and the write load on the master is high,
21+
it's generally OK to have a lag of about 10 seconds on the master.
22+
It is up to the user to decide what lag values are fine.
23+
24+
4. :ref:`Upgrade <admin-upgrades_instance>` all the read-only instances by repeating steps 1--3
25+
until only the master keeps running the old Tarantool version.
26+
27+
5. Make one of the updated replicas the new master:
28+
29+
- If the replica set is using asynchronous replication without
30+
:ref:`RAFT-based leader elections <repl_leader_elect>`,
31+
first run ``box.cfg{ read_only = true }`` on the old master
32+
and then run ``box.cfg{ read_only = false }`` on the replica that will be the new master.
33+
34+
- If the replica set is using :ref:`synchronous replication <repl_sync>` or
35+
:ref:`RAFT-based leader elections <repl_leader_elect>`,
36+
run ``box.ctl.promote()`` on the new master and then run
37+
``box.cfg{ election_mode = 'voter' }`` on the old master.
38+
This will automatically change the ``read_only`` statuses on the instances.
39+
40+
- For a Cartridge replica set, it is possible to select the new master in the web UI.
41+
42+
There is no need to restart the new master.
43+
44+
Check that the new master continues following and being followed by all other replicas, similarly to step 3.
45+
46+
6. :ref:`Upgrade <admin-upgrades_instance>` the former master, which is now a read-only instance.

doc/book/admin/upgrades.rst

Lines changed: 76 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -1,152 +1,113 @@
1-
.. _admin-upgrades:
1+
.. _admin-upgrades:
22

3-
================================================================================
43
Upgrades
5-
================================================================================
4+
========
65

76
For information about backwards compatibility,
87
see the :ref:`compatibility guarantees <compatibility_guarantees>` description.
98

10-
.. _admin-upgrades_db:
9+
.. _admin-upgrades_instance:
1110

12-
--------------------------------------------------------------------------------
13-
Upgrading a Tarantool database
14-
--------------------------------------------------------------------------------
11+
Upgrading Tarantool on a standalone instance
12+
--------------------------------------------
1513

16-
If you created a database with an older Tarantool version and have now installed
17-
a newer version, make the request ``box.schema.upgrade()``. This updates
18-
Tarantool system spaces to match the currently installed version of Tarantool.
19-
20-
For example, here is what happens when you run ``box.schema.upgrade()`` with a
21-
database created with Tarantool version 1.6.4 to version 1.7.2 (only a small
22-
part of the output is shown):
23-
24-
.. code-block:: tarantoolsession
25-
26-
tarantool> box.schema.upgrade()
27-
alter index primary on _space set options to {"unique":true}, parts to [[0,"unsigned"]]
28-
alter space _schema set options to {}
29-
create view _vindex...
30-
grant read access to 'public' role for _vindex view
31-
set schema version to 1.7.0
32-
---
33-
...
34-
35-
.. _admin-upgrades_instance:
36-
37-
--------------------------------------------------------------------------------
38-
Upgrading a Tarantool instance
39-
--------------------------------------------------------------------------------
40-
41-
Tarantool is backward compatible between two adjacent versions. For example, you
42-
should have no or little trouble when upgrading from Tarantool 1.6 to 1.7, or
43-
from Tarantool 1.7 to 2.x. Meanwhile Tarantool 2.x may have incompatible changes
44-
when migrating from Tarantool 1.6. to 2.x directly.
45-
46-
.. _admin-upgrades_instance_17_to_20:
47-
48-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
49-
How to upgrade from Tarantool 1.7 to 2.x
50-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
51-
52-
1. Stop the Tarantool server.
53-
54-
2. Make a copy of all data (see an appropriate hot backup procedure in
55-
:ref:`Backups <admin-backups>`) and the package from which the current (old)
56-
version was installed (for rollback purposes).
57-
58-
3. Update the Tarantool server. See installation instructions at Tarantool
59-
`download page <http://tarantool.org/download.html>`_.
14+
This procedure is for upgrading a standalone Tarantool instance in production.
15+
Notice that this will **always imply a downtime**.
16+
To upgrade **without downtime**, you need several Tarantool servers running in a
17+
replication cluster (see :ref:`below <admin-upgrades_replication_cluster>`).
6018

61-
4. Launch the updated Tarantool server using ``tarantoolctl`` or ``systemctl``.
19+
#. Stop the Tarantool server.
6220

63-
.. _admin-upgrades_instance_16_to_20:
21+
#. Make a copy of all data (see an appropriate hot backup procedure in
22+
:ref:`Backups <admin-backups>`) and the package from which the current (old)
23+
version was installed (for rollback purposes).
6424

65-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
66-
How to upgrade from Tarantool 1.6 to 2.x
67-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
25+
#. Update the Tarantool server. See installation instructions at Tarantool
26+
`download page <http://tarantool.org/download.html>`_.
6827

69-
The procedure is fully analogous to
70-
:ref:`upgrading from 1.7 to 2.x <admin-upgrades_instance_17_to_20>`.
28+
#. Run :ref:`box.schema.upgrade() <box_schema-upgrade>` on the new master.
29+
This will update the Tarantool system spaces to match the currently installed version of Tarantool.
30+
There is no need to run ``box.schema.upgrade()`` on every node:
31+
changes are propagated to other nodes via the regular replication mechanism.
7132

72-
.. _admin-upgrades_instance_16_to_17:
33+
#. Update your application files, if needed.
7334

74-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
75-
How to upgrade from Tarantool 1.6 to 1.7
76-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
35+
#. Launch the updated Tarantool server using ``tarantoolctl``, ``tt``, or ``systemctl``.
7736

78-
This procedure is for upgrading a standalone Tarantool instance in production
79-
from 1.6.x to 1.7.x. Notice that this will **always imply a downtime**.
80-
To upgrade **without downtime**, you need several Tarantool servers running in a
81-
replication cluster (see :ref:`below <admin-upgrades_replication_cluster>`).
37+
.. _admin-upgrades_replication_cluster:
8238

83-
Tarantool 1.7 has an incompatible :ref:`.snap <internals-snapshot>` and
84-
:ref:`.xlog <internals-wal>` file format: 1.6 files are
85-
supported during upgrade, but you won’t be able to return to 1.6 after running
86-
under 1.7 for a while. It also renames a few configuration parameters, but old
87-
parameters are supported. The full list of breaking changes is available in
88-
`release notes for Tarantool 1.7 <https://github.com/tarantool/tarantool/releases>`_.
39+
Upgrading Tarantool in a replica set with no downtime
40+
-----------------------------------------------------
8941

90-
1. Check with application developers whether application files need to be
91-
updated due to incompatible changes (see
92-
`1.7 release notes <https://github.com/tarantool/tarantool/releases>`_).
93-
If yes, back up the old application files.
42+
Below are the general instructions for upgrading Tarantool in a replica set.
43+
Upgrading from some versions can involve certain specifics. You can find
44+
instructions for individual versions :ref:`in the list below <admin-upgrades_version_specifics>`.
9445

95-
2. Stop the Tarantool server.
46+
.. important::
9647

97-
3. Make a copy of all data (see an appropriate hot backup procedure in
98-
:ref:`Backups <admin-backups>`) and the package from which the current (old)
99-
version was installed (for rollback purposes).
48+
The only way to upgrade Tarantool from version 1.6, 1.7, or 1.9 to 2.x **without downtime** is
49+
taking an intermediate step by upgrading to 1.10 and then to 2.x.
10050

101-
4. Update the Tarantool server. See installation instructions at Tarantool
102-
`download page <http://tarantool.org/download.html>`_.
51+
Before upgrading Tarantool from 1.6 to 2.x, please read about the associated
52+
:ref:`caveats <admin-upgrades-1.6-1.10>`.
10353

104-
5. Update the Tarantool database. Put the request ``box.schema.upgrade()``
105-
inside a :doc:`box.once() </reference/reference_lua/box_once>` function in your Tarantool
106-
:ref:`initialization file <index-init_label>`.
107-
On startup, this will create new system spaces, update data type names (e.g.
108-
num -> unsigned, str -> string) and options in Tarantool system spaces.
54+
Preparations
55+
~~~~~~~~~~~~
10956

110-
6. Update application files, if needed.
57+
#. Check the replica set health by running the following code on every instance:
11158

112-
7. Launch the updated Tarantool server using ``tarantoolctl`` or ``systemctl``.
59+
.. code-block:: tarantoolsession
11360
114-
.. _admin-upgrades_replication_cluster:
61+
box.info.ro -- "false" at least on one instance
62+
box.info.status -- should be "running"
63+
64+
If all instances have ``box.info.ro = true``, this means there are no writable nodes.
65+
If you're running Tarantool :doc:`v. 2.10.0 </release/2.10.0>` or later,
66+
you can find out the reason by running ``box.info.ro_reason``.
67+
If it has the value ``orphan``, the instance doesn't see the rest of the replica set.
68+
Similarly, if ``box.info.status`` has the value ``orphan``, the instance doesn't see the rest of the replica set.
69+
First resolve the replication issues and only then continue.
11570

116-
--------------------------------------------------------------------------------
117-
Upgrading Tarantool in a replication cluster
118-
--------------------------------------------------------------------------------
71+
If you're running Cartridge, you can also check node health in the UI.
11972

120-
Tarantool 1.7 can work as a :ref:`replica <replication-architecture>`
121-
for Tarantool 1.6 and vice versa. Replicas
122-
perform capability negotiation on handshake, and new 1.7 replication features
123-
are not used with 1.6 replicas. This allows upgrading clustered configurations.
73+
#. Make sure each replica is connected to the rest of the replica set.
74+
To do this, run ``box.info.replication`` in the instance's console
75+
and check the output table for values like ``upstream``, ``downstream``, and ``lag``.
12476

125-
This procedure allows for a rolling upgrade **without downtime** and works for
126-
any cluster configuration: master-master or master-replica.
77+
For each instance ``id``, there are ``upstream`` and ``downstream`` values.
78+
Both of them should have the value ``follow``, except on the instance where you run this code.
79+
This means that the replicas are connected and there are no errors in the data flow.
12780

128-
1. Upgrade Tarantool at all replicas (or at any master in a master-master
129-
cluster). See details in
130-
:ref:`Upgrading a Tarantool instance <admin-upgrades_instance>`.
81+
The value of the ``lag`` field can be less or equal than ``box.cfg.replication_timeout``,
82+
but it can also be moderately larger.
83+
For example, if ``box.cfg.replication_timeout`` is 1 second and the write load on the master is high,
84+
it's generally OK to have a lag of about 10 seconds on the master.
85+
It is up to the user to decide what lag values are fine.
86+
87+
If the replica set is healthy, proceed to the upgrade.
13188

132-
2. Verify installation on the replicas:
89+
Upgrade procedure
90+
~~~~~~~~~~~~~~~~~
13391

134-
a. Start Tarantool.
92+
.. include:: ./_includes/upgrade_procedure.rst
13593

136-
b. Attach to the master and start working as before.
94+
7. Run :ref:`box.schema.upgrade() <box_schema-upgrade>` on the new master.
95+
This will update the Tarantool system spaces to match the currently installed version of Tarantool.
96+
There is no need to run ``box.schema.upgrade()`` on every node:
97+
changes are propagated to other nodes via the regular replication mechanism.
13798

138-
The master runs the old Tarantool version, which is always compatible with
139-
the next major version.
99+
8. Run ``box.snapshot()`` on every node in the replica set
100+
to make sure that the replicas immediately see the upgraded database state in case of restart.
140101

141-
3. Upgrade the master. The procedure is similar to upgrading a replica.
142102

143-
4. Verify master installation:
103+
.. _admin-upgrades_version_specifics:
144104

145-
a. Start Tarantool with replica configuration to catch up.
105+
Version specifics
106+
-----------------
146107

147-
b. Switch to master mode.
108+
.. toctree::
109+
:maxdepth: 1
148110

149-
5. Upgrade the database on any master node in the cluster. Make the request
150-
``box.schema.upgrade()``. This updates Tarantool system spaces to match the
151-
currently installed version of Tarantool. Changes are propagated to other
152-
nodes via the regular replication mechanism.
111+
upgrades/1.6-1.10
112+
upgrades/1.6-2.0-downtime
113+
upgrades/2.10.1

0 commit comments

Comments
 (0)