Tag Archives: Mysql 5.7

MySQL 5.7 uses xtabackup to resolve error reports

Error message:

InnoDB: An optimized (without redo logging) DDLoperation has been performed. All modified pages may not have been flushed to the disk yet.

To solve this error, percona adds three new parameters xtrabackup — lock DDL, xtrabackup — lock DDL timeout, xtrabackup — lock DDL per table

MySQL 5.7 skips some DDLS when recording redo logs. In MySQL 5.7, index creation is divided into three stages
1: scan the clustered index and generate index entries into the sort buffer. When the sort buffer is full, it will be written to the temporary file
2: multiple threads sort the index entries in the temporary file or sort buffer
3: insert them into the B-tree after sorting
before that, MySQL will call insert APIs to insert B-tree one by one when creating an index. This insertion method will open the B-tree cursor, find the location and insert optimistically. If the B-tree node page to be inserted is full, the B-tree page page will be split or merged, which is called pessimistic insertion. In this way, creating an index will cause continuous splitting and merging, and find the insertion location, which will be more expensive
sorted index builds and redo logging:
redo logging will be turned off when using sorted index to create an index. It ensures the high availability of index creation through checkpointing. Checkpoints force all dirty pages to be written to the disk. During index creation, the page cleaner will periodically refresh the dirty pages to ensure the fast push forward of checkpoints. Usually, the page cleaner will refresh dirty pages only when the number of clean pages is lower than the set threshold. However, during index creation, the page cleaner will refresh quickly to reduce the overhead of checkpoints

Because redo is not recorded, the following errors will occur during backup

[FATAL] InnoDB: An optimized(without redo logging) DDLoperation has been performed. All modified pages may not have been flushed to the disk yet.
Percona XtraBackup will not be able to take a consistent backup. Retry the backup operation

Xtrabackup adds the — lock DDL option to solve this problem, but it will add an executing lock tables for backup to all tables during backup

another option is — lock DDL per table, which will have the following output

170726 11:32:33 [01] Copying ./ibdata1 to /home/shahriyar.rzaev/backup_dir/ps_5.7_master/full/2017-07-26_11-31-56/ibdata1
170726 11:32:33 Locking MDL for db1.sb1
170726 11:32:33 [02] Copying ./db1/sb1.ibd to /home/shahriyar.rzaev/backup_dir/ps_5.7_master/full/2017-07-26_11-31-56/db1/sb1.ibd
170726 11:32:33 Locking MDL for db1.sbtest1
170726 11:32:33 Locking MDL for db2.sb1
170726 11:32:33 [03] Copying ./db1/sbtest1.ibd to /home/shahriyar.rzaev/backup_dir/ps_5.7_master/full/2017-07-26_11-31-56/db1/sbtest1.ibd
170726 11:32:33 [04] Copying ./db2/sb1.ibd to /home/shahriyar.rzaev/backup_dir/ps_5.7_master/full/2017-07-26_11-31-56/db2/sb1.ibd
170726 11:32:33 [04] ...done
170726 11:32:33 >> log scanned up to (2892754398)
170726 11:32:34 Locking MDL for db2.sbtest1

  

It should be noted that the use of the — lock DDL parameter in non percona servers may not be supported, such as MariaDB. But — lock DDL per table is supported by all servers

However, if a process holds an MDL lock and another process performs an alter table operation (index creation belongs to the alter table operation), the update operation will be blocked

If you don’t want any blocking during backup, you can only open old_alter_Table parameter, so you can’t use the new feature of alter table

Parameter item interpretation

  --lock-ddl Issue LOCK TABLES FOR BACKUP if it is supported by server at the beginning of the backup to block all DDL operations. --lock-ddl-timeout=# If LOCK TABLES FOR BACKUP does not return within given timeout, abort the backup. --lock-ddl-per-table Lock DDL for each table before xtrabackup starts to copy it and until the backup is completed. --safe-slave-backup Stop slave SQL thread and wait to start backup until Slave_open_temp_tables in "SHOW STATUS" is zero. If there are no open temporary tables, the backup will take place, otherwise the SQL thread will be started and stopped until there are no open temporary tables. The backup will fail if Slave_open_temp_tables does not become zero after --safe-slave-backup-timeout seconds. The slave SQL thread will be restarted when the backup finishes.

 

MySQL 5.7 error reporting from database 1032 [How to Solve]

1. Introduction:

During MySQL 5.7 multi-source replication and master-slave synchronization, the master database updates a piece of data, and the slave database has been deleted, resulting in the master-slave disconnection

Last_Errno: 1032

The 1032 error of MySQL master-slave synchronization generally means that the data to be changed does not exist and SQL_The log extracted by thread cannot be applied, so an error is reported, resulting in synchronization failure

(update, delete, insert a piece of deleted data). The 1032 error itself has no impact on data consistency, and the biggest impact is the synchronization failure

2. Solution:

MySQL version 5.7.15-log, binlog mode is row

Show slave status \ g, you can see the following error reports:

 1  Last_Errno: 1032
 2                    Last_Error: Coordinator stopped because there were error(s) in the worker(s). The most recent failure being: Worker 3 failed executing transaction '1699
 3 7e5e-5707-11e7-a702-94188201787c:161982297' at master log mysql-bin.000309, end_log_pos 774308000. See error log and/or performance_schema.replication_applier_status_by_worker table for more details about this failure or others, if any.                 Skip_Counter: 0
 4           Exec_Master_Log_Pos: 774271552
 5               Relay_Log_Space: 1266940262
 6               Until_Condition: None
 7                Until_Log_File: 
 8                 Until_Log_Pos: 0
 9            Master_SSL_Allowed: No
10            Master_SSL_CA_File: 
11            Master_SSL_CA_Path: 
12               Master_SSL_Cert: 
13             Master_SSL_Cipher: 
14                Master_SSL_Key: 
15         Seconds_Behind_Master: NULL
16 Master_SSL_Verify_Server_Cert: No
17                 Last_IO_Errno: 0
18                 Last_IO_Error: 
19                Last_SQL_Errno: 1032
20                Last_SQL_Error: Coordinator stopped because there were error(s) in the worker(s). The most recent failure being: Worker 3 failed executing transaction '1699
21 7e5e-5707-11e7-a702-94188201787c:161982297' at master log mysql-bin.000309, end_log_pos 774308000. See error log and/or performance_schema.replication_applier_status_by_worker table for more details about this failure or others, if any.

 

See error log:

vim error.log

2018-10-26T01:55:00.133136+08:00 16179 [ERROR] Slave SQL for channel 'master_6': Worker 3 failed executing transaction '16997e5e-5707-11e7-a702-94188201787c:161982297' at 
master log mysql-bin.000309, end_log_pos 774308000; Could not execute Update_rows event on table test.test_log; Can't find record in 'test_log', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log mysql-bin.000309, end_log_pos 774308000, Error_code: 1032

Method 1: skip errors

1) Skip this error first and let the master-slave synchronization return to normal( Or n events (skip one by one)

set global sql_slave_skip_counter=1;

start slave sql_thread for channel ‘master_6’;

After the slave is up, recover the data and re insert it from the database

2)The most recent failure being: Worker 3 failed executing transaction ‘169921 7e5e-5707-11e7-a702-94188201787c:161982297′

In gtid mode, you can also:

set gtid_next=’169921 7e5e-5707-11e7-a702-94188201787c:161982297′;

begin;

commit;

set gtid_next=’automatic’;

stop slave   sql_thread for channel ‘master_6’;

 

start slave sql_thread for channel ‘master_6’;

Method 2: restore the deleted data

According to the error prompt, find the SQL of this data through mysqlbinglog. The location of this event in the master binlog of the master server is mysql-bin.000309, end_log_pos77430800

 1 [root@xxxxx binlog]# mysqlbinlog  --no-defaults --stop-position=774308000 mysql-bin.000309 -vv |grep -A 20 774308000
 2 #181026  1:55:00 server id 3663306  end_log_pos 774308000 CRC32 0x2969563a     Update_rows: table id 52745 flags: STMT_END_F
 3 
 4 BINLOG '
 5 dAPSWxPK5TcAWgAAAIr+Ji4AAAnOAAAAAAEAB21vbml0b3IAEWpvYl9leGVjdXRpb25fbG9nAAsP
 6 Dw8PDwMPDwMRERCgAJAB/AP8A8gAUACAPgAAgAbDz1ww
 7 dAPSWx/K5TcAFgIAAKAAJy4AAAnOAAAAAAEAAgAL/////4D8JDZlOGJjNGZlLTlmYzktNDllYS1h
 8 NjliLWE4YmNjMWZjOGJlZiQAb21zVXBkYXRlV2FyZWhvdXNlT3JkZXJUYXNrU3RhdHVzSm9iZgBv
 9 bXNVcGRhdGVXYXJlaG91c2VPcmRlclRhc2tTdGF0dXNKb2JALUAwQC1AUkVBRFlALUAxMC4xNTcu
10 MzIuMzlALUA2NTYyYzQ5YS0zMjQyLTQyNWQtODdhZC1lZTA4N2M0NmYzN2UXAGRwcHZkb2NzZXIx
11 OC5zZXBob3JhLmNuDDEwLjE1Ny4zMi4zOQAAAAAOTk9STUFMX1RSSUdHRVIAAAAAW9IDdID4JDZl
12 OGJjNGZlLTlmYzktNDllYS1hNjliLWE4YmNjMWZjOGJlZiQAb21zVXBkYXRlV2FyZWhvdXNlT3Jk
13 ZXJUYXNrU3RhdHVzSm9iZgBvbXNVcGRhdGVXYXJlaG91c2VPcmRlclRhc2tTdGF0dXNKb2JALUAw
14 QC1AUkVBRFlALUAxMC4xNTcuMzIuMzlALUA2NTYyYzQ5YS0zMjQyLTQyNWQtODdhZC1lZTA4N2M0
15 NmYzN2UXAGRwcHZkb2NzZXIxOC5zZXBob3JhLmNuDDEwLjE1Ny4zMi4zOQAAAAAOTk9STUFMX1RS
16 SUdHRVIBAAAAW9IDdFvSA3Q6Vmkp
17 '/*!*/;
18 ### UPDATE `test`.`test_log`
19 ### WHERE
20 ###   @1='6e8bc4fe-9fc9-49ea-a69b-a8bcc1fc8bef' /* VARSTRING(160) meta=160 nullable=0 is_null=0 */
21 ###   @2='omsUpdateWarehouseOrderTaskStatusJob' /* VARSTRING(400) meta=400 nullable=0 is_null=0 */
22 ###   @3='omsUpdateWarehouseOrderTaskStatusJob@-@0@-@READY@-@1@-@6562c49a-3242-425d-87ad-ee087c46f37e' /* VARSTRING(1020) meta=1020 nullable=0 is_null=0 */

 

The statement for the transaction is: UPDATE `test`. `test_log` where @1=”, @2=” (@1 is the first field, @2 is the second field)

To be missing this data from the library, change the update in the above binglog to insert

Do not log binlog.

set sql_log_bin=0;

insert  into `test`.`test_log`   values() ;

set sql_log_bin=1;

start slave sql_thread for channel ‘master_6’;

[Solved] Mysql 5.7 Change Passwords ERROR 1054 (42S22): Unknown column ‘password’ in ‘field list’

1. Environment

Reinstalled the environment on the new server, which was 5.6, and upgraded to version 5.7. 

2. Problems

A new installation of MySQL 5.7 prompted a password error when logging in. I didn't change the password when I installed it, but later changed it by logging in password-free.

Enter.

update mysql.user set password=password('root') where user='root'

Error message: ERROR 1054 (42S22): Unknown column 'password' in 'field list'

3. Solutions

There is no password field in MySQL 5.7 + database. The password field is changed to authentication_ string.

#Just change the change statement to the following

update mysql.user set authentication_ string=password(‘root’) where user=’root’ ;

#Refresh permissions

flush privileges;