-
-
Notifications
You must be signed in to change notification settings - Fork 474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Properly rotate index if using only RT indexes (ALTER RENAME) #527
Comments
You are probably looking for smth like |
I don't remember the exact details now, But pretty sure have had success using 'ATTACH' to move data from one RT index to the other. Each 'shard' an RT index is effectively a 'plain' index. So just move each shard separately. (or can use I think had to create a 'fake' index for the shard. ie if the 'source' RT index has a
then can create a new 'fake' RT index for each shard
Then this new fake index, is that is using the data form the single shard. Then can attach this
(only working from memory here, so probably some more details. Including faffing around with restarting searchd, as it doesnt like converting the RT shard to a plain index while running) Never tried it, but perhaps could just rename all the index files, to 'rename' an index. Would have to be done while searchd is shutdown, and not forgetting to update the config file! |
ALTER TABLE RENAME is exactly what I am looking for. |
@barryhunter as I remember I tried this attach option, however without FLUSHing, will try, many thanks. |
OK, I have tested an approach with attaching index. |
can ALTER RENAME be implemented? |
Yes, it can. But it's not in our nearest plans. If it's mission critical for you we provide professional services including custom feature requests development - https://manticoresearch.com/services |
ok, we will will wait when you consider to add it |
…plete content of the another RT index; fixed Github #527; fixed model at test 187; added cases to test 464
fixed at af5812c. Now ATTACH supports the RT index along with the plain index as the source.
|
Demo of how it works: mysql> drop table if exists t; drop table if exists t2; create table t; insert into t values(1); flush ramchunk t; insert into t values(2); flush ramchunk t; insert into t values(3); select * from t.@files limit 100; create table t2 like t; insert into t2 values(11); flush ramchunk t; insert into t2 values(12); select * from t; select * from t2; ATTACH TABLE t TO TABLE t2; select * from t.@files limit 100;
select * from t2.@files limit 100;
--------------
drop table if exists t
--------------
Query OK, 0 rows affected (0.02 sec)
--------------
drop table if exists t2
--------------
Query OK, 0 rows affected (0.00 sec)
--------------
create table t
--------------
Query OK, 0 rows affected (0.00 sec)
--------------
insert into t values(1)
--------------
Query OK, 1 row affected (0.00 sec)
--------------
flush ramchunk t
--------------
Query OK, 0 rows affected (0.00 sec)
--------------
insert into t values(2)
--------------
Query OK, 1 row affected (0.00 sec)
--------------
flush ramchunk t
--------------
Query OK, 0 rows affected (0.01 sec)
--------------
insert into t values(3)
--------------
Query OK, 1 row affected (0.00 sec)
--------------
select * from t.@files limit 100
--------------
+------+---------------------------------+---------------------------------+------+
| id | file | normalized | size |
+------+---------------------------------+---------------------------------+------+
| 2 | /var/lib/manticore/t/t.settings | /var/lib/manticore/t/t.settings | 3 |
| 3 | /var/lib/manticore/t/t.0.sph | /var/lib/manticore/t/t.0.sph | 419 |
| 4 | /var/lib/manticore/t/t.0.spd | /var/lib/manticore/t/t.0.spd | 1 |
| 5 | /var/lib/manticore/t/t.0.spp | /var/lib/manticore/t/t.0.spp | 1 |
| 6 | /var/lib/manticore/t/t.0.spe | /var/lib/manticore/t/t.0.spe | 1 |
| 7 | /var/lib/manticore/t/t.0.spi | /var/lib/manticore/t/t.0.spi | 1 |
| 8 | /var/lib/manticore/t/t.0.spm | /var/lib/manticore/t/t.0.spm | 4 |
| 9 | /var/lib/manticore/t/t.0.sphi | /var/lib/manticore/t/t.0.sphi | 66 |
| 10 | /var/lib/manticore/t/t.0.spt | /var/lib/manticore/t/t.0.spt | 36 |
| 11 | /var/lib/manticore/t/t.0.spidx | /var/lib/manticore/t/t.0.spidx | 145 |
| 12 | /var/lib/manticore/t/t.0.spa | /var/lib/manticore/t/t.0.spa | 40 |
| 13 | /var/lib/manticore/t/t.1.sph | /var/lib/manticore/t/t.1.sph | 419 |
| 14 | /var/lib/manticore/t/t.1.spd | /var/lib/manticore/t/t.1.spd | 1 |
| 15 | /var/lib/manticore/t/t.1.spp | /var/lib/manticore/t/t.1.spp | 1 |
| 16 | /var/lib/manticore/t/t.1.spe | /var/lib/manticore/t/t.1.spe | 1 |
| 17 | /var/lib/manticore/t/t.1.spi | /var/lib/manticore/t/t.1.spi | 1 |
| 18 | /var/lib/manticore/t/t.1.spm | /var/lib/manticore/t/t.1.spm | 4 |
| 19 | /var/lib/manticore/t/t.1.sphi | /var/lib/manticore/t/t.1.sphi | 66 |
| 20 | /var/lib/manticore/t/t.1.spt | /var/lib/manticore/t/t.1.spt | 36 |
| 21 | /var/lib/manticore/t/t.1.spidx | /var/lib/manticore/t/t.1.spidx | 145 |
| 22 | /var/lib/manticore/t/t.1.spa | /var/lib/manticore/t/t.1.spa | 40 |
| 1 | /var/lib/manticore/t/t.meta | /var/lib/manticore/t/t.meta | 487 |
+------+---------------------------------+---------------------------------+------+
22 rows in set (0.00 sec)
--- 22 out of 22 results in 0ms ---
--------------
create table t2 like t
--------------
Query OK, 0 rows affected (0.00 sec)
--------------
insert into t2 values(11)
--------------
Query OK, 1 row affected (0.00 sec)
--------------
flush ramchunk t
--------------
Query OK, 0 rows affected (0.00 sec)
--------------
insert into t2 values(12)
--------------
Query OK, 1 row affected (0.00 sec)
--------------
select * from t
--------------
+------+
| id |
+------+
| 2 |
| 1 |
| 3 |
+------+
3 rows in set (0.00 sec)
--- 3 out of 3 results in 0ms ---
--------------
select * from t2
--------------
+------+
| id |
+------+
| 12 |
| 11 |
+------+
2 rows in set (0.00 sec)
--- 2 out of 2 results in 0ms ---
--------------
ATTACH TABLE t TO TABLE t2
--------------
Query OK, 0 rows affected (0.01 sec)
--------------
select * from t.@files limit 100
--------------
+------+---------------------------------+---------------------------------+------+
| id | file | normalized | size |
+------+---------------------------------+---------------------------------+------+
| 2 | /var/lib/manticore/t/t.settings | /var/lib/manticore/t/t.settings | 3 |
| 1 | /var/lib/manticore/t/t.meta | /var/lib/manticore/t/t.meta | 489 |
+------+---------------------------------+---------------------------------+------+
2 rows in set (0.00 sec)
--- 2 out of 2 results in 0ms ---
--------------
select * from t2.@files limit 100
--------------
+------+-----------------------------------+-----------------------------------+------+
| id | file | normalized | size |
+------+-----------------------------------+-----------------------------------+------+
| 2 | /var/lib/manticore/t2/t2.ram | /var/lib/manticore/t2/t2.ram | 12 |
| 3 | /var/lib/manticore/t2/t2.settings | /var/lib/manticore/t2/t2.settings | 3 |
| 4 | /var/lib/manticore/t2/t2.0.sph | /var/lib/manticore/t2/t2.0.sph | 419 |
| 5 | /var/lib/manticore/t2/t2.0.spd | /var/lib/manticore/t2/t2.0.spd | 1 |
| 6 | /var/lib/manticore/t2/t2.0.spp | /var/lib/manticore/t2/t2.0.spp | 1 |
| 7 | /var/lib/manticore/t2/t2.0.spe | /var/lib/manticore/t2/t2.0.spe | 1 |
| 8 | /var/lib/manticore/t2/t2.0.spi | /var/lib/manticore/t2/t2.0.spi | 1 |
| 9 | /var/lib/manticore/t2/t2.0.spm | /var/lib/manticore/t2/t2.0.spm | 4 |
| 10 | /var/lib/manticore/t2/t2.0.sphi | /var/lib/manticore/t2/t2.0.sphi | 82 |
| 11 | /var/lib/manticore/t2/t2.0.spt | /var/lib/manticore/t2/t2.0.spt | 41 |
| 12 | /var/lib/manticore/t2/t2.0.spidx | /var/lib/manticore/t2/t2.0.spidx | 149 |
| 13 | /var/lib/manticore/t2/t2.0.spa | /var/lib/manticore/t2/t2.0.spa | 48 |
| 14 | /var/lib/manticore/t2/t2.1.sph | /var/lib/manticore/t2/t2.1.sph | 419 |
| 15 | /var/lib/manticore/t2/t2.1.spd | /var/lib/manticore/t2/t2.1.spd | 1 |
| 16 | /var/lib/manticore/t2/t2.1.spp | /var/lib/manticore/t2/t2.1.spp | 1 |
| 17 | /var/lib/manticore/t2/t2.1.spe | /var/lib/manticore/t2/t2.1.spe | 1 |
| 18 | /var/lib/manticore/t2/t2.1.spi | /var/lib/manticore/t2/t2.1.spi | 1 |
| 19 | /var/lib/manticore/t2/t2.1.spm | /var/lib/manticore/t2/t2.1.spm | 4 |
| 20 | /var/lib/manticore/t2/t2.1.sphi | /var/lib/manticore/t2/t2.1.sphi | 66 |
| 21 | /var/lib/manticore/t2/t2.1.spt | /var/lib/manticore/t2/t2.1.spt | 36 |
| 22 | /var/lib/manticore/t2/t2.1.spidx | /var/lib/manticore/t2/t2.1.spidx | 145 |
| 23 | /var/lib/manticore/t2/t2.1.spa | /var/lib/manticore/t2/t2.1.spa | 40 |
| 24 | /var/lib/manticore/t2/t2.2.sph | /var/lib/manticore/t2/t2.2.sph | 419 |
| 25 | /var/lib/manticore/t2/t2.2.spd | /var/lib/manticore/t2/t2.2.spd | 1 |
| 26 | /var/lib/manticore/t2/t2.2.spp | /var/lib/manticore/t2/t2.2.spp | 1 |
| 27 | /var/lib/manticore/t2/t2.2.spe | /var/lib/manticore/t2/t2.2.spe | 1 |
| 28 | /var/lib/manticore/t2/t2.2.spi | /var/lib/manticore/t2/t2.2.spi | 1 |
| 29 | /var/lib/manticore/t2/t2.2.spm | /var/lib/manticore/t2/t2.2.spm | 4 |
| 30 | /var/lib/manticore/t2/t2.2.sphi | /var/lib/manticore/t2/t2.2.sphi | 66 |
| 31 | /var/lib/manticore/t2/t2.2.spt | /var/lib/manticore/t2/t2.2.spt | 36 |
| 32 | /var/lib/manticore/t2/t2.2.spidx | /var/lib/manticore/t2/t2.2.spidx | 145 |
| 33 | /var/lib/manticore/t2/t2.2.spa | /var/lib/manticore/t2/t2.2.spa | 40 |
| 34 | /var/lib/manticore/t2/t2.3.sph | /var/lib/manticore/t2/t2.3.sph | 419 |
| 35 | /var/lib/manticore/t2/t2.3.spd | /var/lib/manticore/t2/t2.3.spd | 1 |
| 36 | /var/lib/manticore/t2/t2.3.spp | /var/lib/manticore/t2/t2.3.spp | 1 |
| 37 | /var/lib/manticore/t2/t2.3.spe | /var/lib/manticore/t2/t2.3.spe | 1 |
| 38 | /var/lib/manticore/t2/t2.3.spi | /var/lib/manticore/t2/t2.3.spi | 1 |
| 39 | /var/lib/manticore/t2/t2.3.spm | /var/lib/manticore/t2/t2.3.spm | 4 |
| 40 | /var/lib/manticore/t2/t2.3.sphi | /var/lib/manticore/t2/t2.3.sphi | 66 |
| 41 | /var/lib/manticore/t2/t2.3.spt | /var/lib/manticore/t2/t2.3.spt | 36 |
| 42 | /var/lib/manticore/t2/t2.3.spidx | /var/lib/manticore/t2/t2.3.spidx | 145 |
| 43 | /var/lib/manticore/t2/t2.3.spa | /var/lib/manticore/t2/t2.3.spa | 40 |
| 1 | /var/lib/manticore/t2/t2.meta | /var/lib/manticore/t2/t2.meta | 491 |
+------+-----------------------------------+-----------------------------------+------+
43 rows in set (0.00 sec)
--- 43 out of 43 results in 0ms ---
--------------
select * from t2
--------------
+------+
| id |
+------+
| 3 |
| 1 |
| 11 |
| 2 |
| 12 |
+------+
5 rows in set (0.00 sec)
--- 5 out of 5 results in 0ms ---
--------------
select * from t
--------------
Empty set (0.00 sec)
--- 0 out of 0 results in 0ms --- As we can see, all data from table |
I'm reopening this issue to:
|
I sure there is no need to issue |
Blocked by manticoresoftware/manticoresearch-buddy#273 |
waiting for review manticoresoftware/manticoresearch-buddy#260 |
Looks good! Once you've finalized everything, we can move forward with merging. |
@djklim87 pls create a PR with the doc update. |
|
Reviewed. Approved. |
@PavelShilin89 pls proceed with:
|
As discussed, please test it more thoroughly, especially for edge cases. |
I've tested it manually. Looks good to me. |
Done in #2189 |
I am having trouble finding a proper way to rotate data in RT index.
For the sake of speed, I am indexing data to RT index directly (sending concurrent queries and bulk inserts).
But, when I need to reindex the data from the scratch I can't just prepare a new table to create as "LIKE" the current table, fill it with the data, and replace the old table with the new one filled with new data.
What is the correct way to do this?
The text was updated successfully, but these errors were encountered: