Commit Diff


commit - 292164eddb666591c7b5a4fd62f7f58277ec0674
commit + a5d7f34294cb80b14090e6004b8077630f554e23
blob - 801f973048b0b394b86d83504ab0fe3d180aa939
blob + 666312708ca9b08adc3dc22e3a1688da4d004edc
--- src/box/schema.cc
+++ src/box/schema.cc
@@ -36,6 +36,7 @@
 #include "user.h"
 #include "vclock/vclock.h"
 #include "fiber.h"
+#include "session.h"
 #include "memtx_tx.h"
 #include "txn.h"
 #include "engine.h"
@@ -167,11 +168,14 @@ on_replace_dd_system_space(struct trigger *trigger, vo
 	 * so we only allow it
 	 *  - in the fiber that is currently running a schema upgrade because
 	 *    a schema upgrade implies DDL;
+	 *  - in the applier fiber so that it can replicate changes done by
+	 *    a schema upgrade on the master;
 	 *  - during recovery so that DDL records written to the WAL can be
 	 *    replayed.
 	 */
 	if (recovery_state == FINISHED_RECOVERY &&
 	    fiber() != schema_upgrade_fiber &&
+	    current_session()->type != SESSION_TYPE_APPLIER &&
 	    box_schema_needs_upgrade())
 		return -1;
 	memtx_tx_acquire_ddl(txn);
blob - /dev/null
blob + 5783c416b29526d992261482b67d96899066480c (mode 644)
--- /dev/null
+++ test/replication-luatest/gh_9048_schema_upgrade_test.lua
@@ -0,0 +1,45 @@
+local server = require('luatest.server')
+local t = require('luatest')
+
+local g = t.group()
+
+g.before_test('test_schema_upgrade', function(cg)
+    cg.master = server:new({
+        alias = 'master',
+        datadir = 'test/replication-luatest/upgrade/2.11.1/master',
+    })
+    cg.replica = server:new({
+        alias = 'replica',
+        datadir = 'test/replication-luatest/upgrade/2.11.1/replica',
+        box_cfg = {
+            read_only = true,
+            replication = cg.master.net_box_uri,
+        },
+    })
+    cg.master:start()
+    cg.replica:start()
+end)
+
+g.test_schema_upgrade = function(cg)
+    cg.replica:exec(function()
+        t.assert_equals(box.space._schema:get('version'), {'version', 2, 11, 1})
+        t.assert(box.internal.schema_needs_upgrade())
+    end)
+    local version = cg.master:exec(function()
+        t.assert_equals(box.space._schema:get('version'), {'version', 2, 11, 1})
+        t.assert(box.internal.schema_needs_upgrade())
+        box.schema.upgrade()
+        t.assert_not(box.internal.schema_needs_upgrade())
+        return box.space._schema:get('version')
+    end)
+    cg.replica:wait_for_vclock_of(cg.master)
+    cg.replica:exec(function(version)
+        t.assert_not(box.internal.schema_needs_upgrade())
+        t.assert_equals(box.space._schema:get('version'), version)
+    end, {version})
+end
+
+g.after_test('test_schema_upgrade', function(cg)
+    cg.replica:drop()
+    cg.master:drop()
+end)
blob - /dev/null
blob + f31045d1097a4e0bb74c7e997a4f5993d317c4bc (mode 644)
--- /dev/null
+++ test/replication-luatest/upgrade/2.11.1/gen.lua
@@ -0,0 +1,27 @@
+local fio = require('fio')
+local popen = require('popen')
+
+local TARANTOOL_PATH = fio.abspath(arg[-1])
+local SCRIPT_PATH = fio.abspath(arg[0])
+local WORK_DIR = fio.dirname(SCRIPT_PATH)
+
+if not arg[1] then
+    -- master
+    box.cfg{
+        work_dir = fio.pathjoin(WORK_DIR, 'master'),
+        checkpoint_count = 1,
+        listen = '/tmp/tt.sock',
+    }
+    box.schema.user.grant('guest', 'super')
+
+    popen.new({TARANTOOL_PATH, SCRIPT_PATH, 'replica'}):wait()
+    box.snapshot()
+    os.exit(0)
+else
+    -- replica
+    box.cfg{
+        work_dir = fio.pathjoin(WORK_DIR, 'replica'),
+        replication = '/tmp/tt.sock',
+    }
+    os.exit(0)
+end
blob - /dev/null
blob + 80002517b43ebc42bc6fe813efbf546b96a2a188 (mode 644)
Binary files /dev/null and test/replication-luatest/upgrade/2.11.1/master/00000000000000000002.snap differ
blob - /dev/null
blob + 0030cd99c2a92c7610f53b7b3ab3cf76e97efef6 (mode 644)
--- /dev/null
+++ test/replication-luatest/upgrade/2.11.1/master/00000000000000000002.xlog
@@ -0,0 +1,7 @@
+XLOG
+0.13
+Version: 2.11.1-0-g96877bd353af
+Instance: 15f9e46f-16f8-4423-a7c9-5952402227ee
+VClock: {1: 2}
+
+Õ­í
\ No newline at end of file
blob - /dev/null
blob + aacd6f04def83b43d0e1cd4573c298d46216e3a6 (mode 644)
Binary files /dev/null and test/replication-luatest/upgrade/2.11.1/replica/00000000000000000002.snap differ
blob - /dev/null
blob + c482ef9b9509b4c759f80b0fc52315b096314f7d (mode 644)
--- /dev/null
+++ test/replication-luatest/upgrade/2.11.1/replica/00000000000000000002.xlog
@@ -0,0 +1,7 @@
+XLOG
+0.13
+Version: 2.11.1-0-g96877bd353af
+Instance: 82acbbe0-eac0-4ec5-a6b2-0c68c8989c02
+VClock: {1: 2}
+
+Õ­í
\ No newline at end of file