오르다 보면 언젠가는 정상에 다다르게 된다.

AWS

AWS RDS에서 information_schema.innodb_sys_tables에 테이블이 존재하지만 information_schema.tables에 없는 경우

Looplian 2025. 5. 12. 14:50
반응형

 

MySQL 5.0 버전대가 AWS 에서 지원 종료하다 보니 8.0 대로 업그래이드 해야 하는 이슈가 있었다.

기존에 다른 서비스 들은 문제 없이 잘 업그래이드 됐는데 한 서비스가 업그래이드가 되지않아 문제 였다.

PrePatchCompatibility.log 에 업그래이드 실패에 관한 오류 사항들이 기재되어 확인후 처리하면되었는데

19번 체크사항 때문에 업그래이드가 불가한 상태였다.

아래는 그 원본 메세지.

19) Schema inconsistencies resulting from file removal or corruption
The following tables show signs that either the datadir directory or the frm file
was removed or corrupted. If MySQL encounters this issue, it will write messages 
to the error logs, which you can check to understand the issue. These tables are 
considered orphan tables because the respective table data is present in the InnoDB 
data dictionary but is missing from the MySQL data dictionary. Contact AWS Premium 
Support for assistance in dropping the tables from the DB instance. In your case, 
include the table schema if available, and your consent to drop the tables. 
In some cases, this operation requires a database restart. 
If applicable, also include a timeline during which the restart can be performed. 
Quick note: If you have automated backups enabled, restore the backups to recover 
the table contents.
mydb.#sql-bda_26e - present in INFORMATION_SCHEMA's INNODB_SYS_TABLES table 
but missing from TABLES table
 

이게 5.0 버전대에서 ALTER 메뉴로 테이블 구조를 변경하든가 할때 생기는 임시 파일인가 그런데 제대로 처리되지 않고 종료 되면 삭제가 안되나 보다.

검색에서 안나오더니 AWS 에 문의 하라는 내용이 나와 있기는했다.

Aurora MySQL에 대한 사전 확인 설명 참조 - Amazon Aurora

Aurora MySQL 업그레이드 사전 확인에 대해 알아봅니다.

docs.aws.amazon.com

내용 중 "파일 제거 또는 손상으로 인한 스키마 불일치"

이게 암만 삭제를 할려고 해도 삭제가 안되고 "DROP TABLE mydb.`#sql-bda_26e`"

테이블을 생성하려 했더니 테이블이 이미 존재한다고 생성도 안된다.

조금더 찾아 보니 이런 파일이 생기는 Orphan Table이라고 한다.

 

결국, AWS 에 문의..

친절하게 mysql 문서 링크와 처리 방법을 보내주셨다.

https://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting-datadict.html#innodb-orphan-temporary-tables

MySQL :: MySQL 5.7 Reference Manual :: 14.22.3 Troubleshooting InnoDB Data Dictionary Operations

Information about table definitions is stored both in the .frm files, and in the InnoDB data dictionary . If you move .frm files around, or if the server crashes in the middle of a data dictionary operation, these sources of information can become inconsistent. If a data dictionary...

dev.mysql.com

역시.. 다 해결 방법이 있었구나.. 내 검색 실력이 부족했던걸로....

 

 

해결 방법 ~

우선 위와같이 삭제가 안된 테이블이 있는지 검색을 한다.

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE "%#sql%";
 

그다음 해당 테이블을 아래와 같이 "#mysql50#" 접미사를 붙어 테이블명 쓸때 쓰는 백틱(`) 으로 감싸 삭제 한다.

mysql> DROP TABLE `mydb`.`#mysql50##sql-bda_26e`;
 

그러면 문제가 되던 테이블이 삭제가 된다.

 

 

 

 

반응형