vatsrahul1001 opened a new issue, #47274:
URL: https://github.com/apache/airflow/issues/47274
### Apache Airflow version
main (development)
### If "Other Airflow 2 version" selected, which one?
_No response_
### What happened?
When we try to clear task instance it's throws Intermittently.
**Logs:**
### What you think should happen instead?
Task instances endpoint should not throw HTTP500
```
NFO: 192.168.207.1:54306 - "POST /public/dags/etl_dag/clearTaskInstances
HTTP/1.1" 500 Internal Server Error
ERROR: Exception in ASGI application
+ Exception Group Traceback (most recent call last):
| File "/usr/local/lib/python3.9/site-packages/starlette/_utils.py",
line 76, in collapse_excgroups
| yield
| File
"/usr/local/lib/python3.9/site-packages/starlette/middleware/base.py", line
178, in __call__
| recv_stream.close()
| File
"/usr/local/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 767,
in __aexit__
| raise BaseExceptionGroup(
| exceptiongroup.ExceptionGroup: unhandled errors in a TaskGroup (1
sub-exception)
+-+---------------- 1 ----------------
| Traceback (most recent call last):
| File
"/usr/local/lib/python3.9/site-packages/uvicorn/protocols/http/httptools_impl.py",
line 409, in run_asgi
| result = await app( # type: ignore[func-returns-value]
| File
"/usr/local/lib/python3.9/site-packages/fastapi/applications.py", line 1054, in
__call__
| await super().__call__(scope, receive, send)
| File
"/usr/local/lib/python3.9/site-packages/starlette/applications.py", line 112,
in __call__
| await self.middleware_stack(scope, receive, send)
| File
"/usr/local/lib/python3.9/site-packages/starlette/middleware/errors.py", line
187, in __call__
| raise exc
| File
"/usr/local/lib/python3.9/site-packages/starlette/middleware/errors.py", line
165, in __call__
| await self.app(scope, receive, _send)
| File
"/usr/local/lib/python3.9/site-packages/starlette/middleware/gzip.py", line 29,
in __call__
| await responder(scope, receive, send)
| File
"/usr/local/lib/python3.9/site-packages/starlette/middleware/gzip.py", line
126, in __call__
| await super().__call__(scope, receive, send)
| File
"/usr/local/lib/python3.9/site-packages/starlette/middleware/gzip.py", line 46,
in __call__
| await self.app(scope, receive, self.send_with_compression)
| File
"/usr/local/lib/python3.9/site-packages/starlette/middleware/cors.py", line 93,
in __call__
| await self.simple_response(scope, receive, send,
request_headers=headers)
| File
"/usr/local/lib/python3.9/site-packages/starlette/middleware/cors.py", line
144, in simple_response
| await self.app(scope, receive, send)
| File
"/usr/local/lib/python3.9/site-packages/starlette/middleware/base.py", line
178, in __call__
| recv_stream.close()
| File "/usr/local/lib/python3.9/contextlib.py", line 137, in __exit__
| self.gen.throw(typ, value, traceback)
| File "/usr/local/lib/python3.9/site-packages/starlette/_utils.py",
line 82, in collapse_excgroups
| raise exc
| File
"/usr/local/lib/python3.9/site-packages/starlette/middleware/base.py", line
175, in __call__
| response = await self.dispatch_func(request, call_next)
| File "/opt/airflow/airflow/api_fastapi/core_api/middleware.py", line
28, in dispatch
| response = await call_next(request)
| File
"/usr/local/lib/python3.9/site-packages/starlette/middleware/base.py", line
153, in call_next
| raise app_exc
| File
"/usr/local/lib/python3.9/site-packages/starlette/middleware/base.py", line
140, in coro
| await self.app(scope, receive_or_disconnect, send_no_error)
| File
"/usr/local/lib/python3.9/site-packages/starlette/middleware/exceptions.py",
line 62, in __call__
| await wrap_app_handling_exceptions(self.app, conn)(scope, receive,
send)
| File
"/usr/local/lib/python3.9/site-packages/starlette/_exception_handler.py", line
53, in wrapped_app
| raise exc
| File
"/usr/local/lib/python3.9/site-packages/starlette/_exception_handler.py", line
42, in wrapped_app
| await app(scope, receive, sender)
| File "/usr/local/lib/python3.9/site-packages/starlette/routing.py",
line 714, in __call__
| await self.middleware_stack(scope, receive, send)
| File "/usr/local/lib/python3.9/site-packages/starlette/routing.py",
line 734, in app
| await route.handle(scope, receive, send)
| File "/usr/local/lib/python3.9/site-packages/starlette/routing.py",
line 288, in handle
| await self.app(scope, receive, send)
| File "/usr/local/lib/python3.9/site-packages/starlette/routing.py",
line 76, in app
| await wrap_app_handling_exceptions(app, request)(scope, receive,
send)
| File
"/usr/local/lib/python3.9/site-packages/starlette/_exception_handler.py", line
53, in wrapped_app
| raise exc
| File
"/usr/local/lib/python3.9/site-packages/starlette/_exception_handler.py", line
42, in wrapped_app
| await app(scope, receive, sender)
| File "/usr/local/lib/python3.9/site-packages/starlette/routing.py",
line 73, in app
| response = await f(request)
| File "/usr/local/lib/python3.9/site-packages/fastapi/routing.py",
line 301, in app
| raw_response = await run_endpoint_function(
| File "/usr/local/lib/python3.9/site-packages/fastapi/routing.py",
line 214, in run_endpoint_function
| return await run_in_threadpool(dependant.call, **values)
| File
"/usr/local/lib/python3.9/site-packages/starlette/concurrency.py", line 37, in
run_in_threadpool
| return await anyio.to_thread.run_sync(func)
| File "/usr/local/lib/python3.9/site-packages/anyio/to_thread.py",
line 56, in run_sync
| return await get_async_backend().run_sync_in_worker_thread(
| File
"/usr/local/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line
2461, in run_sync_in_worker_thread
| return await future
| File
"/usr/local/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 962,
in run
| result = context.run(func, *args)
| File
"/opt/airflow/airflow/api_fastapi/core_api/routes/public/task_instances.py",
line 651, in post_clear_task_instances
| dag = dag.partial_subset(
| File "/opt/airflow/task_sdk/src/airflow/sdk/definitions/dag.py",
line 811, in partial_subset
| dag.task_dict = {
| File "/opt/airflow/task_sdk/src/airflow/sdk/definitions/dag.py",
line 812, in <dictcomp>
| t.task_id: _deepcopy_task(t)
| File "/opt/airflow/task_sdk/src/airflow/sdk/definitions/dag.py",
line 808, in _deepcopy_task
| return copy.deepcopy(t, memo)
| File "/usr/local/lib/python3.9/copy.py", line 153, in deepcopy
| y = copier(memo)
| File
"/opt/airflow/task_sdk/src/airflow/sdk/definitions/baseoperator.py", line 1188,
in __deepcopy__
| object.__setattr__(result, k, v)
| AttributeError: can't set attribute
+------------------------------------
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File
"/usr/local/lib/python3.9/site-packages/uvicorn/protocols/http/httptools_impl.py",
line 409, in run_asgi
result = await app( # type: ignore[func-returns-value]
File "/usr/local/lib/python3.9/site-packages/fastapi/applications.py",
line 1054, in __call__
await super().__call__(scope, receive, send)
File "/usr/local/lib/python3.9/site-packages/starlette/applications.py",
line 112, in __call__
await self.middleware_stack(scope, receive, send)
File
"/usr/local/lib/python3.9/site-packages/starlette/middleware/errors.py", line
187, in __call__
raise exc
File
"/usr/local/lib/python3.9/site-packages/starlette/middleware/errors.py", line
165, in __call__
await self.app(scope, receive, _send)
File
"/usr/local/lib/python3.9/site-packages/starlette/middleware/gzip.py", line 29,
in __call__
await responder(scope, receive, send)
File
"/usr/local/lib/python3.9/site-packages/starlette/middleware/gzip.py", line
126, in __call__
await super().__call__(scope, receive, send)
File
"/usr/local/lib/python3.9/site-packages/starlette/middleware/gzip.py", line 46,
in __call__
await self.app(scope, receive, self.send_with_compression)
File
"/usr/local/lib/python3.9/site-packages/starlette/middleware/cors.py", line 93,
in __call__
await self.simple_response(scope, receive, send, request_headers=headers)
File
"/usr/local/lib/python3.9/site-packages/starlette/middleware/cors.py", line
144, in simple_response
await self.app(scope, receive, send)
File
"/usr/local/lib/python3.9/site-packages/starlette/middleware/base.py", line
178, in __call__
recv_stream.close()
File "/usr/local/lib/python3.9/contextlib.py", line 137, in __exit__
self.gen.throw(typ, value, traceback)
File "/usr/local/lib/python3.9/site-packages/starlette/_utils.py", line
82, in collapse_excgroups
raise exc
File
"/usr/local/lib/python3.9/site-packages/starlette/middleware/base.py", line
175, in __call__
response = await self.dispatch_func(request, call_next)
File "/opt/airflow/airflow/api_fastapi/core_api/middleware.py", line 28,
in dispatch
response = await call_next(request)
File
"/usr/local/lib/python3.9/site-packages/starlette/middleware/base.py", line
153, in call_next
raise app_exc
File
"/usr/local/lib/python3.9/site-packages/starlette/middleware/base.py", line
140, in coro
await self.app(scope, receive_or_disconnect, send_no_error)
File
"/usr/local/lib/python3.9/site-packages/starlette/middleware/exceptions.py",
line 62, in __call__
await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
File
"/usr/local/lib/python3.9/site-packages/starlette/_exception_handler.py", line
53, in wrapped_app
raise exc
File
"/usr/local/lib/python3.9/site-packages/starlette/_exception_handler.py", line
42, in wrapped_app
await app(scope, receive, sender)
File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line
714, in __call__
await self.middleware_stack(scope, receive, send)
File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line
734, in app
await route.handle(scope, receive, send)
File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line
288, in handle
await self.app(scope, receive, send)
File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line
76, in app
await wrap_app_handling_exceptions(app, request)(scope, receive, send)
File
"/usr/local/lib/python3.9/site-packages/starlette/_exception_handler.py", line
53, in wrapped_app
raise exc
File
"/usr/local/lib/python3.9/site-packages/starlette/_exception_handler.py", line
42, in wrapped_app
await app(scope, receive, sender)
File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line
73, in app
response = await f(request)
File "/usr/local/lib/python3.9/site-packages/fastapi/routing.py", line
301, in app
raw_response = await run_endpoint_function(
File "/usr/local/lib/python3.9/site-packages/fastapi/routing.py", line
214, in run_endpoint_function
return await run_in_threadpool(dependant.call, **values)
File "/usr/local/lib/python3.9/site-packages/starlette/concurrency.py",
line 37, in run_in_threadpool
return await anyio.to_thread.run_sync(func)
File "/usr/local/lib/python3.9/site-packages/anyio/to_thread.py", line 56,
in run_sync
return await get_async_backend().run_sync_in_worker_thread(
File "/usr/local/lib/python3.9/site-packages/anyio/_backends/_asyncio.py",
line 2461, in run_sync_in_worker_thread
return await future
File "/usr/local/lib/python3.9/site-packages/anyio/_backends/_asyncio.py",
line 962, in run
result = context.run(func, *args)
File
"/opt/airflow/airflow/api_fastapi/core_api/routes/public/task_instances.py",
line 651, in post_clear_task_instances
dag = dag.partial_subset(
File "/opt/airflow/task_sdk/src/airflow/sdk/definitions/dag.py", line 811,
in partial_subset
dag.task_dict = {
File "/opt/airflow/task_sdk/src/airflow/sdk/definitions/dag.py", line 812,
in <dictcomp>
t.task_id: _deepcopy_task(t)
File "/opt/airflow/task_sdk/src/airflow/sdk/definitions/dag.py", line 808,
in _deepcopy_task
return copy.deepcopy(t, memo)
File "/usr/local/lib/python3.9/copy.py", line 153, in deepcopy
y = copier(memo)
File "/opt/airflow/task_sdk/src/airflow/sdk/definitions/baseoperator.py",
line 1188, in __deepcopy__
object.__setattr__(result, k, v)
AttributeError: can't set attribute
```
### How to reproduce
As I mentioned, its intermittent you need to try clearing task instance
couple of times from UI and you will observe this issue
### Operating System
Linux
### Versions of Apache Airflow Providers
_No response_
### Deployment
Other
### Deployment details
_No response_
### Anything else?
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [x] I agree to follow this project's [Code of
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
--
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]