Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[0.8.1.RELEASE] TiDB数据库环境下choerodon-tool-liquibase 执行groovy脚本连接断开 #10

Open
mm20140616 opened this issue Dec 18, 2018 · 5 comments

Comments

@mm20140616
Copy link

TiDB 数据库环境下使用choerodon-tool-liquibase执行groovy 脚本时会报出连接断开的错误。

liquibase.exception.LockException: liquibase.exception.UnexpectedLiquibaseException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.

根据报错信息发现问题是liquibase.lockservice.StandardLockService#init方法在数据库中生成的databasechangeloglock表中LOCKEDbit类型,liquibase.lockservice.StandardLockService#acquireLock方法在获取锁时会将该字段改为1TiDBbit类型更新为1时会发生错误2013 - Lost connection to MySQL server during query(应该是TiDB的BUG)。 在liquibase 官方文档中标注的LOCKEDint类型。但是代码并不是int类型,可以通过覆盖文件liquibase.sqlgenerator.core.CreateDatabaseChangeLogLockTableGenerator#generateSql修改字段类型来解决这个问题。

@superlee007
Copy link
Contributor

可以提一个pull request

@mm20140616
Copy link
Author

这个问题只要将那个问题修改一下再重新发版就好了,修改liquibase-core的源码即可,choerodon-tool-liquibase代码没有变化。

@devane001
Copy link
Contributor

@zhaoxiaoyu19951122 你好,你可以通过向TIDB 提issue 来解决这个问题。Choerodon 使用的liquibase 会与官方保持一致。尽量不在liquibase的官方依赖上做修改。

@winkyao
Copy link

winkyao commented Dec 20, 2018

@zhaoxiaoyu19951122 Hi, 我是 TiDB 的开发者,请问能提供以下报错的语句以及 Schema 吗?以及通过 select tidb_version() 看一下版本?

@mm20140616
Copy link
Author

@winkyao 问题原因:在执行更新语句时,bit数据类型的字段的值无法更新为1。建表语句如下:

SET FOREIGN_KEY_CHECKS=0;
DROP TABLE IF EXISTS `DATABASECHANGELOGLOCK`;
CREATE TABLE `DATABASECHANGELOGLOCK` (
  `ID` int(11) NOT NULL,
  `LOCKED` bit(1) NOT NULL,
  `LOCKGRANTED` datetime DEFAULT NULL,
  `LOCKEDBY` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
INSERT INTO `DATABASECHANGELOGLOCK` VALUES ('1', '', null, null);

更新语句如下:

UPDATE DATABASECHANGELOGLOCK SET LOCKED=1 WHERE ID=1 AND LOCKED=0

执行select tidb_version()获取的数据库版本如下:

Release Version: None
Git Commit Hash: 508f5dd6263e4896d53fb37af99f3a1b747de713
Git Branch: master
UTC Build Time: 2018-10-27 09:59:28
GoVersion: go version go1.11 linux/amd64
Race Enabled: false
TiKV Min Version: 2.1.0-alpha.1-ff3dd160846b7d1aed9079c389fc188f7f5ea13e
Check Table Before Drop: false

抛出异常如下:

[SQL] UPDATE DATABASECHANGELOGLOCK SET LOCKED=1 WHERE ID=1 AND LOCKED=0
[Err] 2013 - Lost connection to MySQL server during query

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants