Skip to content

[AMORO-4457][AMS] Replace embedded Derby with H2 - #4458

Open
xxubai wants to merge 3 commits into
apache:masterfrom
xxubai:improvement/replace-ams-derby-with-h2
Open

xxubai wants to merge 3 commits into
apache:masterfrom
xxubai:improvement/replace-ams-derby-with-h2

Conversation

@xxubai

@xxubai xxubai commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Why are the changes needed?

Close #4457.

Derby is retired. Replace it with H2 as the AMS embedded database for local development and tests.

Brief change log

  • Replace AMS Derby with H2, including schema, SQL dialect and persistence/HA tests.
  • Update defaults, packaging, Helm and docs. Keep Hive/Spark dependencies unchanged.

How was this patch tested?

  • Add positive and negative persistence tests.
  • Run tests locally with Java 11: full AMS regression (1,223 cases, 19 skipped) before rebase; 164 targeted cases after rebase.
  • HA 6 cases, Helm 87 cases, distribution startup/login/restart-session smoke test and dependency manifest checks.
  • Frontend build was skipped; backend tests used temporary static resources. Screenshots are not applicable.

Documentation

  • New feature: yes.
  • Updated deployment/configuration guides and CONTRIBUTING. Existing Derby data requires manual migration.

@xxubai
xxubai force-pushed the improvement/replace-ams-derby-with-h2 branch from d1e7a73 to ccff920 Compare October 21, 2026 08:48
@xxubai
xxubai force-pushed the improvement/replace-ams-derby-with-h2 branch from ccff920 to cb2697e Compare October 21, 2026 08:51
@github-actions github-actions Bot added type:docs Improvements or additions to documentation module:ams-server Ams server module type:infra type:build labels Oct 21, 2026
@github-actions

Copy link
Copy Markdown

This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@amoro.apache.org list. Thank you for your contributions.

@github-actions github-actions Bot added the stale label Nov 21, 2026
@czy006

czy006 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Thanks — one behaviour I'd like to see fixed before merging. CI can't show it, because the tests use jdbc:h2:mem: and the process is never killed: durability of committed transactions when AMS is killed abruptly.

With the plain jdbc:h2:file:... URL, H2 delays writing to disk by roughly 0.5–1 s. A transaction whose commit() has already returned is therefore still lost if the process dies inside that window (kill -9, an OOM kill, a host crash). Derby flushed every commit and never lost a committed row in the same probe, so master does not have this window. I ran the same probe against H2 2.5.252 with the URL this PR ships, and against Derby 10.14:

JVM halted after commit() returned H2 2.5.252, plain URL Derby 10.14
immediately 20 of 20 committed rows lost 0 of 22
after 100 ms 12 of 12 lost 0 of 6
after 500 ms 9 of 12 lost 0 of 10
after 900 ms 0 of 12 lost not run
graceful exit (shutdown hooks run) 0 of 12 lost not run

So this only affects abrupt termination. ams.sh stop and SIGTERM are safe, because H2's shutdown hook flushes the store.

Could you add ;WRITE_DELAY=0 to the default URL before merging?

jdbc:h2:file:/tmp/amoro/h2/ams;WRITE_DELAY=0

With it, 0 of 16 committed rows were lost when the JVM was halted immediately after commit(), and the cost is small: a small commit goes from 0.01 ms to 0.05 ms, against 0.04 ms for Derby on the same machine. The setting has to reach every copy of the default: the database.url default in AmoroManagementConf, dist/src/main/amoro-bin/conf/config.yaml, charts/amoro/values.yaml and docs/admin-guides/deployment.md (including the example URL on line 122). docs/configuration/ams-config.md shows the default as well and will pick it up when it is regenerated.

(One limit of the check: I tested process kills, not power loss.)

@github-actions github-actions Bot removed the stale label Nov 25, 2026

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

module:ams-server Ams server module type:build type:docs Improvements or additions to documentation type:infra

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Improvement]: Replace the AMS embedded Derby database with H2

2 participants