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

LockException when using cluster mode #23

Open
gustavlarson opened this issue Dec 6, 2022 · 0 comments
Open

LockException when using cluster mode #23

gustavlarson opened this issue Dec 6, 2022 · 0 comments

Comments

@gustavlarson
Copy link

When running using cluster mode and clickhouse-jdbc 0.3.2-patch11 I consistently see the following exception in the log:

2022-12-05 16:51:31.847 ERROR 68398 --- [           main] liquibase                                : Could not release lock

liquibase.exception.LockException: liquibase.exception.LockException: Did not update change log lock correctly.

-1 rows were updated instead of the expected 1 row using executor liquibase.executor.jvm.JdbcExecutor there are 1 rows in the table
	at liquibase.lockservice.StandardLockService.releaseLock(StandardLockService.java:394) ~[liquibase-core-4.17.1.jar:na]
	at liquibase.Liquibase.lambda$update$1(Liquibase.java:306) ~[liquibase-core-4.17.1.jar:na]
	at liquibase.Scope.lambda$child$0(Scope.java:180) ~[liquibase-core-4.17.1.jar:na]
	at liquibase.Scope.child(Scope.java:189) ~[liquibase-core-4.17.1.jar:na]
	at liquibase.Scope.child(Scope.java:179) ~[liquibase-core-4.17.1.jar:na]
	at liquibase.Scope.child(Scope.java:158) ~[liquibase-core-4.17.1.jar:na]
	at liquibase.Liquibase.runInScope(Liquibase.java:2447) ~[liquibase-core-4.17.1.jar:na]
	at liquibase.Liquibase.update(Liquibase.java:236) ~[liquibase-core-4.17.1.jar:na]
	at liquibase.Liquibase.update(Liquibase.java:221) ~[liquibase-core-4.17.1.jar:na]
	at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:328) ~[liquibase-core-4.17.1.jar:na]
	at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:283) ~[liquibase-core-4.17.1.jar:na]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) ~[spring-beans-5.3.23.jar:5.3.23]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[spring-beans-5.3.23.jar:5.3.23]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.23.jar:5.3.23]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.23.jar:5.3.23]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.23.jar:5.3.23]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.23.jar:5.3.23]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.23.jar:5.3.23]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.23.jar:5.3.23]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955) ~[spring-beans-5.3.23.jar:5.3.23]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.23.jar:5.3.23]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.23.jar:5.3.23]
	at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:66) ~[spring-boot-2.7.5.jar:2.7.5]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) ~[spring-boot-2.7.5.jar:2.7.5]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) ~[spring-boot-2.7.5.jar:2.7.5]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring-boot-2.7.5.jar:2.7.5]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[spring-boot-2.7.5.jar:2.7.5]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~[spring-boot-2.7.5.jar:2.7.5]
	...
Caused by: liquibase.exception.LockException: Did not update change log lock correctly.

I suspect that this is due to the ALTER TABLE UPDATE mutation is running asynchronously. In order for the query to return the number of affected rows the mutations_sync setting needs to be 1 or 2: https://clickhouse.com/docs/en/operations/settings/settings/#mutations_sync

I think that the best solution would be to add this setting in the SQL query. Will soon prepare a PR.

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

1 participant