I am installing MariaD 10.3.9. It is a new installation on Windows Server 2016. There are no errors during installations or even in any java application which is using MariaDb database. But I observed an error in Windows event viewer and the error was
'Failed to load slave replication state from table mysql.gtid_slave_pos: 1932: Table 'mysql.gtid_slave_pos' doesn't exist in engine'
I tried to access this table via HeidiSql and found that there are 4 system tables which are not accessible:
mysql.transaction_registry
mysql.gtid_slave_pos
mysql.innodb_index_stats
mysql.innodb_table_stats
MariaDb installation is not using replication. I was able to fix the problem after removing .frm and .ibd files of above mentioned tables and then run mysql_upgrade. But this is not the solution for me. I need to know why these system tables are getting corrupt? This issue is reproducible with every new installation. However in upgrade use case (I tried installing same MariaDb version with pre-existing mysql_data folder), the issue was not reproducible. I found a MariaDb bug mentioned for similar issue:
https://jira.mariadb.org/browse/MDEV-5965?jql=text%20~%20%22innodb_index_stats%22
But the use case in the issue is entirely different.
I also found following logs in MariaDb err log file:
2023-03-07 11:26:21 0 [Note] InnoDB: The first innodb_system data file 'ibdata1' did not exist. A new tablespace will be created!
2023-03-07 11:26:21 0 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions
2023-03-07 11:26:21 0 [Note] InnoDB: Uses event mutexes
2023-03-07 11:26:21 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2023-03-07 11:26:21 0 [Note] InnoDB: Number of pools: 1
2023-03-07 11:26:21 0 [Note] InnoDB: Using SSE2 crc32 instructions
2023-03-07 11:26:21 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2023-03-07 11:26:21 0 [Note] InnoDB: Completed initialization of buffer pool
2023-03-07 11:26:21 0 [Note] InnoDB: Setting file '.\ibdata1' size to 12 MB. Physically writing the file full; Please wait ...
2023-03-07 11:26:21 0 [Note] InnoDB: File '.\ibdata1' size is now 12 MB.
2023-03-07 11:26:21 0 [Note] InnoDB: Setting log file .\ib_logfile101 size to 50331648 bytes
2023-03-07 11:26:21 0 [Note] InnoDB: Setting log file .\ib_logfile1 size to 50331648 bytes
2023-03-07 11:26:21 0 [Note] InnoDB: Renaming log file .\ib_logfile101 to .\ib_logfile0
2023-03-07 11:26:21 0 [Note] InnoDB: New log files created, LSN=45786
2023-03-07 11:26:21 0 [Note] InnoDB: Doublewrite buffer not found: creating new
2023-03-07 11:26:21 0 [Note] InnoDB: Doublewrite buffer created
2023-03-07 11:26:21 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
2023-03-07 11:26:21 0 [Note] InnoDB: Creating foreign key constraint system tables.
2023-03-07 11:26:21 0 [Note] InnoDB: Creating tablespace and datafile system tables.
2023-03-07 11:26:21 0 [Note] InnoDB: Creating sys_virtual system tables.
2023-03-07 11:26:21 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2023-03-07 11:26:21 0 [Note] InnoDB: Setting file '.\ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2023-03-07 11:26:21 0 [Note] InnoDB: File '.\ibtmp1' size is now 12 MB.
2023-03-07 11:26:21 0 [Note] InnoDB: Waiting for purge to start
2023-03-07 11:26:21 0 [Note] InnoDB: 10.3.9 started; log sequence number 0; transaction id 7
I think the issue is somehow to do with ibdata1 file because this file is not missing from mysql_data folder when MariaDb is installed. And only tables with .idb file getting corrupted. But I am not sure. Any help, I need to know the root cause of this issue. Thanks