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

cacheSize of createSequence is ignored #2147

Closed
mickroll opened this issue Oct 14, 2021 · 5 comments · Fixed by #2270
Closed

cacheSize of createSequence is ignored #2147

mickroll opened this issue Oct 14, 2021 · 5 comments · Fixed by #2270
Assignees
Labels
BKeyPlatform Key Platform DBMariaDB good first issue This issue is an easy starter project for new contributors. ImpactLow IntegrationAny Severity3 TypeBug
Milestone

Comments

@mickroll
Copy link

mickroll commented Oct 14, 2021

Environment

Liquibase Version: 4.4.3

Liquibase Integration & Version: quarkus 2.3.0.Final

Liquibase Extension(s) & Version: liquibase-core only

Database Vendor & Version: MariaDB 10.6.4

Operating System Type & Version: Windows 10

Description

The Attribute cacheSize of createSequence seems to be ignored.

Steps To Reproduce

Run the following changesets:

    <changeSet id="working" author="mickroll">
        <createSequence sequenceName="SEQ_WORKING"
                            startValue="10000000"
                            incrementBy="1" />
        <sql dbms="mysql,mariadb">ALTER SEQUENCE SEQ_WORKING CACHE=5;</sql>
    </changeSet>
    <changeSet id="attribute" author="mickroll">
        <createSequence sequenceName="SEQ_SET"
                            startValue="10000000"
                            incrementBy="1"
                            cacheSize="5" />
    </changeSet>
    <changeSet id="default" author="mickroll">
        <createSequence sequenceName="SEQ_DEFAULT"
                            startValue="10000000"
                            incrementBy="1" />
    </changeSet>
  • changeset working shows the wanted end result
  • changeset attribute shows usage of createSequence cacheSize (which will be ignored)
  • changeset default shows the default value of cacheSize (as defined by the database, i guess)

Now run the following SQL on the database to extract the results (or view the created sequences in the db client of our choice):

SELECT (SELECT cache_size FROM SEQ_WORKING) AS "working",
       (SELECT cache_size FROM SEQ_SET) AS "set with attribute",
       (SELECT cache_size FROM SEQ_DEFAULT) AS "default";

Actual Behavior

  • working = 5 (as expected)
  • set with attribute = 1000 (bug)
  • default = 1000 (shows default value)

Expected/Desired Behavior

  • set with attribute = 5 (as defined by the attribute cacheSize of createSequence tag)

Screenshots (if appropriate)

grafik

Additional Context

Doesn't work, either: <alterSequence sequenceName="SEQ_SET" cacheSize="5"/>

┆Issue is synchronized with this Jira Story by Unito

@molivasdat
Copy link
Contributor

HI @mickroll Thanks for creating this issue and notifying us about it. We will add this to the list of issues that we are processing. If you have a PR with a fix for this, that would be great.

@molivasdat molivasdat added this to To Do in Conditioning++ via automation Oct 19, 2021
@molivasdat molivasdat added BKeyPlatform Key Platform DBMariaDB good first issue This issue is an easy starter project for new contributors. ImpactLow IntegrationAny Severity3 TypeBug labels Oct 19, 2021
@mickroll
Copy link
Author

mickroll commented Nov 16, 2021

A colleague of mine (@tkalmar) just wrote that he may have located the bug:

if (database instanceof OracleDatabase || database instanceof Db2zDatabase || database instanceof PostgresDatabase) {

see https://github.com/liquibase/liquibase/blob/master/liquibase-core/src/main/java/liquibase/sqlgenerator/core/CreateSequenceGenerator.java#L95

-->MariaDB is ignored here

Btw. CYCLE is also ignored for MariaDB:
https://github.com/liquibase/liquibase/blob/master/liquibase-core/src/main/java/liquibase/sqlgenerator/core/CreateSequenceGenerator.java#L117
But it seems to be supported: https://mariadb.com/kb/en/create-sequence/

CREATE [OR REPLACE] [TEMPORARY] SEQUENCE [IF NOT EXISTS] sequence_name
[ INCREMENT [ BY | = ] increment ]
[ MINVALUE [=] minvalue | NO MINVALUE | NOMINVALUE ]
[ MAXVALUE [=] maxvalue | NO MAXVALUE | NOMAXVALUE ]
[ START [ WITH | = ] start ] 
[ CACHE [=] cache | NOCACHE ] [ CYCLE | NOCYCLE] 
[table_options]

Same goes for AlterSequence: https://github.com/liquibase/liquibase/blob/master/liquibase-core/src/main/java/liquibase/sqlgenerator/core/AlterSequenceGenerator.java#L75

@mickroll
Copy link
Author

mickroll commented Nov 16, 2021

Having the first deeper look at this repository, I have a bit of a hard time reading and understanding this part of the code, but shouldn't polling boolean AbstractJdbcDatabase#supportsSequences() be the right way to go, instead of those instanceof-chains? Or having more sequence-related methods like boolean AbstractJdbcDatabase#supportsSequenceCache() and boolean AbstractJdbcDatabase#supportsSequenceCycle()

@nvoxland
Copy link
Contributor

It may be better to have more function checks like that vs instanceof. The trouble is that there is sort of an unlimited variation in what features are supported and not supported across the databases and also we hit variations in the SQL to generate depending on the database as well.

We're looking at some refactoring to make that all work better, but it's a medium-term project. In the meantime, I opened a PR that handles it the current way.

@nvoxland nvoxland moved this from To Do to Code Review in Conditioning++ Dec 13, 2021
@mickroll
Copy link
Author

Thank you!

@nvoxland nvoxland moved this from Code Review to Ready for Handoff (In JIRA) in Conditioning++ Dec 20, 2021
Conditioning++ automation moved this from Ready for Handoff (In JIRA) to Done Jan 10, 2022
@nvoxland nvoxland removed this from Done in Conditioning++ Jan 21, 2022
@nvoxland nvoxland added this to the v4.7.1 milestone Jan 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BKeyPlatform Key Platform DBMariaDB good first issue This issue is an easy starter project for new contributors. ImpactLow IntegrationAny Severity3 TypeBug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants