You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "1fanwang (via GitHub)" <gi...@apache.org> on 2026/08/27 20:13:19 UTC
[PR] Reduce Iceberg snapshot watcher thread use [airflow]
1fanwang opened a new pull request, #72173:
URL: https://github.com/apache/airflow/pull/72173
Each stateful Iceberg snapshot watcher submits worker-thread jobs to load and save its watermark. A triggerer running many watchers spends executor capacity on storage that already has an async API.
After this change, stateful watchers await watermark storage directly. Worker threads remain limited to synchronous PyIceberg catalog calls. Watchers without an injected state store keep their existing behavior.
Depends on https://github.com/apache/airflow/pull/72127 and must merge after it.
<details>
<summary>Test output</summary>
```console
$ uv run --project providers/apache/iceberg pytest providers/apache/iceberg/tests/unit/apache/iceberg/triggers/test_iceberg.py -xvs
# Before
FAILED providers/apache/iceberg/tests/unit/apache/iceberg/triggers/test_iceberg.py::test_resumes_from_the_stored_watermark
E AssertionError: assert [...] == []
1 failed, 10 passed
# After
19 passed, 1 warning in 17.57s
```
</details>
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes: GitHub Copilot CLI 1.0.80 (GPT-5.6 Sol)
Generated-by: GitHub Copilot CLI 1.0.80 (GPT-5.6 Sol) following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
---
* Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
* For fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
* When adding dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Reduce Iceberg snapshot watcher thread use [airflow]
Posted by "jason810496 (via GitHub)" <gi...@apache.org>.
jason810496 commented on code in PR #72173:
URL: https://github.com/apache/airflow/pull/72173#discussion_r3890236506
##########
providers/apache/iceberg/src/airflow/providers/apache/iceberg/triggers/iceberg.py:
##########
@@ -132,7 +132,7 @@ async def run(self) -> AsyncIterator[TriggerEvent]:
store = getattr(self, "asset_state_store", None)
if store is not None:
try:
- stored = await asyncio.to_thread(store.get, WATERMARK_KEY)
+ stored = await store.aget(WATERMARK_KEY)
Review Comment:
I just realized we should add compatible layer for the `aget` method, otherwise the Airflow 3.3.0 and 3.3.1 with the upcoming Iceberg provider will crash.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Reduce Iceberg snapshot watcher thread use [airflow]
Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck merged PR #72173:
URL: https://github.com/apache/airflow/pull/72173
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Reduce Iceberg snapshot watcher thread use [airflow]
Posted by "1fanwang (via GitHub)" <gi...@apache.org>.
1fanwang commented on code in PR #72173:
URL: https://github.com/apache/airflow/pull/72173#discussion_r3891837691
##########
providers/apache/iceberg/src/airflow/providers/apache/iceberg/triggers/iceberg.py:
##########
@@ -132,7 +132,7 @@ async def run(self) -> AsyncIterator[TriggerEvent]:
store = getattr(self, "asset_state_store", None)
if store is not None:
try:
- stored = await asyncio.to_thread(store.get, WATERMARK_KEY)
+ stored = await store.aget(WATERMARK_KEY)
Review Comment:
@jason810496 done in https://github.com/apache/airflow/pull/72312. It awaits `aget`/`aset` where the store has them and otherwise runs the blocking accessor through `asyncio.to_thread`, so the watcher works on 3.3.0 and 3.3.1 and picks up the async accessors automatically once https://github.com/apache/airflow/pull/72127 lands.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Reduce Iceberg snapshot watcher thread use [airflow]
Posted by "1fanwang (via GitHub)" <gi...@apache.org>.
1fanwang commented on code in PR #72173:
URL: https://github.com/apache/airflow/pull/72173#discussion_r3890265972
##########
providers/apache/iceberg/src/airflow/providers/apache/iceberg/triggers/iceberg.py:
##########
@@ -132,7 +132,7 @@ async def run(self) -> AsyncIterator[TriggerEvent]:
store = getattr(self, "asset_state_store", None)
if store is not None:
try:
- stored = await asyncio.to_thread(store.get, WATERMARK_KEY)
+ stored = await store.aget(WATERMARK_KEY)
Review Comment:
Thanks @jason810496 will tag you in the follow up PR in a bit.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Reduce Iceberg snapshot watcher thread use [airflow]
Posted by "jason810496 (via GitHub)" <gi...@apache.org>.
jason810496 commented on code in PR #72173:
URL: https://github.com/apache/airflow/pull/72173#discussion_r3890236506
##########
providers/apache/iceberg/src/airflow/providers/apache/iceberg/triggers/iceberg.py:
##########
@@ -132,7 +132,7 @@ async def run(self) -> AsyncIterator[TriggerEvent]:
store = getattr(self, "asset_state_store", None)
if store is not None:
try:
- stored = await asyncio.to_thread(store.get, WATERMARK_KEY)
+ stored = await store.aget(WATERMARK_KEY)
Review Comment:
I just realized we should add compatible layer for the `aget` method, otherwise Airflow 3.3.0 and 3.3.1 will crash with the upcoming Iceberg provider will crash.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Reduce Iceberg snapshot watcher thread use [airflow]
Posted by "jason810496 (via GitHub)" <gi...@apache.org>.
jason810496 commented on code in PR #72173:
URL: https://github.com/apache/airflow/pull/72173#discussion_r3890236506
##########
providers/apache/iceberg/src/airflow/providers/apache/iceberg/triggers/iceberg.py:
##########
@@ -132,7 +132,7 @@ async def run(self) -> AsyncIterator[TriggerEvent]:
store = getattr(self, "asset_state_store", None)
if store is not None:
try:
- stored = await asyncio.to_thread(store.get, WATERMARK_KEY)
+ stored = await store.aget(WATERMARK_KEY)
Review Comment:
I just realized we should add compatible layer for the `aget` method, otherwise Airflow 3.3.0 and 3.3.1 with the upcoming Iceberg provider will crash.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Reduce Iceberg snapshot watcher thread use [airflow]
Posted by "1fanwang (via GitHub)" <gi...@apache.org>.
1fanwang commented on code in PR #72173:
URL: https://github.com/apache/airflow/pull/72173#discussion_r3891837691
##########
providers/apache/iceberg/src/airflow/providers/apache/iceberg/triggers/iceberg.py:
##########
@@ -132,7 +132,7 @@ async def run(self) -> AsyncIterator[TriggerEvent]:
store = getattr(self, "asset_state_store", None)
if store is not None:
try:
- stored = await asyncio.to_thread(store.get, WATERMARK_KEY)
+ stored = await store.aget(WATERMARK_KEY)
Review Comment:
@jason810496 done in https://github.com/apache/airflow/pull/72312. It awaits `aget`/`aset` where the store has them and otherwise runs the blocking accessor through `asyncio.to_thread`, so the watcher works on 3.3.0 and 3.3.1 and picks up the async accessors automatically once https://github.com/apache/airflow/pull/72127 lands.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org