Skip to content

Fix OpenSearch provider log pagination - #73947

Merged
eladkal merged 4 commits into
apache:mainfrom
kadubhumika:fix/opensearch-log-pagination
Oct 4, 2026
Merged

eladkal merged 4 commits into
apache:mainfrom
kadubhumika:fix/opensearch-log-pagination

Conversation

@kadubhumika

Copy link
Copy Markdown
Contributor

Brief Description

Fixes #73721

This PR resolves the OpenSearch remote log truncation bug by replacing the single-page log reader call with a continuous sliding-window pagination loop inside the orchestrator handler.

Problem

When a task instance generated more than 1,000 log lines, the Apache Airflow OpenSearch remote log viewer capped the output at exactly 1,000 lines in the UI. This happened because OpensearchRemoteLogIO.read() called _os_read() exactly once with a hardcoded starting offset of 0. Since _os_read() executes a query capped to a fixed MAX_LINE_PER_PAGE size of 1,000 documents, any remaining log records (lines 1001+) remained completely stranded inside the OpenSearch index.

Solution Implemented

Instead of blindly increasing page boundaries or relying on deep offset pagination (from_) which harms cluster search performance, I resolved this by utilizing the provider's pre-existing, efficient sliding-window sorting logic:

  1. Orchestrated Pagination in read(): Re-engineered the core read() method to execute a continuous page-aggregating while True loop.
  2. Dynamic Sliding Offsets: After every single chunk is fetched, the method reads the offset_field of the final document hit using attrgetter. It then shifts the running tracking window parameters to automatically request the next batch from OpenSearch where "gt": last_seen_offset.
  3. Preserved Host Grouping: Individual raw document elements are seamlessly stitched across pages into a unified list before formatting payload strings. This fixes the truncation bug while keeping the underlying host-group routing completely intact.

Testing & Environment Validation

  • Added Unit Regression Test: Introduced a dedicated test case test_read_returns_all_logs_when_exceeding_page_size inside test_os_task_handler.py. It explicitly simulates a split multi-page JSON response payload (Page 1 = 1,000 hits, Page 2 = 500 hits, Page 3 = Empty) and asserts that the offset values iterate correctly (0 -> 1000 -> 1500).
  • Test Verification: The test runs successfully against the new loop structure and passes natively.
  • Note on Local Environment Blocker: If you notice any local testing environment variance regarding missing global workspace configurations, please note that it was strictly an isolated dependency-mapping constraint on my local host environment (bypassing heavy Docker Desktop compilations natively). The core provider unit test contract itself passes flawlessly.

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: Gemini following the guidelines

@kadubhumika

Copy link
Copy Markdown
Contributor Author

Hi I have successfully investigated, resolved, and submitted a patch for this log truncation bug.
What was happening:
The new Airflow 3.0+ remote logging utility path inside OpensearchRemoteLogIO.read() was executing a single query hook to _os_read(). Because os_read() is hardcoded to a maximum page threshold window (size=1000), any task instance producing over 1,000 log records had its lines 1001+ completely dropped from the UI viewer once local logs were cleared.
How it's fixed:
I have refactored read() to implement an automated page-aggregating loop. Instead of requesting higher page boundaries with from
changes (which causes deep pagination performance penalties on the OpenSearch cluster), the method now uses attrgetter to read the tracking ID of the final row in a batch. It slides the query window dynamically to pull subsequent sheets where "gt": last_seen_offset until the log index matches are fully exhausted.
I also added a comprehensive mock unit test simulating a split multi-page JSON response payload (1,500 lines combined), and the regression suite passes flawlessly. Please review the PR!

@eladkal

eladkal commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Please share images shows this works with real opensearch. This just feel like a PR from AI tool.

@kadubhumika

Copy link
Copy Markdown
Contributor Author

@eladkal Thanks for the feedback. I’ll add a screenshot showing the task logs retrieved from a real OpenSearch backend, including log entries beyond the 1,000 line boundary

@kadubhumika

Copy link
Copy Markdown
Contributor Author

@eladkal, I tried to reproduce this with a real OpenSearch instance as requested. OpenSearch 2.19.0 is running successfully locally on localhost:9200, but I wasn't able to complete the full Airflow UI integration because the Airflow/Breeze Docker image build fails in my local WSL environment with a Docker BuildKit connection error.
I did verify the pagination behavior with a regression test using 1,500 log entries. The test passes and verifies that _os_read is called with offsets 0 to 1000 to 1500 and that all 1,500 log entries are returned.
I've attached the test result for reference. I understand this is not a substitute for the real OpenSearch UI screenshot you requested, but I wanted to be transparent about the local environment limitation.
Screenshot (1270)
Screenshot (1267)

@eladkal

eladkal commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

cc @Owen-CH-Leung can you take a look?

@kadubhumika

Copy link
Copy Markdown
Contributor Author

cc @Owen-CH-Leung can you take a look?

i am still trying to solve that disck stoarge and docker wsl2 things once my all images i will share the updates . thank for your support

@Owen-CH-Leung

Copy link
Copy Markdown
Contributor

@kadubhumika Thanks for your PR!

While reviewing your PR, I find that the opensearch provider integration test is not triggered. I'll create a PR to fix it

@kadubhumika

kadubhumika commented Oct 1, 2026 via email

Copy link
Copy Markdown
Contributor Author

@Owen-CH-Leung

Copy link
Copy Markdown
Contributor

Ok thanks

@kadubhumika

Copy link
Copy Markdown
Contributor Author

@Owen-CH-Leung @eladkal l I dug into the Breeze core configurations to find out why the OpenSearch integration tests weren't executing on this PR.
I found that opensearch was categorized under OTHER_PROVIDERS_INTEGRATIONS instead of TESTABLE_PROVIDERS_INTEGRATIONS in global_constants.py. Because the selective checks mechanism filters on the testable list to determine the integration execution matrix, changes to the provider paths were bypassing the OpenSearch test engine completely.
I have pushed a commit directly to this branch to move "opensearch" into TESTABLE_PROVIDERS_INTEGRATIONS and map its owner module. I also added a targeted selective-check regression unit test that passes cleanly locally. The GitHub Actions CI runner should now be able to spin up the live OpenSearch test container environment automatically to verify the suite. Please let me know your thoughts!

@kadubhumika

Copy link
Copy Markdown
Contributor Author

Hi @Owen-CH-Leung and @eladkal ,

I investigated why the OpenSearch provider integration test was not being triggered and found that opensearch was categorized under OTHER_PROVIDERS_INTEGRATIONS instead of TESTABLE_PROVIDERS_INTEGRATIONS.
I’ve pushed a fix that:
moves opensearch into TESTABLE_PROVIDERS_INTEGRATIONS
adds the OpenSearch provider owner mapping
adds a regression test to verify that OpenSearch provider changes trigger the integration test
The targeted selective-check test passes locally. The new commit is 06d3574.
Could you please review this change and let me know if anything needs to be adjusted? If everything looks good, I’d be happy for the PR to be merged.
Thank you for the review and guidance!

@kadubhumika

Copy link
Copy Markdown
Contributor Author

@Owen-CH-Leung If my code needed nay changes please do tell i ma ready to fix edit it. Thank you !

@kadubhumika

Copy link
Copy Markdown
Contributor Author

Hi @eladkal ! I checked the two CI failures and have fixed both.
The Breeze unit-test failure was due to the expected selective check output not yet including opensearch after adding it as a testable provider integration. I updated the test expectation and verified 69 tests pass locally.
The Static checks failure was just a ruff-format issue requiring an additional blank line before the new test. I fixed it and verified the formatter and git diff --check pass.
I’ve pushed the fixes to the PR. Please review them when you have a chance. Thanks You are reviewing my Prs ! 🙏

@eladkal

eladkal commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

@kadubhumika can you check the failing test?

@kadubhumika

Copy link
Copy Markdown
Contributor Author

@kadubhumika can you check the failing test?

Yes @eladkal Sure i will start fixing it by now thank you!

@kadubhumika

Copy link
Copy Markdown
Contributor Author

Hi @eladkal , I checked and fixed the failing Breeze unit test. The issue was that the expected testable-providers-integrations output was missing opensearch after adding it as a testable provider integration.
I updated the expected output, verified the exact failing test passes locally, and also ran the formatting/pre-commit checks successfully. I've pushed the fix in the latest commit 6c1330a.
Please have a look when you get a chance. Thank you for pointing me to the failing test and for reviewing the PR!

@eladkal
eladkal merged commit b156582 into apache:main Oct 4, 2026
159 checks passed
@boring-cyborg

boring-cyborg Bot commented Oct 4, 2026

Copy link
Copy Markdown

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Opensearch Provider only loads the the first 1000 loglines for a taskinstance

3 participants