Skip to content

Restore particular tables #58

@sanikolaev

Description

@sanikolaev

It would be great to be able to restore a particular table. IMPORT can be automated for that, e.g.:

root@bb5278967f62:/# mysql -P9306 -h0 -e "insert into t(f) values('abc'); flush ramchunk t;"
root@bb5278967f62:/# mysql -P9306 -h0 -e "insert into t2(f) values('abc'); flush ramchunk t2;"
root@bb5278967f62:/# mysql -P9306 -h0 -e "backup table t to /tmp/"
+----------------------------+
| Path                       |
+----------------------------+
| /tmp/backup-20230222140126 |
+----------------------------+
root@bb5278967f62:/# mysql -P9306 -h0 -e "drop table t"
root@bb5278967f62:/# mysql -P9306 -h0 -e "import table t from '/tmp/backup-20230222140126/data/t/t'"
root@bb5278967f62:/# mysql -P9306 -h0 -e "select * from t"
+---------------------+------+
| id                  | f    |
+---------------------+------+
| 4901936465623121921 | abc  |
+---------------------+------+

UPDATE Jan 19th 2024

For the sake of data safety and high availabiliy it makes sense to:

  • first off import a table into a temporary table (may take time since we copy the files here)
  • then if all is ok, truncate the table being restored
  • then move chunks from the temporary table to the new one (should be instant as the chunks are in the same data dir and we move them). Use ATTACH for that (available for RT since manticoresoftware/manticoresearch@af5812c)

This should protect from losing the table in the middle of importing a table due to an instance shutdown or smth else.

Let's also add support for wildcards in --tables, so

  • --restore --tables=tbl1,tbl2 restores tbl1 and tbl2
  • --restore --tables=tbl* restores all tbl*. Let's support wildcards % and *

We'll also need to cover the new functionality with CLT tests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions