You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "rahulgoyal2987 (via GitHub)" <gi...@apache.org> on 2024/12/04 12:32:51 UTC
[PR] Airflow sentinel defect [airflow]
rahulgoyal2987 opened a new pull request, #44646:
URL: https://github.com/apache/airflow/pull/44646
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!--
Thank you for contributing! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
In case of an existing issue, reference it using one of the following:
closes: #ISSUE
related: #ISSUE
How to write a good git commit message:
http://chris.beams.io/posts/git-commit/
-->
<!-- Please keep an empty line above the dashes. -->
---
**^ Add meaningful description above**
Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information.
In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).
--
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] Fixed thread local _sentinel.callers defect and added test cases [airflow]
Posted by "dabla (via GitHub)" <gi...@apache.org>.
dabla commented on code in PR #44646:
URL: https://github.com/apache/airflow/pull/44646#discussion_r1876365170
##########
airflow/models/baseoperator.py:
##########
@@ -364,6 +364,8 @@ def wrapper(self, *args, **kwargs):
sentinel = kwargs.pop(sentinel_key, None)
if sentinel:
+ if not getattr(cls._sentinel, "callers", None):
Review Comment:
> I guess it will be difficult to figure out unit tests if we have no hypothesis what happens here (look like some race condition). Also @dabla it does not look like it was only your problem - #44648 has been raised by another user.
Indeed I also experience the same error, but only in multi threaded env, see closed [PR](https://github.com/apache/airflow/pull/44240)
--
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] Airflow sentinel defect [airflow]
Posted by "ashb (via GitHub)" <gi...@apache.org>.
ashb commented on PR #44646:
URL: https://github.com/apache/airflow/pull/44646#issuecomment-2521026017
Please add a meaningful description to this pr, and likely unit tests too
--
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] Fixed thread local _sentinel.callers defect and added test cases [airflow]
Posted by "eladkal (via GitHub)" <gi...@apache.org>.
eladkal commented on PR #44646:
URL: https://github.com/apache/airflow/pull/44646#issuecomment-2618128435
I guess this issue fixes https://github.com/apache/airflow/issues/44648 which is a bug on 2.10.3
@utkarsharma2 can we backport the fix to v2-10 branch?
--
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] Fixed thread local _sentinel.callers defect and added test cases [airflow]
Posted by "kulkarni-sp (via GitHub)" <gi...@apache.org>.
kulkarni-sp commented on PR #44646:
URL: https://github.com/apache/airflow/pull/44646#issuecomment-2582690885
> > We are currently using Airflow 2.9.3 and encountered the same errors during our attempt to upgrade to 2.10.3. Therefore, this fix is essential to unblock our upgrade path.
>
> Could you please be more specific - what exactly error you experienced - i think that one has no clear issue that it marks as "solving" ? And is it possible that you apply that patch to verify that this one solves it ?
We are utilizing Airflow with KubernetesExecutor and have several long-running pods that continuously monitor specified locations for input files. Initially, we used mapped tasks to specify different input locations, but this led to a higher number of pods and caused stability issues on our AKS cluster. Now, we are employing ThreadPoolExecutor for parallel processing, which triggers the processor DAG upon receiving a valid input file. However, with Airflow 2.10.3, we encounter the following errors when triggering the processor DAG:
**[2025-01-10, 12:53:29 UTC] {ThreadPoolExecutor-1_3 logging_mixin.py:190} INFO - pa: Error while calling processor DAG: '_thread._local' object has no attribute 'callers'**
```
@task(executor_config=k8s_poller_exec_config_resource_requirements)
def poll_adls_driver(config_list, **kwargs):
args_list = []
for upstream_config in config_list:
args_list.append((upstream_config, kwargs,))
with ThreadPoolExecutor(max_workers=5) as executor:
# Unpack the argument tuples
futures = [executor.submit(poll_adls, *args) for args in args_list]
for future in futures:
future.result()
```
--
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] Airflow sentinel defect [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #44646:
URL: https://github.com/apache/airflow/pull/44646#discussion_r1872785913
##########
airflow/models/baseoperator.py:
##########
@@ -364,6 +364,8 @@ def wrapper(self, *args, **kwargs):
sentinel = kwargs.pop(sentinel_key, None)
if sentinel:
+ if not getattr(cls._sentinel, "callers", None):
Review Comment:
I guess it will be difficult to figure out unit tests if we have no hypothesis what happens here (look like some race condition). Also @dabla it does not look like it was only your problem - #44648 has been raised by another user.
--
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] Airflow sentinel defect [airflow]
Posted by "rahulgoyal2987 (via GitHub)" <gi...@apache.org>.
rahulgoyal2987 commented on code in PR #44646:
URL: https://github.com/apache/airflow/pull/44646#discussion_r1872806068
##########
airflow/models/baseoperator.py:
##########
@@ -364,6 +364,8 @@ def wrapper(self, *args, **kwargs):
sentinel = kwargs.pop(sentinel_key, None)
if sentinel:
+ if not getattr(cls._sentinel, "callers", None):
Review Comment:
@potiuk This issue is related to thread local variable. https://stackoverflow.com/questions/49375702/python-threading-local-not-working-in-thread-class stack overflow issue have more details regarding this issue.
--
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] Airflow sentinel defect [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #44646:
URL: https://github.com/apache/airflow/pull/44646#discussion_r1873314988
##########
airflow/models/baseoperator.py:
##########
@@ -364,6 +364,8 @@ def wrapper(self, *args, **kwargs):
sentinel = kwargs.pop(sentinel_key, None)
if sentinel:
+ if not getattr(cls._sentinel, "callers", None):
Review Comment:
This is not at all obvious what's going on, so for the future refactors etc. if someone will touch the code, they will know what to avoid.
--
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] Fixed thread local _sentinel.callers defect and added test cases [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #44646:
URL: https://github.com/apache/airflow/pull/44646#issuecomment-2580691416
> We are currently using Airflow 2.9.3 and encountered the same errors during our attempt to upgrade to 2.10.3. Therefore, this fix is essential to unblock our upgrade path.
Could you please be more specific - what exactly error you experienced - i think that one has no clear issue that it marks as "solving" ? And is it possible that you apply that patch to verify that this one solves it ?
--
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] Fixed thread local _sentinel.callers defect and added test cases [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #44646:
URL: https://github.com/apache/airflow/pull/44646#issuecomment-2580012103
Currently Airflow 3. Why? Is this worthwhile to make an attempt to backport it to Airflow 2.* ? If so - why? What would be your arguments @kulkarni-sp ?
--
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] Fixed thread local _sentinel.callers defect and added test cases [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #44646:
URL: https://github.com/apache/airflow/pull/44646#issuecomment-2621833113
I marked it as 2.10.5 milestone to not forget about it.
--
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] Fixed thread local _sentinel.callers defect and added test cases [airflow]
Posted by "kulkarni-sp (via GitHub)" <gi...@apache.org>.
kulkarni-sp commented on PR #44646:
URL: https://github.com/apache/airflow/pull/44646#issuecomment-2580038390
> Currently Airflow 3. Why? Is this worthwhile to make an attempt to backport it to Airflow 2.* ? If so - why? What would be your arguments @kulkarni-sp ?
We are currently using Airflow 2.9.3 and encountered the same errors during our attempt to upgrade to 2.10.3. Therefore, this fix is essential to unblock our upgrade path.
--
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] Fixed thread local _sentinel.callers defect and added test cases [airflow]
Posted by "rahulgoyal2987 (via GitHub)" <gi...@apache.org>.
rahulgoyal2987 commented on code in PR #44646:
URL: https://github.com/apache/airflow/pull/44646#discussion_r1873706618
##########
airflow/models/baseoperator.py:
##########
@@ -364,6 +364,8 @@ def wrapper(self, *args, **kwargs):
sentinel = kwargs.pop(sentinel_key, None)
if sentinel:
+ if not getattr(cls._sentinel, "callers", None):
Review Comment:
@potiuk I have added test case. if someone will touch this code and do same mistake again then text case will fail.
--
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] Airflow sentinel defect [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #44646:
URL: https://github.com/apache/airflow/pull/44646#discussion_r1872781630
##########
airflow/models/baseoperator.py:
##########
@@ -364,6 +364,8 @@ def wrapper(self, *args, **kwargs):
sentinel = kwargs.pop(sentinel_key, None)
if sentinel:
+ if not getattr(cls._sentinel, "callers", None):
Review Comment:
As @ashb wrote - better description + unit test would be great - there was also a related PR that has been reported by @dabla here https://github.com/apache/airflow/pull/44240 - and we could not figure out why the class method would not be ine maybe we can brainstorm together why this might be needed in this case - because essentially it should not be needed (at least as far as we discussed there).
Maybe @ashb you have an idea ?
--
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] Airflow sentinel defect [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #44646:
URL: https://github.com/apache/airflow/pull/44646#discussion_r1873314011
##########
airflow/models/baseoperator.py:
##########
@@ -364,6 +364,8 @@ def wrapper(self, *args, **kwargs):
sentinel = kwargs.pop(sentinel_key, None)
if sentinel:
+ if not getattr(cls._sentinel, "callers", None):
Review Comment:
Ah . Of course - Could you please add a comment describing it and update commit message?
--
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] Fixed thread local _sentinel.callers defect and added test cases [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #44646:
URL: https://github.com/apache/airflow/pull/44646#discussion_r1873793763
##########
airflow/models/baseoperator.py:
##########
@@ -364,6 +364,8 @@ def wrapper(self, *args, **kwargs):
sentinel = kwargs.pop(sentinel_key, None)
if sentinel:
+ if not getattr(cls._sentinel, "callers", None):
Review Comment:
Even better!
--
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] Fixed thread local _sentinel.callers defect and added test cases [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #44646:
URL: https://github.com/apache/airflow/pull/44646#issuecomment-2535496564
I thi k we mostly overlooked it :(
--
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] Fixed thread local _sentinel.callers defect and added test cases [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk merged PR #44646:
URL: https://github.com/apache/airflow/pull/44646
--
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] Fixed thread local _sentinel.callers defect and added test cases [airflow]
Posted by "dabla (via GitHub)" <gi...@apache.org>.
dabla commented on PR #44646:
URL: https://github.com/apache/airflow/pull/44646#issuecomment-2533969734
Is there a reason why this PR isn't merged yet as it fixes a thread safety issues with the ExecutorSafeguard?
--
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] Fixed thread local _sentinel.callers defect and added test cases [airflow]
Posted by "kulkarni-sp (via GitHub)" <gi...@apache.org>.
kulkarni-sp commented on PR #44646:
URL: https://github.com/apache/airflow/pull/44646#issuecomment-2579552641
What is the target release version for this fix?
--
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] Fixed thread local _sentinel.callers defect and added test cases [airflow]
Posted by "kulkarni-sp (via GitHub)" <gi...@apache.org>.
kulkarni-sp commented on PR #44646:
URL: https://github.com/apache/airflow/pull/44646#issuecomment-2592834933
@potiuk We have also applied this patch, Requires minor change for it to work in multithreaded env i.e. getattr check and initialization should be done before sentinel check OR It could work with is PR [](https://github.com/apache/airflow/pull/44240/files)
@classmethod
def decorator(cls, func):
@wraps(func)
def wrapper(self, *args, **kwargs):
from airflow.decorators.base import DecoratedOperator
sentinel_key = f"{self.__class__.__name__}__sentinel"
sentinel = kwargs.pop(sentinel_key, None)
**if not getattr(cls._sentinel, "callers", None):
cls._sentinel.callers = {}**
if sentinel:
cls._sentinel.callers[sentinel_key] = sentinel
else:
sentinel = cls._sentinel.callers.pop(f"{func.__qualname__.split('.')[0]}__sentinel", None)
----
--
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] Fixed thread local _sentinel.callers defect and added test cases [airflow]
Posted by "kulkarni-sp (via GitHub)" <gi...@apache.org>.
kulkarni-sp commented on PR #44646:
URL: https://github.com/apache/airflow/pull/44646#issuecomment-2622004840
@utkarsharma2 Is it possible for you to include this make minor change? Essentially doing getattr check before if statement.
//Initialize attribute callers
if not getattr(cls._sentinel, "callers", None):
cls._sentinel.callers = {}
if sentinel:
cls._sentinel.callers[sentinel_key] = sentinel
else:
sentinel = cls._sentinel.callers.pop(f"{func.__qualname__.split('.')[0]}__sentinel", None)
----
--
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