Skip to content

perf(admin): index operation log queries (#6675) - #7404

Merged
Aias00 merged 3 commits into
apache:masterfrom
sunnysabor:perf/6675-operation-record-log-index
Oct 17, 2026
Merged

Aias00 merged 3 commits into
apache:masterfrom
sunnysabor:perf/6675-operation-record-log-index

Conversation

@sunnysabor

@sunnysabor sunnysabor commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Description

Add the missing operation-time and operator/time indexes to Oracle and the shared PostgreSQL/openGauss initialization schema, plus the OceanBase, openGauss, Oracle, and PostgreSQL 2.7.1-to-2.7.2 upgrade scripts. OceanBase now reuses the MySQL initialization schema, which already contains both indexes. This keeps time-range and username-filtered operation-log queries indexed across these databases.

Rebased onto master at 1d599d90e; preserve the initialization consolidation from #7529/#7530 instead of restoring the deleted OceanBase/openGauss files. Oracle uses the shorter idx_operation_log_oper_time name for the 30-byte identifier limit. Query, pagination, API behavior, and leading-wildcard context search are unchanged. Related issue: #6675.

Validation

  • python3 .github/scripts/test-native-sql-matrix.py — 31 tests passed (script/unit checks, not native database execution).
  • python3 .github/scripts/test-agent-gateway-migrations.py — 11 tests passed.
  • ./mvnw -B -ntp -N validate — passed, 0 Checkstyle violations (root project only).
  • Checked exactly one definition of each operation-log index in the three applicable initialization schemas and five upgrade scripts; Oracle names fit within 30 bytes.
  • git diff --check upstream/master...HEAD passed; complete branch diff contains six SQL files and no Markdown.
  • Native database DDL execution and full Maven reactor were not run locally for this SQL-only conflict resolution. New-head hosted checks are pending.

@sunnysabor

Copy link
Copy Markdown
Contributor Author

CI follow-up: pr_build failed after the 101-test shenyu-client-core suite hit HeartbeatFailureIsolationTest.failureDoesNotSuppressOtherUrisOrSubsequentTicks (NoSuchElement at line 57). This failure is unrelated to the SQL files in this PR and is the known heartbeat-test regression tracked by #7401; I reproduced it on clean upstream/master earlier, and #7402 contains the focused test fix (its module run passed all 101 tests and its triggered CI was green). The other checks relevant so far, including license headers, agent-gateway migration checks, and Docker image build, pass. Database-storage E2E and integration jobs are still pending; I will report those separately when they finish.

@sunnysabor

Copy link
Copy Markdown
Contributor Author

Storage E2E follow-up for the previous head (ed056c8): the PostgreSQL and openGauss storage Compose jobs completed successfully, exercising startup against the changed initialization schemas. H2 and MySQL jobs were cancelled when the Oracle identifier-name follow-up was pushed; I expect the current-head workflow to rerun them. These jobs validate initialization, not the 2.7.1-to-2.7.2 upgrade scripts. The Oracle composite index name has since been shortened to 27 bytes for compatibility with Oracle configurations whose COMPATIBLE setting is below 12.2.

@sunnysabor

Copy link
Copy Markdown
Contributor Author

Follow-up on the current-head CI run: pr_build again fails only at the known unrelated HeartbeatFailureIsolationTest.failureDoesNotSuppressOtherUrisOrSubsequentTicks (NoSuchElementException, line 57) in shenyu-client-core. The exact failing job is run 36885871577; the workflow summary gate fails because of that job. The Kubernetes Gateway API integration passed. HTTP integration and Docker image build are still running, so I will report their results when complete.

@sunnysabor

Copy link
Copy Markdown
Contributor Author

HTTP integration follow-up: the current-head shenyu-integrated-test-http job passed (run 36885871665, 11m37s), as did the Kubernetes Gateway API integration job. The Docker image build is the only remaining active workflow; pr_build remains blocked by the unrelated heartbeat test failure documented above.

@sunnysabor

Copy link
Copy Markdown
Contributor Author

Storage E2E update for the current head: Docker image build passed, and H2, MySQL, and openGauss storage jobs passed. PostgreSQL storage E2E is still running. These jobs exercise initialization/startup schemas; they do not execute the 2.7.1-to-2.7.2 upgrade scripts. The HTTP and Kubernetes Gateway API integration jobs are also green.

@sunnysabor

Copy link
Copy Markdown
Contributor Author

Final storage matrix update for the current head: PostgreSQL storage E2E passed as well. The complete changed-initialization-schema matrix is now green for H2, MySQL, PostgreSQL, and openGauss; Docker image build, HTTP integration, and Kubernetes Gateway API integration also passed. The only failing required check remains pr_build, due to the unrelated heartbeat test documented above. The upgrade DDL itself is still not exercised by these storage startup jobs.

@sunnysabor

Copy link
Copy Markdown
Contributor Author

Could a maintainer review the portability and scope of this change on head dc06b14a? It adds the two existing H2/MySQL operation-log indexes to OceanBase, openGauss, Oracle, and PostgreSQL initialization plus 2.7.1→2.7.2 upgrade DDL; Oracle uses a shorter identifier for pre-12.2 compatibility. Current-head startup E2E passed for H2, MySQL, PostgreSQL, and openGauss, and HTTP/Kubernetes integration plus Docker build passed. The upgrade scripts themselves were not executed locally or by those startup jobs. I would especially value feedback on dialect conventions and whether the migration coverage is appropriate.

Aias00
Aias00 previously approved these changes Oct 2, 2026

@Aias00 Aias00 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This brings OceanBase / OpenGauss / Oracle / PostgreSQL to parity with MySQL, which already had both indexes (db/init/mysql/schema.sql:2879-2880 and db/upgrade/2.7.1-upgrade-2.7.2-mysql.sql). I checked all five db/init dialects plus the four 2.7.1-upgrade-2.7.2-* scripts: after this change every dialect declares an index on operation_time and a composite on (operator, operation_time), so this is parity work rather than a partial migration. Good to see init and upgrade scripts kept in step — an index that exists only in db/init silently does not exist for anyone who upgrades.

Two details worth calling out because they look wrong and aren't:

  • The Oracle composite is named idx_operation_log_oper_time while the others use idx_operation_log_operator_time. That is intentional: the full name is 31 characters and Oracle <= 12.1 caps identifiers at 30. Please add a short comment so nobody "fixes" it later.
  • OceanBase declares the indexes inline in CREATE TABLE, og/pg use standalone CREATE INDEX after the PK constraint, and Oracle uses lowercase create index — each matches how its own file is written.

Nit: operation_record_log is append-only and (operator, operation_time) already leads with operation_time for the per-operator case, so both indexes are justified only if the admin actually lists recent operations across all operators. If it does, keep both; if not, the composite alone covers it and you save write cost on a hot table.

Aias00
Aias00 previously approved these changes Oct 8, 2026

@Aias00 Aias00 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed current head 6ccd107c30f2.

The PR adds operation_record_log indexes for the dialects missing them and keeps Oracle index names within its identifier limit. MySQL already contains the same logical indexes in init and upgrade scripts at head.

Validation: init/upgrade SQL reviewed across dialects; native database execution was not run locally.

GitHub still reports failing checks: build (shenyu-integrated-test-http), rat_check, pr_build. This review does not claim those checks have passed.

@Aias00

Aias00 commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Hi @sunnysabor, this PR currently has merge conflicts with the master base branch, so CI cannot validate it against the latest code. Please rebase/merge the latest master and resolve the conflicts, then push the updated branch. Once the conflicts are cleared, CI will re-run automatically and we can continue the review. Thanks!

@sunnysabor

Copy link
Copy Markdown
Contributor Author

Resolved the conflicts and rebased onto current master 971354fef; updated head is 78a5db772.

The conflicts came from #7529/#7530 removing the separate OceanBase/openGauss initialization files. I kept those deletions: OceanBase inherits the existing MySQL indexes, while openGauss inherits the PostgreSQL indexes added here. All four dialect-specific upgrade scripts retain the index additions; Oracle retains the short name and explanatory comment.

Validation: 29 native-SQL-matrix script tests and 11 migration script tests passed; root Maven validate/Checkstyle passed; index-definition/Oracle identifier checks and git diff --check passed. These are static/script checks, not native database DDL execution. The branch diff is now six SQL files. Fresh hosted CI still needs to complete.

@sunnysabor
sunnysabor force-pushed the perf/6675-operation-record-log-index branch from 6ccd107 to 78a5db7 Compare October 14, 2026 14:52
@sunnysabor
sunnysabor force-pushed the perf/6675-operation-record-log-index branch from 78a5db7 to b860917 Compare October 15, 2026 14:21
@sunnysabor

Copy link
Copy Markdown
Contributor Author

Rebased again onto current master 1d599d9; the new head is b860917. The new conflicts were at the upgrade-script append points: I preserved upstream data_permission deduplication/unique-index migrations and retained this PR's operation-log indexes, including the Oracle-compatible identifier. The complete branch diff remains six SQL files with no Markdown.

Validation: 31 native-SQL-matrix script unit tests and 11 migration script tests pass; root Maven validate reports zero Checkstyle violations; git diff --check passes. These script tests are not native database execution.

I also inspected the previous head's failed openGauss storage job: https://github.com/apache/shenyu/actions/runs/38584449453/job/115990129091 . Compose reports shenyu-admin unhealthy; Admin fails during integrationDataSourceInitializer startup, with CannotGetJdbcConnectionException -> org.opengauss.util.PSQLException -> EOFException. The database log includes successful CREATE INDEX output, with no SQL ERROR/FATAL shown. This establishes the observed startup/connection failure, not a proven transient-infrastructure root cause or a passing E2E run. The rebased head will receive fresh hosted checks.

@Aias00 Aias00 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Summary

Addresses #6675. This PR adds missing indexes on operation_record_log(operation_time) and operation_record_log(operator, operation_time) across the Oracle and shared PostgreSQL/openGauss initialization schemas, plus the OceanBase, openGauss, Oracle, and PostgreSQL 2.7.1→2.7.2 upgrade scripts. This keeps time-range and username-filtered operation-log queries indexed on every supported database. OceanBase reuses the MySQL initialization schema, which already contained both indexes (verified at db/init/mysql/schema.sql:2477-2478), so only its upgrade path needs the new statements.

What the change does

  • db/init/oracle/schema.sql:422,424 — create index idx_operation_log_time and create index idx_operation_log_oper_time (the shorter name respects Oracle's 30-byte identifier limit).
  • db/init/pg/create-table.sql:2066,2067 — CREATE INDEX "idx_operation_log_time" and "idx_operation_log_operator_time" (shared PG/openGauss init).
  • db/upgrade/2.7.1-upgrade-2.7.2-ob.sql:91,92 — ALTER TABLE operation_record_log ADD INDEX (MySQL syntax, for OceanBase).
  • db/upgrade/2.7.1-upgrade-2.7.2-og.sql:91,92, ...-oracle.sql:105,107, ...-pg.sql:91,92 — matching index additions in each DB's dialect.

Verification

  • Compared all six changed files at head (b86091708f934aa652b1ae9daebc3362dc511256) against master.
  • grep idx_operation_log across both head and master confirms the new index names appear only in the head version; no duplicate index name already exists in any target file (so no re-creation conflict within the scripts).
  • Table/column existence confirmed against the master schemas:
    • Oracle operation_record_log: operator VARCHAR2(200) not null, operation_time timestamp(3) not null (db/init/oracle/schema.sql:404-405).
    • PG operation_record_log: "operator" varchar(200) NOT NULL, "operation_time" timestamp(6) NOT NULL (db/init/pg/create-table.sql:406-407).
    • The column lists in every new CREATE INDEX/ALTER TABLE ADD INDEX match these definitions exactly.
  • Premise check: db/init/mysql/schema.sql:2477-2478 (the schema OceanBase reuses) already defines idx_operation_log_time and idx_operation_log_operator_time, so the OB init path is covered and only the OB upgrade script was needed.
  • CI: 28 successful, 0 failing on all relevant checks including native-sql-matrix/*, agent_gateway_migrations, pr_build, check-license-header, rat_check, registry_dependencies, build (shenyu-integrated-test-*) builds. The only pending jobs are infra-level (build_local_repo, compat_java21, test_group, e2e-case aggregator) — none red.

Notes (non-blocking)

  • The CREATE INDEX/ALTER TABLE ADD INDEX statements are unconditional. On a fresh init/upgrade they are correct; re-running an init script against an already-initialized database (or a partial upgrade) would raise a duplicate-index error. This matches the existing convention in these scripts (e.g., idx_meta_data_namespace_path added unconditionally in the same blocks), so it is consistent rather than a new defect.
  • Index naming diverges by dialect (idx_operation_log_oper_time for Oracle vs idx_operation_log_operator_time elsewhere) purely for Oracle's 30-byte limit, as documented in the inline comment — intentional and correct.

Conclusion

APPROVE. The change is a correct, well-scoped SQL-only performance improvement, verified against master schemas, with all relevant CI green and no duplicate-index or column-name issues.

@Aias00
Aias00 merged commit cd00ac4 into apache:master Oct 17, 2026
33 checks passed
@Aias00 Aias00 added this to the 2.7.2 milestone Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants