Skip to content

Invalid default value's causing MySQL to not start #4927

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

Open
2 tasks done
gbennett-squarespace opened this issue May 7, 2025 · 2 comments
Open
2 tasks done

Invalid default value's causing MySQL to not start #4927

gbennett-squarespace opened this issue May 7, 2025 · 2 comments
Labels
defect Something isn't working in triage

Comments

@gbennett-squarespace
Copy link

gbennett-squarespace commented May 7, 2025

Current Behavior

When testing MySQL for another change, creating the DB from scratch throws errors.

From Policy.java:

    @Persistent
    @Column(name = "ONLY_LATEST_PROJECT_VERSION", defaultValue = "false")
    private boolean onlyLatestProjectVersion = false;

While most DBs handle false just fine, MySQL chokes on it. Changing to:

    @Persistent
    @Column(name = "ONLY_LATEST_PROJECT_VERSION", defaultValue = "0")
    private boolean onlyLatestProjectVersion = false;

Should correctly build the database for all 5 DB types (this hasn't been tested yet....).

APIKEY IS_LEGACY

2025-05-07 17:51:12,179 ERROR [Datastore] Error thrown executing CREATE TABLE "APIKEY"
2025-05-07T17:51:12.181410000Z (
2025-05-07T17:51:12.181475000Z     "ID" BIGINT NOT NULL AUTO_INCREMENT,
2025-05-07T17:51:12.181881000Z     "COMMENT" VARCHAR(255) BINARY NULL,
2025-05-07T17:51:12.182054000Z     "CREATED" TIMESTAMP NULL,
2025-05-07T17:51:12.182261000Z     "IS_LEGACY" BIT NOT NULL DEFAULT 'false',
2025-05-07T17:51:12.182344000Z     "LAST_USED" TIMESTAMP NULL,
2025-05-07T17:51:12.182436000Z     "PUBLIC_ID" VARCHAR(8) BINARY NULL,
2025-05-07T17:51:12.182514000Z     "SECRET_HASH" VARCHAR(64) BINARY NULL,
2025-05-07T17:51:12.182541000Z     CONSTRAINT "APIKEY_PK" PRIMARY KEY ("ID")
2025-05-07T17:51:12.182595000Z ) ENGINE=INNODB : Invalid default value for 'IS_LEGACY'
2025-05-07T17:51:12.182629000Z java.sql.SQLSyntaxErrorException: Invalid default value for 'IS_LEGACY'

This one is odd because the only reference I see to this is in the upgrade script v4130_1Updater.java.

This one is a bit more complicated, removing the upgrade script (and references to it) allows MySQL to finish building the database and start succesfully.

Steps to Reproduce

Start up DT with MySQL.

Using MySQL 5.7.

Env Vars:

ALPINE_DATABASE_DRIVER=com.mysql.cj.jdbc.Driver;
ALPINE_DATABASE_MODE=external;
ALPINE_DATABASE_PASSWORD=admin;
ALPINE_DATABASE_URL=jdbc:mysql://host.docker.internal:3306/dtrack?autoReconnect\=true&useSSL\=false&sessionVariables\=sql_mode\='ANSI_QUOTES,STRICT_TRANS_TABLES,ONLY_FULL_GROUP_BY,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
ALPINE_DATABASE_USERNAME=user;
LOGGING_LEVEL=DEBUG

Expected Behavior

MySQL based DB starts without issue.

Dependency-Track Version

4.13.x

Dependency-Track Distribution

Container Image

Database Server

MySQL

Database Server Version

5.7

Browser

N/A

Checklist

@gbennett-squarespace gbennett-squarespace added defect Something isn't working in triage labels May 7, 2025
@gbennett-squarespace gbennett-squarespace changed the title Invalid default value for 'ONLY_LATEST_PROJECT_VERSION' Invalid default value's causing MySQL to not start May 7, 2025
@valentijnscholten
Copy link
Contributor

Did you also try a newer DT version? 4.7.x is over two years old. I know it might not make a difference, but the docs also state MySQL is not really recommended: https://docs.dependencytrack.org/getting-started/database-support/. More to troubles are reported in #271 (comment) Considering the future of DT will probably only support Postgres it might be worth migrating to that.

@gbennett-squarespace
Copy link
Author

Sorry, this is my error. I'm running the most recent version of DT.

It may not be worth fixing if MySQL is on the short end, but since it's currently listed as supported (and I believe both of the things I ran into are fairly recent changes) I figured I'd mention it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect Something isn't working in triage
Projects
None yet
Development

No branches or pull requests

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy