为什么SELECT语句会导致MySQL上的元数据锁定?

时间:2018-11-29 10:39:11

标签: mysql

为什么以下MySQL语句会导致特定表(T_DCE)上的元数据锁定?

SELECT M_COUNTRY.ICAO,
  M_DOCUMENTTYPE.DocumentType,
  T_DCE_CHECKS.CheckResult_ID
FROM T_DC 
  INNER JOIN M_COUNTRY 
    ON T_DC.ONationality_ID=M_COUNTRY.ID
  INNER JOIN M_DOCUMENTTYPE
    ON T_DC.ODocumentType_ID=M_DOCUMENTTYPE.ID 
  INNER JOIN T_DCE
    ON T_DC.ID=T_DCE.T_DC_ID
    AND T_DC.Date=T_DCE.Date
  INNER JOIN T_DCE_CHECKS
    ON T_DCE.ID=T_DCE_CHECKS.T_DCE_ID
    AND T_DCE.Date= T_DCE_CHECKS.Date  
WHERE (T_DC.Date BETWEEN '2017-01-01' AND '2018-12-31')
   AND M_COUNTRY.ICAO IN ( 'ALB', 'ARE')
   AND T_DCE_CHECKS.CheckResult_ID='57'
GROUP BY M_COUNTRY.ICAO, M_DOCUMENTTYPE.DocumentType
ORDER BY M_COUNTRY.ICAO, M_DOCUMENTTYPE.DocumentType
;

要获取有关导致元数据锁定的语句的信息,我使用了this blog post on percona中提到的过程。

Process(es) that have the metadata lock:
PID 5612772 has metadata lock on MySchema.T_DCE with current state [Sending data] for 81055 seconds and is currently running
[SELECT M_COUNTRY.ICAO, M_DOCUMENT...

我不确定我是否正确阅读了文档,但是仅当我明确使用LOCK TABLE或DDL / DML语句时,才不会发生表锁定吗?

系统环境:

  • 操作系统:CentOS 7.5.1804 x64
  • 数据库:MySQL Community Server 8.0.13
  • 引擎:InnoDB
  • 复制:具有3个成员的MySQL组复制(1个r / w,2个只读,与此问题相关的所有内容都在r / w节点上)

0 个答案:

没有答案