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

java.lang.ArrayIndexOutOfBoundsException: Index -1 for SQL rollback #3060

Open
hlinus opened this issue Jul 13, 2022 · 4 comments
Open

java.lang.ArrayIndexOutOfBoundsException: Index -1 for SQL rollback #3060

hlinus opened this issue Jul 13, 2022 · 4 comments

Comments

@hlinus
Copy link

hlinus commented Jul 13, 2022

Environment

Liquibase Version:
4.9.1

Liquibase Integration & Version: gradle/spring

Liquibase Extension(s) & Version:

Database Vendor & Version:
Oracle DB 19.3

Operating System Type & Version:
Linux x64

Steps To Reproduce

We are applying our change set multiple times a day and two times we saw an ArrayIndexOutOfBoundsException when applying our change sets. My estimate it happens only 1 out of a couple of 100 times applying. Since the issue occurred recently I think it is related to the latest SQL rollback or liquibase upgrade. Our latest SQL rollback looks similar to:

<rollback>
    UPDATE ${database.defaultSchemaName}.tbl_tablename SET column = NULL WHERE other_column = 'value';
</rollback>

Actual Behavior

Caused by: liquibase.exception.ChangeLogParseException: liquibase.exception.UnexpectedLiquibaseException: java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 152
	at liquibase.parser.core.xml.AbstractChangeLogParser.parse(AbstractChangeLogParser.java:25) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.changelog.DatabaseChangeLog.include(DatabaseChangeLog.java:587) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.changelog.DatabaseChangeLog.handleChildNode(DatabaseChangeLog.java:363) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.changelog.DatabaseChangeLog.load(DatabaseChangeLog.java:318) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.parser.core.xml.AbstractChangeLogParser.parse(AbstractChangeLogParser.java:23) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.Liquibase.getDatabaseChangeLog(Liquibase.java:369) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.Liquibase.lambda$update$1(Liquibase.java:224) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.Scope.lambda$child$0(Scope.java:180) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.Scope.child(Scope.java:189) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.Scope.child(Scope.java:179) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.Scope.child(Scope.java:158) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.Liquibase.runInScope(Liquibase.java:2405) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.Liquibase.update(Liquibase.java:211) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.Liquibase.update(Liquibase.java:197) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:314) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:269) ~[liquibase-core-4.9.1.jar:?]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[spring-beans-5.3.20.jar:5.3.20]
	... 110 more
Caused by: liquibase.exception.UnexpectedLiquibaseException: java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 152
	at liquibase.util.SqlParser.parse(SqlParser.java:44) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.util.StringUtil.processMultiLineSQL(StringUtil.java:64) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.changelog.ChangeSet.handleRollbackNode(ChangeSet.java:497) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.changelog.ChangeSet.handleChildNode(ChangeSet.java:381) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.changelog.ChangeSet.load(ChangeSet.java:374) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.changelog.DatabaseChangeLog.createChangeSet(DatabaseChangeLog.java:628) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.changelog.DatabaseChangeLog.handleChildNode(DatabaseChangeLog.java:350) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.changelog.DatabaseChangeLog.load(DatabaseChangeLog.java:318) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.parser.core.xml.AbstractChangeLogParser.parse(AbstractChangeLogParser.java:23) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.changelog.DatabaseChangeLog.include(DatabaseChangeLog.java:587) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.changelog.DatabaseChangeLog.handleChildNode(DatabaseChangeLog.java:363) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.changelog.DatabaseChangeLog.load(DatabaseChangeLog.java:318) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.parser.core.xml.AbstractChangeLogParser.parse(AbstractChangeLogParser.java:23) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.Liquibase.getDatabaseChangeLog(Liquibase.java:369) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.Liquibase.lambda$update$1(Liquibase.java:224) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.Scope.lambda$child$0(Scope.java:180) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.Scope.child(Scope.java:189) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.Scope.child(Scope.java:179) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.Scope.child(Scope.java:158) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.Liquibase.runInScope(Liquibase.java:2405) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.Liquibase.update(Liquibase.java:211) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.Liquibase.update(Liquibase.java:197) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:314) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:269) ~[liquibase-core-4.9.1.jar:?]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[spring-beans-5.3.20.jar:5.3.20]
	... 110 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 152
	at liquibase.util.grammar.SimpleSqlGrammarTokenManager.jjMoveNfa_0(SimpleSqlGrammarTokenManager.java:320) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.util.grammar.SimpleSqlGrammarTokenManager.jjMoveStringLiteralDfa0_0(SimpleSqlGrammarTokenManager.java:14) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.util.grammar.SimpleSqlGrammarTokenManager.getNextToken(SimpleSqlGrammarTokenManager.java:1351) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.util.grammar.SimpleSqlGrammar.getNextToken(SimpleSqlGrammar.java:109) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.util.SqlParser.parse(SqlParser.java:40) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.util.StringUtil.processMultiLineSQL(StringUtil.java:64) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.changelog.ChangeSet.handleRollbackNode(ChangeSet.java:497) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.changelog.ChangeSet.handleChildNode(ChangeSet.java:381) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.changelog.ChangeSet.load(ChangeSet.java:374) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.changelog.DatabaseChangeLog.createChangeSet(DatabaseChangeLog.java:628) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.changelog.DatabaseChangeLog.handleChildNode(DatabaseChangeLog.java:350) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.changelog.DatabaseChangeLog.load(DatabaseChangeLog.java:318) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.parser.core.xml.AbstractChangeLogParser.parse(AbstractChangeLogParser.java:23) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.changelog.DatabaseChangeLog.include(DatabaseChangeLog.java:587) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.changelog.DatabaseChangeLog.handleChildNode(DatabaseChangeLog.java:363) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.changelog.DatabaseChangeLog.load(DatabaseChangeLog.java:318) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.parser.core.xml.AbstractChangeLogParser.parse(AbstractChangeLogParser.java:23) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.Liquibase.getDatabaseChangeLog(Liquibase.java:369) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.Liquibase.lambda$update$1(Liquibase.java:224) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.Scope.lambda$child$0(Scope.java:180) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.Scope.child(Scope.java:189) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.Scope.child(Scope.java:179) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.Scope.child(Scope.java:158) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.Liquibase.runInScope(Liquibase.java:2405) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.Liquibase.update(Liquibase.java:211) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.Liquibase.update(Liquibase.java:197) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:314) ~[liquibase-core-4.9.1.jar:?]
	at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:269) ~[liquibase-core-4.9.1.jar:?]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[spring-beans-5.3.20.jar:5.3.20]
	... 110 more

Expected/Desired Behavior

No ArrayIndexOutOfBoundsException

@milosonator
Copy link

Seen this happen in an integration test using H2 database, although the error seems to happen before any actual DB interactions happen.

Caused by: liquibase.exception.SetupException: liquibase.exception.UnexpectedLiquibaseException: java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 152
	at liquibase.changelog.DatabaseChangeLog.handleChildNode(DatabaseChangeLog.java:371)
	at liquibase.changelog.DatabaseChangeLog.load(DatabaseChangeLog.java:318)
	at liquibase.parser.core.xml.AbstractChangeLogParser.parse(AbstractChangeLogParser.java:23)
	... 116 more
Caused by: liquibase.exception.ChangeLogParseException: liquibase.exception.UnexpectedLiquibaseException: java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 152
	at liquibase.parser.core.xml.AbstractChangeLogParser.parse(AbstractChangeLogParser.java:25)
	at liquibase.changelog.DatabaseChangeLog.include(DatabaseChangeLog.java:587)
	at liquibase.changelog.DatabaseChangeLog.handleChildNode(DatabaseChangeLog.java:363)
	... 118 more
Caused by: liquibase.exception.UnexpectedLiquibaseException: java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 152
	at liquibase.util.SqlParser.parse(SqlParser.java:44)
	at liquibase.util.StringUtil.processMultiLineSQL(StringUtil.java:64)
	at liquibase.changelog.ChangeSet.handleRollbackNode(ChangeSet.java:497)
	at liquibase.changelog.ChangeSet.handleChildNode(ChangeSet.java:381)
	at liquibase.changelog.ChangeSet.load(ChangeSet.java:374)
	at liquibase.changelog.DatabaseChangeLog.createChangeSet(DatabaseChangeLog.java:628)
	at liquibase.changelog.DatabaseChangeLog.handleChildNode(DatabaseChangeLog.java:350)
	at liquibase.changelog.DatabaseChangeLog.load(DatabaseChangeLog.java:318)
	at liquibase.parser.core.xml.AbstractChangeLogParser.parse(AbstractChangeLogParser.java:23)
	... 120 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 152
	at liquibase.util.grammar.SimpleSqlGrammarTokenManager.jjMoveNfa_0(SimpleSqlGrammarTokenManager.java:320)
	at liquibase.util.grammar.SimpleSqlGrammarTokenManager.jjMoveStringLiteralDfa0_0(SimpleSqlGrammarTokenManager.java:14)
	at liquibase.util.grammar.SimpleSqlGrammarTokenManager.getNextToken(SimpleSqlGrammarTokenManager.java:1351)
	at liquibase.util.grammar.SimpleSqlGrammar.getNextToken(SimpleSqlGrammar.java:109)
	at liquibase.util.SqlParser.parse(SqlParser.java:40)
	... 128 more

@tati-qalified
Copy link
Contributor

Hello @hlinus, sorry for the late response.
We have identified the source of the issue and we'll be updating the code to fix it.
Thank you for letting us know!
Tatiana

@filipelautert
Copy link
Collaborator

Hello @hlinus @milosonator - does this issue still happens with liquibase 4.23.1 ?

@milosonator
Copy link

Hi @filipelautert thank you for your reply. We are currently still on an older version. Since this does not happen very often, it's not easy for us to test. Seems to have not or barely happened the last couple of months.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In Discussion
Development

Successfully merging a pull request may close this issue.

6 participants