Skip to content

[fix]Fix issues such as index failure#3953

Merged
zqr10159 merged 14 commits into
apache:masterfrom
Duansg:fix-index
Jan 18, 2026
Merged

[fix]Fix issues such as index failure#3953
zqr10159 merged 14 commits into
apache:masterfrom
Duansg:fix-index

Conversation

@Duansg

@Duansg Duansg commented Jan 8, 2026

Copy link
Copy Markdown
Member

What's changed?

  1. In the current version, although index configurations have been defined, certain issues prevent the indexes from taking effect. Enabling log output will reveal numerous error messages, such as:
Internal Exception: java.sql.SQLSyntaxErrorException: Key column 'alertDefineId' doesn't exist in table
Error Code: 1072
Call: CREATE INDEX index_alert_define_monitor ON hzb_alert_define_monitor_bind (alertDefineId)
---
Internal Exception: java.sql.SQLSyntaxErrorException: Duplicate key name 'index_alert_define_monitor'
Error Code: 1061
Call: CREATE INDEX index_alert_define_monitor ON hzb_alert_define_monitor_bind (monitor_id)
  1. After reinitializing the project, the non-primary key indexes do not comply with the current project settings. The list is as follows:
image
  1. After analyzing the issues statistically, the following problems were identified:

    Issues Index
    Index conflict hzb_history
    hzb_monitor
    hzb_push_metrics
    hzb_alert_define_monitor_bind
    hzb_collector_monitor_bind
    hzb_status_page_incident_component_bind
    Column name specification exception hzb_param
    hzb_push_metrics
    hzb_monitor_bind
    hzb_plugin_param
    hzb_alert_define_monitor_bind
    Unique constraint violation exception hzb_param

Modification details

  1. Adjust index naming settings to ensure compatibility with different databases.
  2. Added Flyway migration scripts to ensure compatibility with both initialization and upgrades.
  3. Added integration tests and passed them successfully.
  4. Verified index consistency for H2/MySQL/PostgreSQL during initialization or upgrade scenarios.

Checklist

  • I have read the Contributing Guide
  • I have written the necessary doc or comment.
  • I have added the necessary unit tests and all cases have passed.

Add or update API

  • I have added the necessary e2e tests and all cases have passed.

H2 Before

h2_before

H2 After

h2_after

MySQL Before

mysql_before

MySQL After

mysql_after

PostgreSQL Before

PostgreSQL_ before

PostgreSQL After

PostgreSQL_ after

@Duansg Duansg requested review from leo-934 and tomsun28 and removed request for tomsun28 January 8, 2026 11:55
@apache apache deleted a comment from DanielCarter-stack Jan 13, 2026
@apache apache deleted a comment from DanielCarter-stack Jan 13, 2026
@tomsun28

Copy link
Copy Markdown
Member

Please wait after the 1.8.0 release.

@zqr10159

Copy link
Copy Markdown
Member

Please wait after the 1.8.0 release.

Due to other bugs, 1.8.0-RC2 has been discontinued. Should we consider merging this PR?

@zqr10159 zqr10159 merged commit 6c0d5c0 into apache:master Jan 18, 2026
3 of 4 checks passed
@tomsun28

Copy link
Copy Markdown
Member

this pr contains the hertzbeat-startup/src/main/resources/db/migration/h2/V181__update_indexes.sql updates. suggest move them into v180 @Duansg @zqr10159

@Duansg

Duansg commented Jan 19, 2026

Copy link
Copy Markdown
Member Author

this pr contains the hertzbeat-startup/src/main/resources/db/migration/h2/V181__update_indexes.sql updates. suggest move them into v180 @Duansg @zqr10159

@tomsun28 Got it, thanks, i will handle it later ~

@Duansg Duansg deleted the fix-index branch January 20, 2026 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants