Bonjour à tous,

Je bute depuis plusieurs jours sur une erreur de réplication et je ne trouve aucune solution.

J'ai deux serveurs, un primaire (en mysql 5.7.31), et un secondaire (qui était jusqu'à hier en 5.7.31 et depuis cette nuit en mariadb 10) sur lequel je fais donc une réplication avec un user replica qui a les droits de réplications, références, update .. bref, je lui ai mis la totale ...

Voici l'erreur:

MariaDB [(none)]> show all slaves status \G
*************************** 1. row ***************************
Connection_name:
Slave_SQL_State:
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.0.100
Master_User: replica
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000002
Read_Master_Log_Pos: 114304984
Relay_Log_File: mysqld-relay-bin.000002
Relay_Log_Pos: 3766
Relay_Master_Log_File: mysql-bin.000002
Slave_IO_Running: Yes
Slave_SQL_Running: No
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 1452
Last_Error: Could not execute Write_rows event on table databaseX.HISTOPT; Cannot add or update a child row: a foreign key constraint fails (`databaseX`.`HISTOPT`, CONSTRAINT `FK_HISTOPT_HISTORY` FOREIGN KEY (`histoIDProduit`, `historyrange`) REFERENCES `History` (`idProduit`, `range`) ON DELETE NO ACTION ON UPDATE NO ACTIO), Error_code: 1452; handler error HA_ERR_NO_REFERENCED_ROW; the event's master log mysql-bin.000002, end_log_pos 107837329
Skip_Counter: 0
Exec_Master_Log_Pos: 107836379
Relay_Log_Space: 6041058
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 1452
Last_SQL_Error: Could not execute Write_rows event on table databaseX.HISTOPT; Cannot add or update a child row: a foreign key constraint fails (`databaseX`.`HISTOPT`, CONSTRAINT `FK_HISTOPT_HISTORY` FOREIGN KEY (`histoIDProduit`, `historyrange`) REFERENCES `History` (`idProduit`, `range`) ON DELETE NO ACTION ON UPDATE NO ACTIO), Error_code: 1452; handler error HA_ERR_NO_REFERENCED_ROW; the event's master log mysql-bin.000002, end_log_pos 107837329
Replicate_Ignore_Server_Ids:
Master_Server_Id: 1
Master_SSL_Crl:
Master_SSL_Crlpath:
Using_Gtid: No
Gtid_IO_Pos:
Replicate_Do_Domain_Ids:
Replicate_Ignore_Domain_Ids:
Parallel_Mode: conservative
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State:
Slave_DDL_Groups: 0
Slave_Non_Transactional_Groups: 0
Slave_Transactional_Groups: 0
Retried_transactions: 0
Max_relay_log_size: 1073741824
Executed_log_entries: 45
Slave_received_heartbeats: 0
Slave_heartbeat_period: 30.000
Gtid_Slave_Pos: 0-2-17
1 row in set (0.001 sec)

MariaDB [(none)]> show engine innodb status \G
*************************** 1. row ***************************
Type: InnoDB
Name:
Status:
=====================================
2020-11-17 11:12:08 0x7f6bf0b77700 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 59 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 4 srv_active, 0 srv_shutdown, 1874 srv_idle
srv_master_thread log flush and writes: 1878
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 44
OS WAIT ARRAY INFO: signal count 34
RW-shared spins 59, rounds 477, OS waits 11
RW-excl spins 162, rounds 575, OS waits 3
RW-sx spins 0, rounds 0, OS waits 0
Spin rounds per wait: 8.08 RW-shared, 3.55 RW-excl, 0.00 RW-sx
------------------------
LATEST FOREIGN KEY ERROR
------------------------
2020-11-17 11:02:22 0x7f6bf0ae1700 Transaction:
TRANSACTION 2459, ACTIVE 0 sec inserting
mysql tables in use 1, locked 1
5 lock struct(s), heap size 1128, 2 row lock(s), undo log entries 1
MySQL thread id 22, OS thread handle 140101576169216, query id 122 Write_rows_log_event::write_row(-1)
Foreign key constraint fails for table `databaseX`.`HISTOPT`:
,
CONSTRAINT `FK_HISTOPT_HISTORY` FOREIGN KEY (`histoIDProduit`, `historyrange`) REFERENCES `History` (`idProduit`, `range`) ON DELETE NO ACTION ON UPDATE NO ACTION in parent table, in index PRIMARY tuple:
DATA TUPLE: 15 fields;
0: len 8; hex 0000000000003d57; asc =W;;
1: len 8; hex 0000000000000026; asc &;;
2: len 8; hex 0000000000000009; asc ;;
3: len 6; hex 00000000099b; asc ;;
4: len 7; hex 80000000000000; asc ;;
5: len 6; hex 99a7e2bc2a00; asc * ;;
6: len 4; hex b0016722; asc g";;
7: len 5; hex 8002005362; asc Sb;;
8: len 1; hex 64; asc d;;
9: len 3; hex 800000; asc ;;
10: SQL NULL;
11: len 1; hex 91; asc ;;
12: SQL NULL;
13: len 1; hex 02; asc ;;
14: SQL NULL;

But in parent table `databaseX`.`History`, in index PRIMARY,
the closest match we can find is record:
PHYSICAL RECORD: n_fields 12; compact format; info bits 0
0: len 8; hex 0000000000003d58; asc =X;;
1: len 8; hex 0000000000000001; asc ;;
2: len 6; hex 000000000000; asc ;;
3: len 7; hex 80000000000000; asc ;;
4: SQL NULL;
5: len 4; hex 80000000; asc ;;
6: len 6; hex 99a778ab6c5a; asc x lZ;;
7: len 6; hex 99a778ab6c5a; asc x lZ;;
8: len 1; hex 07; asc ;;
9: SQL NULL;
10: len 1; hex 00; asc ;;
11: len 1; hex 00; asc ;;

------------
TRANSACTIONS
------------
Trx id counter 2461
Purge done for trx's n:o < 2461 undo n:o < 0 state: running but idle
History list length 89
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 421576894288256, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421576894284040, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421576894279824, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
--------
FILE I/O
--------
I/O thread 0 state: waiting for completed aio requests (insert buffer thread)
I/O thread 1 state: waiting for completed aio requests (log thread)
I/O thread 2 state: waiting for completed aio requests (read thread)
I/O thread 3 state: waiting for completed aio requests (read thread)
I/O thread 4 state: waiting for completed aio requests (read thread)
I/O thread 5 state: waiting for completed aio requests (read thread)
I/O thread 6 state: waiting for completed aio requests (write thread)
I/O thread 7 state: waiting for completed aio requests (write thread)
I/O thread 8 state: waiting for completed aio requests (write thread)
I/O thread 9 state: waiting for completed aio requests (write thread)
Pending normal aio reads: [0, 0, 0, 0] , aio writes: [0, 0, 0, 0] ,
ibuf aio reads:, log i/o's:, sync i/o's:
Pending flushes (fsync) log: 0; buffer pool: 0
2333 OS file reads, 177 OS file writes, 34 OS fsyncs
0.00 reads/s, 0 avg bytes/read, 0.00 writes/s, 0.00 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 0, seg size 2, 0 merges
merged operations:
insert 0, delete mark 0, delete 0
discarded operations:
insert 0, delete mark 0, delete 0
Hash table size 34679, node heap has 0 buffer(s)
Hash table size 34679, node heap has 0 buffer(s)
Hash table size 34679, node heap has 0 buffer(s)
Hash table size 34679, node heap has 0 buffer(s)
Hash table size 34679, node heap has 0 buffer(s)
Hash table size 34679, node heap has 0 buffer(s)
Hash table size 34679, node heap has 1 buffer(s)
Hash table size 34679, node heap has 0 buffer(s)
0.00 hash searches/s, 0.00 non-hash searches/s
---
LOG
---
Log sequence number 999879653
Log flushed up to 999879653
Pages flushed up to 999879653
Last checkpoint at 999879644
0 pending log flushes, 0 pending chkp writes
28 log i/o's done, 0.00 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total large memory allocated 170655744
Dictionary memory allocated 205024
Buffer pool size 8192
Free buffers 5815
Database pages 2376
Old database pages 897
Modified db pages 0
Percent of dirty pages(LRU & free pages): 0.000
Max dirty pages percent: 75.000
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 2244, created 132, written 151
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 2376, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
0 read views open inside InnoDB
Process ID=28868, Main thread ID=140101274502912, state: sleeping
Number of rows inserted 0, updated 6, deleted 0, read 6
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
Number of system rows inserted 0, updated 0, deleted 0, read 0
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
============================

1 row in set (0.001 sec)

MariaDB [(none)]>

Je comprends bien qu'il y a un souci avec les FK, mais je ne peux pas modifier pour le moment la prod. J'ai passé plusieurs SKIP_ERRORS mais ce n'est pas une solution car ca ne change rien.
Quelqu'un aurait une idée ?
Merci