Ниже представлен пример в рамках курса: Manticore Search - Main+delta schema
Собираем main:
root@maindelta-6f4db574f-2cq47:/# sudo -u manticore indexer main
Manticore 6.0.4 1a3a4ea82@230314
Copyright (c) 2001-2016, Andrew Aksyonoff
Copyright (c) 2008-2016, Sphinx Technologies Inc (http://sphinxsearch.com)
Copyright (c) 2017-2023, Manticore Software LTD (https://manticoresearch.com)
using config file '/etc/manticoresearch/manticore.conf'...
WARNING: key 'read_timeout' is deprecated in /etc/manticoresearch/manticore.conf line 45; use 'network_timeout' instead.
WARNING: key 'max_children' was permanently removed from configuration. Refer to documentation for details.
WARNING: key 'preopen_indexes' is deprecated in /etc/manticoresearch/manticore.conf line 48; use 'preopen_tables' instead.
WARNING: key 'workers' is deprecated in /etc/manticoresearch/manticore.conf line 50; use 'default value' instead.
indexing table 'main'...
collected 9 docs, 0.0 MB
creating lookup: 0.0 Kdocs, 100.0% done
sorted 0.0 Mhits, 100.0% done
total 9 docs, 117 bytes
total 176.703 sec, 0 bytes/sec, 0.05 docs/sec
total 3 reads, 0.000 sec, 0.1 kb/call avg, 0.0 msec/call avg
total 17 writes, 0.000 sec, 0.1 kb/call avg, 0.0 msec/call avg
Выполняем ротацию и проверяем main:
root@maindelta-6f4db574f-2cq47:/# mysql -P9306 -h0
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 6.0.4 1a3a4ea82@230314 git branch HEAD (no branch)
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> RELOAD TABLES;
Query OK, 0 rows affected (0.00 sec)
mysql> SELECT * FROM main;
+------+----------------+------------+
| id | title | updated |
+------+----------------+------------+
| 1 | Document One | 1719397970 |
| 2 | Document Two | 1719397970 |
| 3 | Document Three | 1719397970 |
| 4 | Document Four | 1719397970 |
| 5 | Document Five | 1719397970 |
| 6 | Document Six | 1719397970 |
| 7 | Document Seven | 1719397970 |
| 8 | Document Eight | 1719397970 |
| 9 | Document Nine | 1719397970 |
+------+----------------+------------+
9 rows in set (0.00 sec)
Далее вносим правки в Источнике:
root@maindelta-6f4db574f-2cq47:/# mysql test -u user --password=pass123
mysql: [Warning] Using a password on the command line interface can be insecure.
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.40 MySQL Community Server (GPL)
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> INSERT INTO documents VALUES(10,'Document Ten',NOW(),0);
Query OK, 1 row affected (0.00 sec)
mysql> UPDATE documents SET title='Altered document Six' WHERE id=6;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> UPDATE documents SET deleted=1 WHERE id=5;exit;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
Собираем, выполняем ротацию и проверяем delta:
root@maindelta-6f4db574f-2cq47:/# sudo -u manticore indexer delta
Manticore 6.0.4 1a3a4ea82@230314
Copyright (c) 2001-2016, Andrew Aksyonoff
Copyright (c) 2008-2016, Sphinx Technologies Inc (http://sphinxsearch.com)
Copyright (c) 2017-2023, Manticore Software LTD (https://manticoresearch.com)
using config file '/etc/manticoresearch/manticore.conf'...
WARNING: key 'read_timeout' is deprecated in /etc/manticoresearch/manticore.conf line 45; use 'network_timeout' instead.
WARNING: key 'max_children' was permanently removed from configuration. Refer to documentation for details.
WARNING: key 'preopen_indexes' is deprecated in /etc/manticoresearch/manticore.conf line 48; use 'preopen_tables' instead.
WARNING: key 'workers' is deprecated in /etc/manticoresearch/manticore.conf line 50; use 'default value' instead.
indexing table 'delta'...
collected 2 docs, 0.0 MB
creating lookup: 0.0 Kdocs, 100.0% done
sorted 0.0 Mhits, 100.0% done
total 2 docs, 32 bytes
total 1.702 sec, 18 bytes/sec, 1.17 docs/sec
total 3 reads, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
total 18 writes, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
root@maindelta-6f4db574f-2cq47:/# mysql -P9306 -h0
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 6.0.4 1a3a4ea82@230314 git branch HEAD (no branch)
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> RELOAD TABLES;
Query OK, 0 rows affected (0.00 sec)
mysql> SELECT * FROM delta;
+------+----------------------+------------+
| id | title | updated |
+------+----------------------+------------+
| 6 | Altered document Six | 1752045845 |
| 10 | Document Ten | 1752045844 |
+------+----------------------+------------+
2 rows in set (0.00 sec)
Проверяем main:
mysql> SELECT * FROM main;
+------+----------------+------------+
| id | title | updated |
+------+----------------+------------+
| 1 | Document One | 1719397970 |
| 2 | Document Two | 1719397970 |
| 3 | Document Three | 1719397970 |
| 4 | Document Four | 1719397970 |
| 7 | Document Seven | 1719397970 |
| 8 | Document Eight | 1719397970 |
| 9 | Document Nine | 1719397970 |
+------+----------------+------------+
7 rows in set (0.00 sec)
И смотрим в распределенной таблице общий результат:
mysql> SELECT * FROM mytable;
+------+----------------------+------------+
| id | title | updated |
+------+----------------------+------------+
| 6 | Altered document Six | 1752045845 |
| 1 | Document One | 1719397970 |
| 2 | Document Two | 1719397970 |
| 10 | Document Ten | 1752045844 |
| 3 | Document Three | 1719397970 |
| 4 | Document Four | 1719397970 |
| 7 | Document Seven | 1719397970 |
| 8 | Document Eight | 1719397970 |
| 9 | Document Nine | 1719397970 |
+------+----------------------+------------+
9 rows in set (0.00 sec)
Внесем правки в Источнике:
root@maindelta-6f4db574f-2cq47:/# mysql test -u user --password=pass123
mysql: [Warning] Using a password on the command line interface can be insecure.
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.7.40 MySQL Community Server (GPL)
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> INSERT INTO documents VALUES(11,'Document Ten',NOW(),0);
Query OK, 1 row affected (0.02 sec)
mysql> INSERT INTO documents VALUES(12,'Document Ten',NOW(),0);
Query OK, 1 row affected (0.00 sec)
mysql> UPDATE documents SET title='Altered documentssssx' WHERE id=7;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> UPDATE documents SET title='Altered dRRRR' WHERE id=3;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> UPDATE documents SET deleted=1 WHERE id=1;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
Соберем и выполним ротацию main:
root@maindelta-6f4db574f-2cq47:/# sudo -u manticore indexer main --rotate
Manticore 6.0.4 1a3a4ea82@230314
Copyright (c) 2001-2016, Andrew Aksyonoff
Copyright (c) 2008-2016, Sphinx Technologies Inc (http://sphinxsearch.com)
Copyright (c) 2017-2023, Manticore Software LTD (https://manticoresearch.com)
using config file '/etc/manticoresearch/manticore.conf'...
WARNING: key 'read_timeout' is deprecated in /etc/manticoresearch/manticore.conf line 45; use 'network_timeout' instead.
WARNING: key 'max_children' was permanently removed from configuration. Refer to documentation for details.
WARNING: key 'preopen_indexes' is deprecated in /etc/manticoresearch/manticore.conf line 48; use 'preopen_tables' instead.
WARNING: key 'workers' is deprecated in /etc/manticoresearch/manticore.conf line 50; use 'default value' instead.
indexing table 'main'...
collected 10 docs, 0.0 MB
creating lookup: 0.0 Kdocs, 100.0% done
sorted 0.0 Mhits, 100.0% done
total 10 docs, 142 bytes
total 178.896 sec, 0 bytes/sec, 0.05 docs/sec
total 3 reads, 0.000 sec, 0.1 kb/call avg, 0.0 msec/call avg
total 17 writes, 0.000 sec, 0.1 kb/call avg, 0.0 msec/call avg
rotating tables: successfully sent SIGHUP to searchd (pid=42).
Проверяем распределенный индекс:
mysql> SELECT * FROM mytable;
+------+-----------------------+------------+
| id | title | updated |
+------+-----------------------+------------+
| 2 | Document Two | 1719397970 |
| 6 | Altered document Six | 1752045845 |
| 4 | Document Four | 1719397970 |
| 10 | Document Ten | 1752045844 |
| 8 | Document Eight | 1719397970 |
| 9 | Document Nine | 1719397970 |
| 11 | Document Ten | 1752045965 |
| 12 | Document Ten | 1752045968 |
| 3 | Altered dRRRR | 1752045986 |
| 7 | Altered documentssssx | 1752045978 |
+------+-----------------------+------------+
10 rows in set (0.00 sec)
Внесем теперь правки в Источник:
root@maindelta-6f4db574f-2cq47:/# mysql test -u user --password=pass123
mysql: [Warning] Using a password on the command line interface can be insecure.
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 5.7.40 MySQL Community Server (GPL)
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> UPDATE documents SET title='AltereTTTTx' WHERE id=4;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> UPDATE documents SET title='AltereTTTTx' WHERE id=10;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> INSERT INTO documents VALUES(13,'Document Ten',NOW(),0);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO documents VALUES(14,'Document Ten',NOW(),0);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO documents VALUES(15,'Document Ten',NOW(),0);
Query OK, 1 row affected (0.08 sec)
И соберем и выполним ротацию уже новой delta к новому main:
root@maindelta-6f4db574f-2cq47:/# sudo -u manticore indexer delta --rotate
Manticore 6.0.4 1a3a4ea82@230314
Copyright (c) 2001-2016, Andrew Aksyonoff
Copyright (c) 2008-2016, Sphinx Technologies Inc (http://sphinxsearch.com)
Copyright (c) 2017-2023, Manticore Software LTD (https://manticoresearch.com)
using config file '/etc/manticoresearch/manticore.conf'...
WARNING: key 'read_timeout' is deprecated in /etc/manticoresearch/manticore.conf line 45; use 'network_timeout' instead.
WARNING: key 'max_children' was permanently removed from configuration. Refer to documentation for details.
WARNING: key 'preopen_indexes' is deprecated in /etc/manticoresearch/manticore.conf line 48; use 'preopen_tables' instead.
WARNING: key 'workers' is deprecated in /etc/manticoresearch/manticore.conf line 50; use 'default value' instead.
indexing table 'delta'...
collected 5 docs, 0.0 MB
creating lookup: 0.0 Kdocs, 100.0% done
sorted 0.0 Mhits, 100.0% done
total 5 docs, 58 bytes
total 1.702 sec, 34 bytes/sec, 2.93 docs/sec
total 3 reads, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
total 18 writes, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
rotating tables: successfully sent SIGHUP to searchd (pid=42).
Проверяем распределенный индекс:
mysql> SELECT * FROM mytable;
+------+-----------------------+------------+
| id | title | updated |
+------+-----------------------+------------+
| 4 | AltereTTTTx | 1752046237 |
| 2 | Document Two | 1719397970 |
| 10 | AltereTTTTx | 1752046241 |
| 13 | Document Ten | 1752046249 |
| 8 | Document Eight | 1719397970 |
| 9 | Document Nine | 1719397970 |
| 14 | Document Ten | 1752046252 |
| 15 | Document Ten | 1752046256 |
| 11 | Document Ten | 1752045965 |
| 12 | Document Ten | 1752045968 |
| 3 | Altered dRRRR | 1752045986 |
| 7 | Altered documentssssx | 1752045978 |
+------+-----------------------+------------+
12 rows in set (0.00 sec)
Итого:
- собрали и применили main
- внесли правки в Источнике
- собрали и применили delta к main
- результат ОК
- внесли правки в Источнике
- собрали уже новый main и выполнили ротацию
- результат ОК
- внесли правки в Источнике
- собрали уже новую delta и применили к новому main
- результат ОК
Все документы: новые, измененные и старые на месте. Удаленные и обновленные подавлены. Т.е. проблемы нет.
Это на старой версии 6.0.4. Такой же результат ожидается на 7.0.0.
Отличительная разница в примере и нашем случае:
- в примере данных слишком мало и сборка main быстрая (относительно)
- дата
created_at
в таблице deltabreaker
устанавливает раньше чем нужно, ведь фактически индексация main еще может быть не закончена и тем более не применена в Manticore
У нас же дата для нового диапазона устанавливается не в sql_query_post_index
, а после синхронизации на поисковые node и фактической ротации main.
И как писал ранее от этого диапазона зависит результат сборки и применения delta к main:
- если дату ставить раньше чем нужно в
sql_query_post_index
, то delta будет собирается с новым диапазоном и после ротации к еще старому main начнет подавлять документы в нем ДО новой ротации main, а этого быть не должно
- если дату ставить после фактической ротации нового main, то delta будет собирается с новым диапазоном (это верно) и после ротации к уже новому main будет подавлено большое количество документов. При этом это не соответствует числу документов в новой delta и ее kill-list вне зависимости от режима.