Skip to content

feat: introduce a new sql module - #1867

Open
0utplay wants to merge 22 commits into
nightlyfrom
feat/sql-module
Open

0utplay wants to merge 22 commits into
nightlyfrom
feat/sql-module

Conversation

@0utplay

@0utplay 0utplay commented Aug 7, 2026

Copy link
Copy Markdown
Member

Motivation

Currently we only support mariadb and mysql, while we could support more sql based databases. Using jooq we can achieve this support with a single implementation.

Modification

Removed the mysql module and replaced it with a generic sql module.

Result

Postgres, MariaDB, MySQL, SQLite are now supported

@0utplay
0utplay requested a lite review from Copilot August 7, 2026 18:41
@0utplay 0utplay self-assigned this Aug 7, 2026
@0utplay 0utplay added v: 4.X This pull should be included in the 4.0 release in: module An issue/pull request releated to one of the internal modules labels Aug 7, 2026
@github-actions

github-actions Bot commented Aug 7, 2026 •

Copy link
Copy Markdown

Test Results

   60 files  + 2     60 suites  +2   3m 26s ⏱️ +6s
  713 tests +20    713 ✅ +20  0 💤 ±0  0 ❌ ±0 
1 088 runs  +20  1 088 ✅ +20  0 💤 ±0  0 ❌ ±0 

Results for commit e0d058e. ± Comparison against base commit 202ea8a.

This pull request removes 45 and adds 65 tests. Note that renamed tests count towards both.
eu.cloudnetservice.driver.impl.document.DocumentSerialisationTest ‑ [4] {"b":1,"s":2,"i":3,"l":4,"f":5.0,"d":6.0,"c":"/","string":"Hello, World!","bol":true,"cloud":["Ben?","Yes","No","HoHoHoHo"],"world":{"this":"is","insane":"!","hello":"world"}}, PRETTY
eu.cloudnetservice.driver.impl.document.gson.JavaTimeSerializerTest ‑ [14] 2026-11-20
eu.cloudnetservice.driver.impl.document.gson.JavaTimeSerializerTest ‑ [23] 20:53:16.296685910
eu.cloudnetservice.driver.impl.document.gson.JavaTimeSerializerTest ‑ [28] 20:53:16.296784496Z
eu.cloudnetservice.driver.impl.document.gson.JavaTimeSerializerTest ‑ [29] 20:53:16.296802092Z
eu.cloudnetservice.driver.impl.document.gson.JavaTimeSerializerTest ‑ [30] 20:53:16.296808953+05:00
eu.cloudnetservice.driver.impl.document.gson.JavaTimeSerializerTest ‑ [31] 20:53:16.296828892-03:00
eu.cloudnetservice.driver.impl.document.gson.JavaTimeSerializerTest ‑ [34] 2026-11-20T20:53:16.296958635
eu.cloudnetservice.driver.impl.document.gson.JavaTimeSerializerTest ‑ [39] 2026-11-20T20:53:16.297082569Z
eu.cloudnetservice.driver.impl.document.gson.JavaTimeSerializerTest ‑ [4] 2026-11-20T20:53:16.287295067Z
…
eu.cloudnetservice.driver.impl.document.DocumentSerialisationTest ‑ [4] {"b":1,"s":2,"i":3,"l":4,"f":5.0,"d":6.0,"c":"/","string":"Hello, World!","bol":true,"cloud":["Ben?","Yes","No","HoHoHoHo"],"world":{"insane":"!","hello":"world","this":"is"}}, PRETTY
eu.cloudnetservice.driver.impl.document.gson.JavaTimeSerializerTest ‑ [14] 2026-11-22
eu.cloudnetservice.driver.impl.document.gson.JavaTimeSerializerTest ‑ [23] 14:46:07.835008458
eu.cloudnetservice.driver.impl.document.gson.JavaTimeSerializerTest ‑ [28] 14:46:07.835086300Z
eu.cloudnetservice.driver.impl.document.gson.JavaTimeSerializerTest ‑ [29] 14:46:07.835099825Z
eu.cloudnetservice.driver.impl.document.gson.JavaTimeSerializerTest ‑ [30] 14:46:07.835105495+05:00
eu.cloudnetservice.driver.impl.document.gson.JavaTimeSerializerTest ‑ [31] 14:46:07.835123050-03:00
eu.cloudnetservice.driver.impl.document.gson.JavaTimeSerializerTest ‑ [34] 2026-11-22T14:46:07.835225740
eu.cloudnetservice.driver.impl.document.gson.JavaTimeSerializerTest ‑ [39] 2026-11-22T14:46:07.835313282Z
eu.cloudnetservice.driver.impl.document.gson.JavaTimeSerializerTest ‑ [4] 2026-11-22T14:46:07.832710503Z
…

