xchwan commented on code in PR #77283:
URL: https://github.com/apache/airflow/pull/77283#discussion_r4690582068


##########
shared/observability/src/airflow_shared/observability/traces/__init__.py:
##########
@@ -211,7 +211,10 @@ def _get_backcompat_config(conf: ConfigParser) -> 
tuple[str | None, Resource | N
     if not os.environ.get("OTEL_SERVICE_NAME") and not 
os.environ.get("OTEL_RESOURCE_ATTRIBUTES"):
         service_name = conf.get("traces", "otel_service", fallback=None)
         if service_name:
-            resource = Resource({"service.name": service_name})
+            # ``Resource.create()``, not ``Resource(...)``: it imports 
``concurrent.futures.thread``, so that
+            # module's at-fork hooks are registered before 
``TracerProvider``'s and the forked child does not
+            # deadlock (open-telemetry/opentelemetry-python#5789).
+            resource = Resource.create({"service.name": service_name})

Review Comment:
   Thanks for trying the variants on 3.11–3.14. I'd lean towards the 
import-only version with the static `Resource({...})`: it keeps this PR to the 
deadlock fix, leaves the resource identical to `main` (which makes a backport 
simpler, given the report above from a 3.3.x upgrade), and the regression test 
then pins the import line exactly. Aligning the deprecated path with 
`Resource.create()` seems worth doing too, but as a separate change. That said, 
a maintainer may have a preference.
   
   Before suggesting it, I verified that variant (explicit `import 
concurrent.futures.thread  # noqa: F401`, static `Resource({...})`, and the 
precondition assert moved above the `configure_otel` import):
   
   - Python 3.11, 3.12, 3.13 and 3.14 with SDK 1.45.2: the test passes. 
Removing only the import makes it fail with `forked child deadlocked` on all 
four, and putting the assert back after the import makes the precondition fail, 
so both parts are needed.
   - The full `shared/observability` suite passes, and ruff and mypy are clean 
(the `noqa` is required, F401 otherwise).
   - Real Airflow process: the same kind cluster setup as my earlier comment, 
with this variant. All 96 Dags were serialized (0 with the original code), with 
no parse timeouts and no children stuck in `futex_do_wait`, and 4 Dag runs (12 
tasks) succeeded.
   
   ---
   Drafted-by: Claude Code (Opus 5.5); reviewed by @xchwan before posting
   



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to