Skip to content

Improve distributed reindex speed and fix bugs - #25758

Merged
mohityadav766 merged 40 commits into
mainfrom
faster-distributed-index
Feb 9, 2026
Merged

mohityadav766 merged 40 commits into
mainfrom
faster-distributed-index

Conversation

@mohityadav766

@mohityadav766 mohityadav766 commented Feb 9, 2026 •

Copy link
Copy Markdown
Member

Improve distributed reindex speed and fix bugs

Describe your changes:

Fixes

I worked on ... because ...

Type of change:

  • Bug fix
  • Improvement
  • New feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • 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.

Summary by Gitar

  • Performance optimization:
    • Reduced bulk flush interval from 5s to 1s in ElasticSearchBulkSink.java and OpenSearchBulkSink.java for faster batch processing
    • Increased initial batch size from 5 to 100 entities in SearchIndexExecutor.java with more aggressive tuning thresholds
  • Fixed index recreation bug:
    • Added canonical index cleanup in DefaultRecreateHandler.java before alias attachment to prevent conflicts
  • Batch processing improvements:
    • Pre-calculated document size estimation with BULK_OPERATION_METADATA_OVERHEAD constant to avoid redundant calculations
    • Cached entity counts in PaginatedEntitiesSource.java and PaginatedEntityTimeSeriesSource.java to eliminate repeated database queries
  • Cluster configuration:
    • Updated conservative batch size recommendations across all entity tiers in SearchClusterMetrics.java (increased from 50-300 to 100-500)

This will update automatically on new commits.


sonika-shah and others added 8 commits February 9, 2026 12:00
)

When using the K8s pipeline client with useOMJobOperator=false, scheduled
pipelines (CronJobs) were failing because pipelineRunId was set to the
literal string "{{ omjob.uid }}" instead of a valid UUID.

This template syntax is designed for the OMJob operator to resolve at
runtime, but standard K8s CronJobs have no templating engine.

The fix uses the Kubernetes Downward API to inject the pod's own UID
(metadata.uid) as the pipelineRunId. Pod UIDs are valid UUIDv4 values
and unique per execution, making them suitable replacements.

Co-authored-by: Claude Opus 4.5 <[email protected]>
* Rename deny list recognizer

* Update generated TypeScript types

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
* refactor: replace testCaseResultSummary with lastResultTimestamp in ES index

* feat: add lean batch SQL queries for test suite result summaries

* fix: recompute related test suite results on pipeline completion

* test: update UI sort field and tests for lastResultTimestamp
* Initial plan

* Revert MUITagSuggestion changes from PR #25588

Co-authored-by: karanh37 <[email protected]>

* Revert test file changes from PR #25588

Co-authored-by: karanh37 <[email protected]>

* fix test

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: karanh37 <[email protected]>
Co-authored-by: karanh37 <[email protected]>
…25627)

* Flatten Custom Properties

* Fix UI Side

* Fix Reindex matching old index conflict with alias

* Hacky wacky

* Review comments

* Add tests for custom properties to check field don't exceed

* Change to nested

* Align tests

* Fix Column and DataModel and subassets customProperties

* Fix extension updates

* Fix Description Updates

* Temp fix from other PR

* Fix Test failures

* Fix Review comments

* Fix Tests for playwright
* Batched Import

* Batched Import

* Batched Import

* Optimised Internal methods for adding relationships for import, fixed circular dependency, generated changeEvents (#25582)

* Fix tag clearing and circular dependency detection in batch CSV imports

  - **Tag clearing fix**: Add deleteTagsByTarget before applying new tags in batch imports to match single entity import behavior, ensuring empty CSV fields properly clear existing
   tags
  - **Circular dependency detection fix**: Pre-track entities in dryRunCreatedEntities before parent resolution to enable proper circular reference validation during CSV team
  imports
  - Resolves test failures in TeamResourceIT.test_importCsv_circularDependency_trueRun and tag-related import issues
  - Maintains batch import performance while restoring pre-batch-import validation contracts

* improve storeRelationshipsInternal internal methods - make them truly batched operations

* - Add storeEntities override to all repositories (57 repos)
-  Add batch lock check to HierarchicalLockManager
- Add batch cache write to EntityRepository
-  Fix createManyEntitiesForImport with batched operations
- Fix updateManyEntitiesForImport with batched operations
-  Add change event creation in flushPendingEntityOperations

---------

Co-authored-by: sonika-shah <[email protected]>

* have default implementation of storeEntities

* add batch relationship clearing while updating during import

* Fix column import failing for tables in same batch

 When importing CSV with batching, column rows failed to find their
  parent table because the table was queued but not yet persisted to DB.
  Added pendingEntityFQNs set to track entities in current batch. When
  processing columns, check if table is in this set - if so, add columns
  directly to the queued table object instead of creating a patch context.
  This ensures columns are persisted with the table in a single operation.

* fix UserResourceTest, TestCaseResourceIT

* Fix Circular Dependency Validation for GlossaryTerms

* Batch Insert ChangeEvents and Process Async

* fix: defer CSV result reporting until batch operations complete to ensure accuracy

* fix: ensure custom properties persist during batch CSV imports

* Fix rows processed count

* Fix: Moving of glossaryTerms to correctly detect update operation during import

* Increment version history

* fix TeamResourceTest

* Fix: Mutual Exclusivity Tag Validation during dry run, Deferring of failures

* Fix: Table Constraints Preservation on table import

* revert validateCsvString logic, needed for csv validation

* revert test changes

* Use dependency resolution to flush pending operations to find the parent

* fix search groping based on entityType in updateEntitiesBulk with tests

* Fetch original from db as cache takes some time to reload

* Test Cases

* Remove logs, fix TableResourceIT, Fix ChangeEvent Race Condition

---------

Co-authored-by: Ram Narayan Balaji <[email protected]>
Co-authored-by: sonika-shah <[email protected]>
Co-authored-by: Ram Narayan Balaji <[email protected]>
Co-authored-by: Karan Hotchandani <[email protected]>
Co-authored-by: karanh37 <[email protected]>
@gitar-bot

gitar-bot Bot commented Feb 9, 2026 •

Copy link
Copy Markdown
🔍 CI failure analysis for a681c9f: Maven build and Test Report jobs show 6 DataProductResourceTest failures that were already FIXED in intermediate commits. Current persistent issues: 7 Python Trino tests (entities not in search indexes) + frontend custom property search/indexing issues.

Issue

UPDATE: DataProductResourceTest failures (6 tests) were FIXED in intermediate commits. Current CI failures show 7 persistent Python Trino tests + frontend custom property issues remain.

Root Cause

Maven Build and Test Report Jobs - ALREADY FIXED

Jobs: maven-sonarcloud-ci (62970601913) and Test Report (62997052210)

6 DataProductResourceTest failures (FIXED in later commits):

  1. testDataProductBulkOutputPorts - Expected success, got failure
  2. testGetPortsByNameEndpoints - Expected 1 port, got 0
  3. testGetPortsViewEndpoint - Expected 1 port, got 0
  4. testGetOutputPortsReturnsFullEntities - Expected 1 port, got 0
  5. testDataProductDomainMigrationWithInputOutputPorts - Wrong domain after migration
  6. testDataProductBulkPortsViaApi - HTTP 400 error during bulk operation

Status: These failures were already analyzed in previous CI runs and confirmed FIXED in intermediate commits. The CI jobs are running on commit a681c9f which is before the fixes were applied.


Backend Python Integration Test Failures (PERSISTENT - RELATED TO PR)

Job: py-run-tests (3.10) - 62970601963

Results: 3,715 unit tests passed ✅, 7 integration test errors ❌

7 Failed Tests (ALL Trino Classifier):

  • test_auto_classification_workflow[{database_service}.minio.my_schema.*] (7 table variants)

Error: WorkflowExecutionError: Sampler reported errors

Root Cause:

Could not fetch database entity for [docker_test_trino0.minio.my_schema.*] from Search Indexes.
The search index may not be available or the entity has not been indexed yet.
Please ensure the Elasticsearch index is properly configured and try reindexing.

Affected Tables:

  • complex_and_simple, empty, iris, only_complex, table, titanic, userdata

Why This Is Related to PR:

  • Tests expect entities to be available in Elasticsearch search indexes
  • Entities are not found during profiler workflow Sampler step
  • Same 7 tests failing across multiple runs with identical error
  • Suggests distributed search indexing changes have not properly indexed these entities

Frontend Shard 4/6 - Custom Property Search/Indexing Issues (PERSISTENT - POSSIBLY RELATED TO PR)

Job: playwright-ci-postgresql shard 4/6 (62970601620)

Results: 645 tests: 630 passed, 1 failed, 14 flaky (97.7% pass rate)

1 Persistent Failure:

  • CustomPropertyAdvanceSeach.spec.ts:77:9 - "String CP with all operators"
    • Test applies custom property filter in advanced search
    • Dashboard card not found in search results
    • expect(locator).toBeVisible() failed
    • Search not returning expected results

14 Flaky Tests:

  • Advanced Search (3 flaky): Time CP, Timestamp CP - dashboard cards not appearing in search results
  • Custom Property Persistence (11 flaky): Integer, String, Duration, Email, SQL Query, Time Interval, Timestamp, Hyperlink, Enum, Entity Reference, Date
    • Custom property shows "Not set" after save/reload
    • Some showing API 500 errors

Why This May Be Related to PR:

  1. Search functionality affected: Advanced search not returning results when filtering by custom properties
  2. Custom property indexing issues: Values showing "Not set" suggests indexing problems
  3. API 500 errors: Server errors during custom property operations
  4. High flakiness (14 tests): Suggests timing issues with distributed indexing
  5. Different from other shards: Only Shard 4/6 shows search-related failures

Backend Java Integration Test Summary

Overall Status:

  • 99.99% pass rate, 14 of 16 previous failures fixed
  • 2 Remaining Timing Edge Cases:
    1. AppsResourceIT.test_triggerApp_200 - Job concurrency
    2. ColumnGridResourceIT - Cross-entity search timing

Frontend Shards 2, 5, 6 - UI Element Issues (LIKELY UNRELATED)

Pattern: Edit button duplication, loader visibility, UI state issues

  • Shard 2/6: 5 persistent + 3 flaky (Column Bulk Ops, KPI Widget)
  • Shard 5/6: 1 persistent + 6 flaky (edit button duplication)
  • Shard 6/6: 1 persistent + 4 flaky (Roles loader)

Why Likely Unrelated:

  • DOM rendering issues, not search functionality
  • UI element duplication patterns
  • No indexing or search queries involved

Details

Current Persistent Issues Summary:

  1. 7 Python Trino Tests: Entities not appearing in Elasticsearch during profiler workflow (PERSISTENT)
  2. Frontend Custom Properties: Search not returning results, values not persisting (1 PERSISTENT + 14 FLAKY)
  3. Backend Java: 2 timing edge cases only (99.99% pass rate)
  4. 6 DataProductResourceTest failures: Already FIXED in intermediate commits

Common Thread: Persistent failures involve entity/metadata availability in search indexes

The distributed search indexing changes (flush intervals 5s→1s, batch sizes 5→100) may have introduced:

  • Race conditions between entity creation and index availability
  • Issues with custom property metadata indexing
  • Timing dependencies in profiler workflows

Related to PR Changes?

Maven Build + Test Report (6 failures): ✅ FIXED - Were related to PR, now resolved

Backend Java (2 timing issues): ✅ YES - Minor edge cases, 99.99% pass rate

Backend Python (7 failures): ✅ YES - Entities not in search indexes (PERSISTENT)

Shard 4/6 (1 + 14 flaky): ⚠️ POSSIBLY YES - Custom property search/indexing issues

Shards 2, 5, 6 (6 + 13 flaky): ❌ LIKELY NO - UI element issues

Code Review 👍 Approved with suggestions 2 resolved / 6 findings

Solid performance improvements and per-entity index promotion feature. All 4 previous findings remain unresolved: missing cleanup on exception, TOCTOU race in error tracking, inconsistent ListFilter for time series, and createSource using live batchSize instead of snapshot.

⚠️ Bug: Removing cleanup() from finally leaks resources on exception

📄 openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/SearchIndexExecutor.java:233

The finally { cleanup(); } block was removed from execute(), but the success-path call to closeSinkIfNeeded() at line 294 only runs when executeSingleServer() completes normally. If an exception is thrown (caught at line 235), the sink is never closed and finalizeReindex() is never called.

The caller (SearchIndexApp.runSingleServerReindexing) creates executor as a field and doesn't use try-with-resources, so close() (which calls cleanup()) is never called on the error path.

Impact: On reindexing failure, the search index sink connection leaks, the failure recorder isn't flushed, and index finalization (alias swapping) doesn't happen.

Suggested fix: Restore the finally block or restructure execute() to guarantee cleanup:

try {
    return executeSingleServer();
} catch (Exception e) {
    LOG.error("Reindexing failed", e);
    listeners.onJobFailed(stats.get(), e);
    return ExecutionResult.fromStats(stats.get(), ExecutionResult.Status.FAILED, startTime);
} finally {
    cleanup();
}
⚠️ Bug: createSource uses live batchSize instead of snapshotted value

📄 openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/SearchIndexExecutor.java:997

The PR correctly snapshots batchSize at the start of processEntityReindex() and uses it to calculate offsets (i * fixedBatchSize). However, processBatch() calls createSource() which still uses batchSize.get() — the live, potentially-tuned value — as the page size for the paginated source.

If the batch size is tuned between the initial snapshot and when a batch actually executes (which is likely since tuning runs every 10s now):

  • If batchSize.get() > fixedBatchSize: overlapping reads → duplicate documents indexed
  • If batchSize.get() < fixedBatchSize: gaps → entities skipped during reindex

Suggested fix: Pass fixedBatchSize through the call chain: processBatch → createSource, or capture it in the lambda closure. For example:

// In processEntityType:
producerExecutor.submit(() -> processBatch(entityType, currentOffset, producerLatch, fixedBatchSize));

// In processBatch, pass to createSource:
Source<?> source = createSource(entityType, fixedBatchSize);

// In createSource, use the passed batchSize instead of batchSize.get():
private Source<?> createSource(String entityType, int batchSize) {
    ...
    return new PaginatedEntitiesSource(correctedEntityType, batchSize, searchIndexFields, knownTotal);
}
💡 Edge Case: TOCTOU race in pendingErrors check-then-reset logic

📄 openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/listeners/QuartzProgressListener.java:85

In onProgressUpdate(), pendingErrors.get() > 0 followed by pendingErrors.set(0) is not atomic. If onError() is called concurrently between the get() and set(0), those new errors are silently cleared without ever reaching the ERROR_THRESHOLD check.

Similarly, in onError(), pendingErrors.incrementAndGet() and jobData.setStatus() are not synchronized, meaning concurrent onProgressUpdate could reset pendingErrors to 0 right after incrementAndGet returns a value below threshold but before the error is visible via websocket.

In practice this is unlikely to cause visible issues since it's a UI status indicator, but for correctness you could use getAndSet(0) instead:

if (pendingErrors.getAndSet(0) > 0) {
    jobData.setStatus(EventPublisherJob.Status.RUNNING);
}
💡 Edge Case: Inconsistent ListFilter for time series count in getEntityTotal()

📄 openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/SearchIndexExecutor.java:1101

The PR changed PaginatedEntityTimeSeriesSource.getFilter() to use new ListFilter(Include.ALL) (line 193), but SearchIndexExecutor.getEntityTotal() still uses new ListFilter(null) for the time series path (line 1101). This means the count used for batch planning (getEntityTotal) could differ from what the source actually reads, potentially causing incorrect latch counts or batch partitioning.

Suggested fix: Use Include.ALL consistently in getEntityTotal() for the time series path as well:

ListFilter listFilter = new ListFilter(Include.ALL);
✅ 2 resolved
✅ Bug: Broken merge in waitForSinkOperations — file won't compile

📄 openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/distributed/PartitionWorker.java:316
The waitForSinkOperations method in PartitionWorker.java has a broken merge: the new vector-aware await code (lines 312-316) was added, but the old code (lines 317-325) was not removed. This results in:

  1. Unbalanced braces — the file has brace depth of 1 at EOF instead of 0. The if (!statsComplete) { block on line 316 is never properly closed relative to the method. The } on line 328 closes the if block, but the method's closing brace is missing. This file will not compile.

  2. statsTracker.flush() only called on timeout path — because it's inside the if (!statsComplete) block, successful completions skip the flush entirely, losing stats.

  3. Redundant double-await — statsTracker.awaitSinkCompletion() is called twice (line 315 and line 319) when the first times out.

Fix: Remove the old code (lines 317-325) and add a closing brace for the if (!statsComplete) block before statsTracker.flush():

long statsTimeout = hasVectorTasks ? 60000 : 30000;
boolean statsComplete = statsTracker.awaitSinkCompletion(statsTimeout);
if (!statsComplete) {
    LOG.warn(
        "Timed out waiting for sink stats completion, {} operations still pending for entity {}",
        statsTracker.getPendingSinkOps(),
        statsTracker.getEntityType());
}

statsTracker.flush();
✅ Bug: finalizeAllEntityReindex(false) called instead of closing sink

📄 openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/SearchIndexApp.java:898
In SearchIndexApp.stopJob(), the PR replaced the sink-close logic with finalizeAllEntityReindex(false). Looking at finalizeAllEntityReindex, it calls finalizeEntityReindex for each entity type, which handles index promotion/cleanup — a much heavier operation than just closing the sink. When stopJob() is called (job is being stopped), the intent was to clean up resources, not to finalize all entity reindexes (which would attempt index promotion with success=false).

Looking at finalizeAllEntityReindex(false):

  • It iterates all entities calling finalizeEntityReindex(entityType, false)
  • This will finalize the reindex as a failure for every entity type
  • But the original code only closed the sink

If finalizeAllEntityReindex is already called during normal flow (e.g., by the executor), calling it again in stopJob() could cause double-finalization. The recreateContext = null at the end of finalizeAllEntityReindex provides some guard, but there's still a race if the executor is concurrently finalizing.

Verify that this behavioral change is intentional and won't cause issues with double-finalization or unintended index promotion rollbacks during stop.

Tip

Comment Gitar fix CI or enable auto-apply: gitar auto-apply:on

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing less information.

Comment with these commands to change:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

This branch had an error being deployed

1 failed deployment
test — a681c9f9 Deployed Feb 9, 2026 by mohityadav766 via playwright-ci-postgresql (4, 6) #33362
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.