♻️ This comment has been updated with latest results.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR replaces the dedicated MySQL database module with a new generic SQL module powered by jOOQ/HikariCP to support multiple SQL backends (MySQL, MariaDB, PostgreSQL, SQLite), and adjusts the core database APIs/providers accordingly.

Changes:

  • Replace database-mysql with database-sql and introduce a jOOQ-based provider/database implementation.
  • Extend the database provider API with synced() and update provider implementations accordingly.
  • Add SQL module configuration/types plus a new cross-database test suite (SQLite + Testcontainers for MySQL/MariaDB/Postgres).

Reviewed changes

Copilot reviewed 39 out of 41 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
settings.gradle.kts Switches the registered database module from database-mysql to database-sql.
node/impl/src/main/java/eu/cloudnetservice/node/impl/database/xodus/XodusDatabaseProvider.java Implements new synced() API for Xodus provider.
node/impl/src/main/java/eu/cloudnetservice/node/impl/database/xodus/XodusDatabase.java Removes now-deleted LocalDatabase.iterate(BiConsumer) override.
node/impl/src/main/java/eu/cloudnetservice/node/impl/database/sql/SQLDatabaseProvider.java Removes deprecated legacy SQL provider abstraction.
node/impl/src/main/java/eu/cloudnetservice/node/impl/database/h2/H2DatabaseProvider.java Refactors H2 provider to no longer depend on removed legacy SQL provider; adds synced().
node/impl/src/main/java/eu/cloudnetservice/node/impl/database/h2/H2Database.java Moves H2 database implementation onto shared AbstractDatabase; removes old iterate override.
node/api/src/main/java/eu/cloudnetservice/node/database/LocalDatabase.java Removes iterate(BiConsumer) from the LocalDatabase API.
modules/database-sql/impl/src/test/resources/logback-test.xml Adds test logback configuration for SQL module tests.
modules/database-sql/impl/src/test/java/eu/cloudnetservice/modules/sql/impl/SQLiteDatabaseTest.java Adds SQLite variant of the SQL database test suite.
modules/database-sql/impl/src/test/java/eu/cloudnetservice/modules/sql/impl/SQLDatabaseTest.java Adds shared behavior tests for SQL providers/databases.
modules/database-sql/impl/src/test/java/eu/cloudnetservice/modules/sql/impl/PostgreSQLDatabaseTest.java Adds Postgres Testcontainers-based test wiring.
modules/database-sql/impl/src/test/java/eu/cloudnetservice/modules/sql/impl/MySQLDBDatabaseTest.java Adds MySQL Testcontainers-based test wiring.
modules/database-sql/impl/src/test/java/eu/cloudnetservice/modules/sql/impl/MariaDBDatabaseTest.java Adds MariaDB Testcontainers-based test wiring.
modules/database-sql/impl/src/test/java/eu/cloudnetservice/modules/sql/impl/junit/EnableServicesInjectExtension.java Renames test extension package from mysql to sql module namespace.
modules/database-sql/impl/src/test/java/eu/cloudnetservice/modules/sql/impl/junit/EnableServicesInject.java Renames test annotation package from mysql to sql module namespace.
modules/database-sql/impl/src/main/java/eu/cloudnetservice/modules/sql/impl/table/TableCreator.java Introduces abstraction to create per-dialect tables via jOOQ.
modules/database-sql/impl/src/main/java/eu/cloudnetservice/modules/sql/impl/table/SQLiteTableCreator.java Implements SQLite-specific table creation.
modules/database-sql/impl/src/main/java/eu/cloudnetservice/modules/sql/impl/table/PostgreSQLTableCreator.java Implements Postgres-specific table creation (currently contains a compile-breaking incomplete statement).
modules/database-sql/impl/src/main/java/eu/cloudnetservice/modules/sql/impl/table/MySQLTableCreator.java Implements MySQL-specific table creation.
modules/database-sql/impl/src/main/java/eu/cloudnetservice/modules/sql/impl/table/MariaDBTableCreator.java Implements MariaDB-specific table creation.
modules/database-sql/impl/src/main/java/eu/cloudnetservice/modules/sql/impl/JooqProvider.java Adds the new SQL provider implementation (currently bypasses provider cache).
modules/database-sql/impl/src/main/java/eu/cloudnetservice/modules/sql/impl/JooqDatabaseType.java Adds dialect/driver mapping for supported SQL backends.
modules/database-sql/impl/src/main/java/eu/cloudnetservice/modules/sql/impl/JooqDatabase.java Adds new jOOQ-backed database implementation (currently uses HashMap.newHashMap).
modules/database-sql/impl/src/main/java/eu/cloudnetservice/modules/sql/impl/DocumentConverter.java Adds JSONB↔Document conversion for jOOQ mapping.
modules/database-sql/impl/src/main/java/eu/cloudnetservice/modules/sql/impl/CloudNetSQLDatabaseModule.java Registers SQL database providers from module configuration; contains legacy config conversion.
modules/database-sql/impl/build.gradle.kts Updates dependencies/artifact/module metadata for new SQL module (main class currently mismatched).
modules/database-sql/api/src/main/java/eu/cloudnetservice/modules/sql/config/SQLModuleConfiguration.java Introduces SQL module configuration record (list of entries).
modules/database-sql/api/src/main/java/eu/cloudnetservice/modules/sql/config/SQLConfigurationEntry.java Introduces per-provider SQL config entry and JDBC URI builder (currently not SQLite-safe without override).
modules/database-sql/api/src/main/java/eu/cloudnetservice/modules/sql/config/DatabaseType.java Adds enum for supported SQL backends.
modules/database-sql/api/build.gradle.kts Adds API module build definition for the SQL module.
modules/database-mysql/impl/src/test/java/eu/cloudnetservice/modules/mysql/impl/MySQLDatabaseTest.java Removes old MySQL module tests.
modules/database-mysql/impl/src/main/java/eu/cloudnetservice/modules/mysql/impl/MySQLDatabaseProvider.java Removes old MySQL provider implementation.
modules/database-mysql/impl/src/main/java/eu/cloudnetservice/modules/mysql/impl/MySQLDatabase.java Removes old MySQL database implementation.
modules/database-mysql/impl/src/main/java/eu/cloudnetservice/modules/mysql/impl/CloudNetMySQLDatabaseModule.java Removes old MySQL module entrypoint.
modules/database-mysql/api/src/main/java/eu/cloudnetservice/modules/mysql/config/MySQLConfiguration.java Removes old MySQL module configuration type.
modules/database-mongodb/impl/src/main/java/eu/cloudnetservice/modules/mongodb/impl/MongoDBDatabaseProvider.java Implements new synced() API for MongoDB provider.
modules/database-mongodb/impl/src/main/java/eu/cloudnetservice/modules/mongodb/impl/MongoDBDatabase.java Removes now-deleted LocalDatabase.iterate(BiConsumer) override.
gradle/libs.versions.toml Adds jOOQ + additional JDBC drivers; replaces mysql bundle with a new sql bundle.
driver/api/src/main/java/eu/cloudnetservice/driver/database/DatabaseProvider.java Adds synced() API to DatabaseProvider.
driver/api/src/main/java/eu/cloudnetservice/driver/database/Database.java Contains a new malformed/duplicated Javadoc opening near documentCountAsync().
build-extensions/src/main/kotlin/eu/cloudnetservice/cloudnet/gradle/util/Files.kt Renames database module artifact constant from mysql to sql; removes unused constants.
Suppressed comments (1)

modules/database-sql/impl/build.gradle.kts:42

  • The module descriptor points to a main class that doesn't exist in this PR. The implementation class added is CloudNetSQLDatabaseModule, so the module won't load at runtime with the current value.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@0utplay
0utplay requested a balanced review from Copilot August 7, 2026 18:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@0utplay
0utplay requested a balanced review from Copilot August 7, 2026 18:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@DasBabyPixel

Copy link
Copy Markdown
Contributor

A request of mine is to add failure resistance to the connection. If the node boots before the database does, it currently just completely crashes (without ending the process) and the node is in a broken state until it is manually restarted.
I don't know if restarting the database causes issues, in that case the node should detect the connection ending and reconnect when available again.

Data consistency is a concern here, if the underlying data in the database changes that's life and shit will break, but as long as it's just a short connection outage (or database update), the entire server shouldn't break.

@0utplay

0utplay commented Aug 14, 2026

Copy link
Copy Markdown
Member Author

A request of mine is to add failure resistance to the connection. If the node boots before the database does, it currently just completely crashes (without ending the process) and the node is in a broken state until it is manually restarted.

whats your suggestion here? I guess letting the node boot up would be wrong, a controlled stop should be the best I from my point of view

@DasBabyPixel

Copy link
Copy Markdown
Contributor

My suggestion is retries for a specified timeout, after that timeout controlled stop. The node should survive parallel startup with the database as well as database restarts/updates. (As long as the database restarts in a timely manner, 1min or something like that)

@0utplay
0utplay marked this pull request as ready for review November 3, 2026 20:17

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in: module An issue/pull request releated to one of the internal modules v: 4.X This pull should be included in the 4.0 release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants