Skip to content

Fixes #37345: send ReindexStopUnderLoadIT's stop while the reindex is still running - #37918

Merged
mohityadav766 merged 1 commit into
mainfrom
fix/reindex-stop-under-load-warmup
Nov 17, 2026
Merged

mohityadav766 merged 1 commit into
mainfrom
fix/reindex-stop-under-load-warmup

Conversation

@mohityadav766

@mohityadav766 mohityadav766 commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Describe your changes:

Fixes #37345

ReindexStopUnderLoadIT.stopRequestTerminatesActiveReindexUnderLoad fails intermittently in the openmetadata-nightly fast tier (embedded search shard, PostgreSQL + OpenSearch, jpw.sizeFactor=0.05):

org.openmetadata.service.exception.UnhandledServerException: An exception with message [There is no job running for the application.] was thrown while processing request.
	at org.openmetadata.service.apps.scheduler.AppScheduler.stopApplicationRun(AppScheduler.java:505)
	at org.openmetadata.service.resources.apps.AppResource.lambda$stopApplicationRun$5(AppResource.java:1425)
	at java.base/java.lang.VirtualThread.run(VirtualThread.java:329)

Since #37346 scaled this test's cohort with jpw.sizeFactor, the fast tier seeds 500 tables, and the whole reindex finishes in about 6 s. The stop still went out a fixed 8 s after the test saw the run register, which is about 6.5–6.75 s after the job logs Reindexing job started. So whether the stop reached a running job was a coin flip. From the server logs of the last five fast-tier runs that executed this test:

nightly run ref stop reached the server job finished on its own result
43869847174 (11-16 12:48) 2.0 +6.69 s +6.64 s error
43782862284 (11-16 00:51) 2.0 +6.75 s +5.97 s error
43659695098 (11-15 00:44) 2.1 +6.50 s +6.33 s error
43822277036 (11-16 07:13) 2.0 +6.50 s stopped first pass
43660309950 (11-15 00:52) 2.0 +6.55 s stopped first pass

When the stop misses, POST /apps/stop still answers 200 and runs the stop on a virtual thread, which throws because no job is running. In the embedded lane the server shares the test JVM, and Awaitility (4.2.2, catchUncaughtExceptions on by default) rethrows that uncaught exception from the test's await. That's why the test errors even though it accepts success/completed, and why the trace has only server frames. The cluster lane and the nightly tier (10k tables) don't hit it. The test is identical on main, 2.1 and 2.0, and main has no scheduled fast-tier runs, so it has only shown up on the release branches so far.

The fix scales the warm-up with the cohort: 8 s at full size (the nightly tier is unchanged), with a 2 s floor. In the runs above the job started 1.25–1.5 s after the test saw the run register, so at 0.05 the stop now lands about 0.5–0.75 s into a run that takes about 6 s, leaving 5 s or more of margin.

Type of change:

  • Bug fix (test-only)

High-level design:

N/A — one-file test fix.

Tests:

Use cases covered

  • At the fast tier's jpw.sizeFactor=0.05, the stop reaches the reindex while it is still running.
  • At full size (nightly tier), the warm-up is unchanged at 8 s.

Unit tests

Not applicable: test-only change.

Backend integration tests

  • Not applicable (no backend API changes); this PR changes ReindexStopUnderLoadIT only.
  • Compiled with mvn -DskipTests install -pl :openmetadata-integration-tests -am (the nightly's build command) and test-compile at the pushed commit. Spotless is clean.
  • Not run locally. The planner's focused plan is this one class (search-it, postgres-opensearch). The local Docker VM had no memory left for a PostgreSQL + OpenSearch stack (the OpenSearch container was OOM-killed at startup), so the run was skipped. The merge queue doesn't run search-it, so the nightly fast tier is where this gets exercised.

Ingestion integration tests

Not applicable.

Playwright (UI) tests

Not applicable.

Visual regression baselines

  • Not applicable (no rendering change).

Manual testing performed

  1. Read the failing job logs of nightly runs 43869847174 and 43782862284 and the failsafe artifact of 43659695098 (all UnhandledServerException from AppScheduler.stopApplicationRun).
  2. Measured each stop against its job in the server logs (Reindexing job started vs. AppScheduler: Found matching job / No running job found and status -> COMPLETED/STOPPED), giving the table above.
  3. Checked Awaitility 4.2.2's ConditionAwaiter bytecode: an await() without .ignoreExceptions() installs itself as the default uncaught-exception handler, and defaultCatchUncaughtExceptions is true.

UI screen recording:

Not applicable — test-only change.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed. (no schema change)
  • For a UI feature or feature task: as part of PR creation, I ran the PR build in Docker with sample data and embedded a verified GitHub-hosted recording plus build/health evidence above (or explained why this requirement is not applicable). (no UI change)
  • I have added tests (unit / integration / Playwright as applicable) and listed them above. (this PR fixes a test; no new test)
  • Self-review: I reviewed the final diff against REVIEW.md (the pr-checklist skill runs it) and fixed every 🔴 finding, or answered it on the line below.
  • Decision check: if this PR decides something the next contributor could undo — a schema field, REST path or format another component or repo must agree with, a new default or limit, an ordering that must hold, or a rule stated only in this description — it adds a record under docs/decisions/ (see its README.md). This description is gone from git log after the squash-merge. (nothing to record: the warm-up's reason is in the code comment)

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 5/5

This test-only change appears safe to merge.

Summary

Updates ReindexStopUnderLoadIT to send its stop request sooner for smaller table cohorts.

  • The reindex test waits less before stopping smaller runs.

Reviews (1) · Last reviewed commit: "test(it): send ReindexStopUnderLoadIT's ..." · Reviewed by Greptile

…ll running

At the nightly fast tier's jpw.sizeFactor=0.05 the test seeds 500 tables and the whole
reindex finishes in about 6 s, but the stop went out a fixed 8 s after the run registered.
When it arrived after the job had finished, the server's async stop thread threw "There is
no job running for the application", and in the embedded lane Awaitility rethrew that
uncaught exception in the test. Scale the warm-up with the cohort: 8 s at full size as
before, and at least 2 s.
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

Comment on lines +53 to +57
// The stop has to reach a reindex that is still running, and at the fast tier's 0.05 factor
// the whole run takes about 6 s. So the warm-up scales with the cohort, with a 2 s floor that
// gives the job time to start.
private static final Duration WARMUP =
Duration.ofMillis(Math.max(2_000L, 8_000L * SEED_TABLES / FULL_SIZE_TABLES));

@gitar-bot gitar-bot Bot Nov 16, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Edge Case: Stop still races with job completion; only the timing window shrinks

The fix only moves the stop earlier: WARMUP is now max(2s, 8s*SEED_TABLES/FULL_SIZE_TABLES), which is 2 s at the 0.05 factor against a run the comment puts at about 6 s. ReindexHelpers.sendStop (ReindexHelpers.java) still POSTs /v1/apps/stop/... without handling the error, so if the run finishes before the stop arrives, the test fails with the same uncaught 'no job running' error. That can happen on a fast runner, with any SizeFactor below 0.05 (the cohort shrinks down to SizeFactor.FLOOR but the warm-up stays at 2 s), or when waitForRunStartedSince notices the start late. The assertion already allows success and completed, which shows a finished-before-stop run is expected. Right now that outcome can't get past sendStop. A sturdier fix: catch the stop failure, and if freshRunIsTerminal shows the run already ended, carry on to the status assertions instead of failing.

Tolerate a stop that arrives after the run already finished, so accepted success/completed outcomes can actually be reached:

try {
  ReindexHelpers.sendStop(server, ReindexHelpers.SEARCH_INDEX_APP);
} catch (RuntimeException stopFailure) {
  if (!ReindexHelpers.freshRunIsTerminal(
      server, ReindexHelpers.SEARCH_INDEX_APP, triggeredAt)) {
    throw stopFailure;
  }
}

Was this helpful? React with 👍 / 👎

@gitar-bot

gitar-bot Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Code Review 👍 Approved with suggestions 🟡 Medium risk 0 closed / 1 findings

Scaling the integration test’s warm-up changes when its stop request runs; a timing regression could still let reindex finish first.

Scales the ReindexStopUnderLoadIT stop warm-up with the seeded cohort size, moving the stop earlier so it lands while the reindex is still running at the fast tier's reduced size. Approved with a suggestion: the stop still races with job completion, since the 2 s floor at 0.05 leaves a short window and ReindexHelpers.sendStop does not handle a stop that arrives after the run has already finished. Consider catching the stop failure and proceeding to the status assertions when the run is already terminal.

💡 Edge Case: Stop still races with job completion; only the timing window shrinks

📄 openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/search/ReindexStopUnderLoadIT.java:53-57 📄 openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/search/ReindexStopUnderLoadIT.java:107-109 📄 openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/search/ReindexStopUnderLoadIT.java:120-122

The fix only moves the stop earlier: WARMUP is now max(2s, 8s*SEED_TABLES/FULL_SIZE_TABLES), which is 2 s at the 0.05 factor against a run the comment puts at about 6 s. ReindexHelpers.sendStop (ReindexHelpers.java) still POSTs /v1/apps/stop/... without handling the error, so if the run finishes before the stop arrives, the test fails with the same uncaught 'no job running' error. That can happen on a fast runner, with any SizeFactor below 0.05 (the cohort shrinks down to SizeFactor.FLOOR but the warm-up stays at 2 s), or when waitForRunStartedSince notices the start late. The assertion already allows success and completed, which shows a finished-before-stop run is expected. Right now that outcome can't get past sendStop. A sturdier fix: catch the stop failure, and if freshRunIsTerminal shows the run already ended, carry on to the status assertions instead of failing.

Tolerate a stop that arrives after the run already finished, so accepted success/completed outcomes can actually be reached
try {
  ReindexHelpers.sendStop(server, ReindexHelpers.SEARCH_INDEX_APP);
} catch (RuntimeException stopFailure) {
  if (!ReindexHelpers.freshRunIsTerminal(
      server, ReindexHelpers.SEARCH_INDEX_APP, triggeredAt)) {
    throw stopFailure;
  }
}
🤖 Prompt for agents
Code Review: Scales the ReindexStopUnderLoadIT stop warm-up with the seeded cohort size, moving the stop earlier so it lands while the reindex is still running at the fast tier's reduced size. Approved with a suggestion: the stop still races with job completion, since the 2 s floor at 0.05 leaves a short window and `ReindexHelpers.sendStop` does not handle a stop that arrives after the run has already finished. Consider catching the stop failure and proceeding to the status assertions when the run is already terminal.

1. 💡 Edge Case: Stop still races with job completion; only the timing window shrinks
   Files: openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/search/ReindexStopUnderLoadIT.java:53-57, openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/search/ReindexStopUnderLoadIT.java:107-109, openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/search/ReindexStopUnderLoadIT.java:120-122

   The fix only moves the stop earlier: `WARMUP` is now `max(2s, 8s*SEED_TABLES/FULL_SIZE_TABLES)`, which is 2 s at the 0.05 factor against a run the comment puts at about 6 s. `ReindexHelpers.sendStop` (ReindexHelpers.java) still POSTs `/v1/apps/stop/...` without handling the error, so if the run finishes before the stop arrives, the test fails with the same uncaught 'no job running' error. That can happen on a fast runner, with any `SizeFactor` below 0.05 (the cohort shrinks down to `SizeFactor.FLOOR` but the warm-up stays at 2 s), or when `waitForRunStartedSince` notices the start late. The assertion already allows `success` and `completed`, which shows a finished-before-stop run is expected. Right now that outcome can't get past `sendStop`. A sturdier fix: catch the stop failure, and if `freshRunIsTerminal` shows the run already ended, carry on to the status assertions instead of failing.

   Fix (Tolerate a stop that arrives after the run already finished, so accepted success/completed outcomes can actually be reached):
   try {
     ReindexHelpers.sendStop(server, ReindexHelpers.SEARCH_INDEX_APP);
   } catch (RuntimeException stopFailure) {
     if (!ReindexHelpers.freshRunIsTerminal(
         server, ReindexHelpers.SEARCH_INDEX_APP, triggeredAt)) {
       throw stopFailure;
     }
   }

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@mohityadav766 mohityadav766 added the To release Will cherry-pick this PR into the release branch label Nov 16, 2026
@mohityadav766
mohityadav766 merged commit fa2eb13 into main Nov 17, 2026
52 of 54 checks passed
@mohityadav766
mohityadav766 deleted the fix/reindex-stop-under-load-warmup branch November 17, 2026 09:09
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Backport to 2.0 is under way. It is built from openmetadata-collate, which holds the credentials needed to open a PR here, and it will comment again with the result — nothing is needed from you unless it reports otherwise.

@gh-bot-collate

Copy link
Copy Markdown

🤖 Backport to 2.0 opened as #37964 (clean cherry-pick). It merges itself once the checks pass.

mohityadav766 added a commit that referenced this pull request Nov 17, 2026
…ll running (#37918) (#37964)

At the nightly fast tier's jpw.sizeFactor=0.05 the test seeds 500 tables and the whole
reindex finishes in about 6 s, but the stop went out a fixed 8 s after the run registered.
When it arrived after the job had finished, the server's async stop thread threw "There is
no job running for the application", and in the embedded lane Awaitility rethrew that
uncaught exception in the test. Scale the warm-up with the cohort: 8 s at full size as
before, and at least 2 s.

(cherry picked from commit fa2eb13)

Co-authored-by: Mohit Yadav <105265192+mohityadav766@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

To release Will cherry-pick this PR into the release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Java IT nightly: make it green, then split it into a heavy nightly tier and a fast on-demand tier

2 participants