-
-
Notifications
You must be signed in to change notification settings - Fork 511
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
mysqldump: keep cluster name #2249
Comments
Seems to be not possible without sensitive changes. As long as we return no cluster name in 'show tables' output, mysqldump can't imagine anything about cluster. Starting from this moment, all the rest issues (like mentioned Since in this call we have no sign of mysqldump (like |
shows that before
or without specifying the table (
Can't we use one of these specific queries (e.g. |
Seems that queries are specific to mysqldump flavour. We can use, for example, specific username or database name as explicit and obvious mark. Such way is more flexible, since username is not hardly bind to mysqldump, and so, you can also dump your table as if it were not in a cluster also. Best way would be just to allow plain names, without 'cluster:' prefix. Because otherwise it require further chain of changes - that is, if daemon returns prefixed names in 'show tables' - then mysqldump will use such names in all the other queries, like 'lock tables', 'show table status', and following in the trace. Some of them (like show create table) need special care, because direct replacement of table name to cluster:name is not replayable. So, there are at least two possible solutions:
|
That cause the user to write into cluster while node is not in the cluster, ie in case of the network issue or cluster got broken user will write into cluster think it works however cluster already gone and that data will not reach the other nodes or the data could conflicts with other nodes data or that data will be replaced by the data from the donor after node got fixed and reconnect back into cluster. That was some kind of protection to make sure the user make sure it writes data into cluster or into local table. |
Well, that is effectively protect clustered table from being backed up by mysqldump then. |
As discussed on yesterday's call:
|
List of commands which need to be fixed for mysqldump to work with manticore
|
-- MySQL dump 10.13 Distrib 8.3.0, for macos14.4 (arm64)
--
-- Host: 0 Database: Manticore
-- ------------------------------------------------------
-- Server version 6.3.7 2bdc473e1@24100420 dev (knn 2.2.5 478fff2@240417)
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!50503 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Dumping data for table `test:x`
--
LOCK TABLES `test:x` WRITE;
/*!40000 ALTER TABLE `test:x` DISABLE KEYS */;
INSERT INTO `test:x` VALUES ('1',1),('2',2),('3',3),('4',1),('5',2),('6',3);
/*!40000 ALTER TABLE `test:x` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2024-10-07 15:49:15 for reference, dump WITHOUT cluster, from command -- MySQL dump 10.13 Distrib 8.3.0, for macos14.4 (arm64)
--
-- Host: 0 Database: Manticore
-- ------------------------------------------------------
-- Server version 6.3.7 2bdc473e1@24100420 dev (knn 2.2.5 478fff2@240417)
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!50503 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Dumping data for table `x`
--
LOCK TABLES `x` WRITE;
/*!40000 ALTER TABLE `x` DISABLE KEYS */;
INSERT INTO `x` VALUES ('1',1),('2',2),('3',3),('4',1),('5',2),('6',3);
/*!40000 ALTER TABLE `x` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2024-10-07 15:52:35 and dump WITHOUT cluster, from command -- MySQL dump 10.13 Distrib 8.3.0, for macos14.4 (arm64)
--
-- Host: 0 Database: Manticore
-- ------------------------------------------------------
-- Server version 6.3.7 2bdc473e1@24100420 dev (knn 2.2.5 478fff2@240417)
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!50503 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `x`
--
DROP TABLE IF EXISTS `x`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `x` (
`id` bigint,
`tag` bigint
) jieba_hmm='0' charset_table='non_cjk';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `x`
--
LOCK TABLES `x` WRITE;
/*!40000 ALTER TABLE `x` DISABLE KEYS */;
INSERT INTO `x` VALUES ('1',1),('2',2),('3',3),('4',1),('5',2),('6',3);
/*!40000 ALTER TABLE `x` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2024-10-07 15:51:56 |
That is not just cluster:table, but `cluster:table`. For mysqldump-specific commands user should match cluster_user (yes, this is not normal-flavour, this is specific hack). For insert/replace user is not checked (so, replaying dumps doesn't require specific user). That is related to #2249
There are couple of things m.b. need to be added into documentation. mysql> show variables;
+------------------------------+----------------+
| Variable_name | Value |
+------------------------------+----------------+
| autocommit | 1 |
| auto_optimize | 1 |
| optimize_cutoff | 24 |
| collation_connection | libc_ci |
| query_log_format | sphinxql |
| session_read_only | 0 |
| log_level | debug |
| max_allowed_packet | 134217728 |
| character_set_client | utf8 |
| character_set_connection | utf8 |
| grouping_in_utc | 0 |
| timezone | /etc/localtime |
| last_insert_id | |
| pseudo_sharding | 1 |
| secondary_indexes | 0 |
| accurate_aggregation | 0 |
| distinct_precision_threshold | 3500 |
| threads_ex_effective | |
| cluster_user | cluster |
| thread_stack | 1048576 |
| threads_ex | |
| user | alexey |
+------------------------------+----------------+
22 rows in set (0,00 sec) Notice new values -
That name is instance-wide, and doesn't require vip. Also, you don't need to relogin. mysql> show tables;
+----------------+-------------+
| Index | Type |
+----------------+-------------+
| dist_table | distributed |
| dname | distributed |
| index2001 | rt |
| index2002 | rt |
| index2003 | rt |
| index2004 | rt |
| index201 | rt |
| index202 | rt |
| index203 | rt |
| index204 | rt |
| mcl_only_json | rt |
| name | rt |
| no_mcl_json | rt |
| no_mcl_multi | rt |
| no_mcl_multi64 | rt |
| oned | distributed |
| products | percolate |
| rr | rt |
| t | rt |
| t1 | rt |
| test | rt |
| test1 | rt |
| test_template | rt |
| tt | rt |
| x | rt |
+----------------+-------------+
25 rows in set (0,00 sec)
mysql> set global cluster_user=alexey;
Query OK, 0 rows affected (0,00 sec)
mysql> show tables;
+----------------+-------------+
| Index | Type |
+----------------+-------------+
| dist_table | distributed |
| dname | distributed |
| index2001 | rt |
| index2002 | rt |
| index2003 | rt |
| index2004 | rt |
| index201 | rt |
| index202 | rt |
| index203 | rt |
| index204 | rt |
| mcl_only_json | rt |
| test:name | rt |
| no_mcl_json | rt |
| no_mcl_multi | rt |
| no_mcl_multi64 | rt |
| oned | distributed |
| products | percolate |
| rr | rt |
| t | rt |
| t1 | rt |
| test | rt |
| test1 | rt |
| test_template | rt |
| tt | rt |
| test:x | rt |
+----------------+-------------+
25 rows in set (0,00 sec) |
Updated docs in 05247a0 |
@PavelShilin89 pls update the mysqldump CLT test, so it tests dump/restore in replication mode too. See details in the docs - https://manual.manticoresearch.com/dev/Securing_and_compacting_a_table/Backup_and_restore#Backup-and-restore-with-mysqldump |
@sanikolaev Test updated in PR - #2816. |
I'm reopening this issue since it's not working (tested on
dev2:
Expected: mysqldump doesn't fail. |
It's turned out this functionality comes with 2 limitations:
The updated test is:
|
It's turned out
is not the requirement. Vice versa, it's recommended to dump a specific table, but you need to use the
|
@PavelShilin89 I've updated the docs. Pls continue with preparing a test for this issue. In your PR you don't specify |
Proposal:
When a table is being dumped with
mysqldump
and the table is in a cluster, let's keep the cluster name. It makes possible using mysqldump to reindex the table in a cluster like this:Another option is to make
mysqldump ... cluster:table
possible:Probably it fails at:
Checklist:
To be completed by the assignee. Check off tasks that have been completed or are not applicable.
The text was updated successfully, but these errors were encountered: