Hi! Thanks for the fixes! See comments below.
Running box.cfg{}, I see this:
2018-12-10 13:13:15.077 [6329] main/101/interactive xlog.c:1920 E> can't
open tx: bootstrap: has some data after eof marker at 1903
Looks like an artifact of changing initial snapshot with a
wrong editor, or using a wrong editor mode. In vim, as I
remember, you should use -b option. But I can be mistaken.
Also, this upgrade does not work. I've created a
snapshot with old stat format and 2.1.0 version. Then I
tried to start on this snapshot using your version, but
got
2018-12-10 13:22:07.317 [14183] main/101/interactive F> failed to initialize
SQL subsystem
Process 14183 exited with status = 1 (0x00000001)
On 08/12/2018 16:10, imeevma@xxxxxxxxxxxxx wrote:
Hi! Thank you for review! New version and my answers below.
I resend this letters because didn't add links in the last one.
In addition, it seems that the tabs were replaced with spaces
there.
https://github.com/tarantool/tarantool/issues/3242
https://github.com/tarantool/tarantool/tree/imeevma/gh-3242-hold-ids-in-stat-tables
> commit 5e1eb513b33ee8ab31901e8e0bf8d8f5a9442b9f
Author: Mergen Imeev <imeevma@xxxxxxxxx>
Date: Sun Dec 2 17:57:19 2018 +0300
sql: hold in stat tables space/index id instead of name
To avoid problems with table and index renaming it is good idea
to save ids of tables and indexes instead of their names. Ids of
tables and indexes are fixed values.
Closes #3242
Closes #2962
diff --git a/src/box/bootstrap.snap b/src/box/bootstrap.snap
index d6cc821..22208c6 100644
Binary files a/src/box/bootstrap.snap and b/src/box/bootstrap.snap differ
diff --git a/src/box/lua/upgrade.lua b/src/box/lua/upgrade.lua
index 3d9acc9..2767f9b 100644
--- a/src/box/lua/upgrade.lua
+++ b/src/box/lua/upgrade.lua
@@ -613,6 +613,31 @@ local function upgrade_to_2_1_0()
upgrade_priv_to_2_1_0()
end
+--------------------------------------------------------------------------------
+-- Tarantool 2.1.1
+--------------------------------------------------------------------------------
+
+local function upgrade_sql_stat_to_2_1_1(space_id, parts)
+ local _sql_stat = box.space[space_id]
+
+ local stats = _sql_stat:select()
+ for _, v in pairs(stats) do _sql_stat:delete{v.tbl, v.idx} end
+
+ local format = _sql_stat:format()
+ format[1].name = 'space_id'
+ format[1].type = 'unsigned'
+ format[2].name = 'index_id'
+ format[2].type = 'unsigned'
+ _sql_stat.index.primary:alter{parts={3, 'string'}}
+ _sql_stat:format(format)
+ _sql_stat.index.primary:alter{parts=parts}
+end
diff --git a/src/box/schema.cc b/src/box/schema.cc
index 8625d92..844b6c3 100644
--- a/src/box/schema.cc
+++ b/src/box/schema.cc
@@ -444,21 +444,19 @@ schema_init()
sc_space_new(BOX_INDEX_ID, "_index", key_parts, 2,
&alter_space_on_replace_index, &on_stmt_begin_index);
- /* _sql_stat1 - a simpler statistics on space, seen in SQL. */
- key_parts[0].fieldno = 0; /* space name */
+ /*
+ *_sql_stat1 - a simpler statistics on space, seen in SQL.
+ * The real index is defined in the snapshot.
+ */
+ key_parts[0].fieldno = 2;
key_parts[0].type = FIELD_TYPE_STRING;
- key_parts[1].fieldno = 1; /* index name */
- key_parts[1].type = FIELD_TYPE_STRING;
- sc_space_new(BOX_SQL_STAT1_ID, "_sql_stat1", key_parts, 2, NULL, NULL);
+ sc_space_new(BOX_SQL_STAT1_ID, "_sql_stat1", key_parts, 1, NULL, NULL);
- /* _sql_stat4 - extensive statistics on space, seen in SQL. */
- key_parts[0].fieldno = 0; /* space name */
- key_parts[0].type = FIELD_TYPE_STRING;
- key_parts[1].fieldno = 1; /* index name */
- key_parts[1].type = FIELD_TYPE_STRING;
- key_parts[2].fieldno = 5; /* sample */
- key_parts[2].type = FIELD_TYPE_SCALAR;
- sc_space_new(BOX_SQL_STAT4_ID, "_sql_stat4", key_parts, 3, NULL, NULL);
+ /*
+ * _sql_stat4 - extensive statistics on space, seen in SQL.
+ * The real index is defined in the snapshot.
+ */
+ sc_space_new(BOX_SQL_STAT4_ID, "_sql_stat4", key_parts, 1, NULL, NULL);
/* _fk_сonstraint - foreign keys constraints. */
key_parts[0].fieldno = 0; /* constraint name */