potiuk commented on PR #25532:
URL: https://github.com/apache/airflow/pull/25532#issuecomment-1205261137
> Exactly the code you have above is what I tried and it failed. I don't
have any logging handlers and no environment variables was set too.
Hmm. Can you really reproduce it ? Maybe there was some mistake when you run
it. and you run another version (or maybe .pyc file was compiled or something
like that).
When I look closer at the stacktrace it DOES seem like the last hypothesis
of mine..
```
File "/opt/airflow/airflow/models/dagrun.py", line 950, in verify_integrity
self._create_task_instances(dag.dag_id, tasks, created_counts,
hook_is_noop, session=session)
File "/opt/airflow/airflow/models/dagrun.py", line 1154, in
_create_task_instances
self.run_id,
```
^^ this is part of the log.info where run_id is accessed.
```
File
"/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/attributes.py", line
481, in __get__
return self.impl.get(state, dict_)
File
"/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/attributes.py", line
926, in get
value = self._fire_loader_callables(state, key, passive)
File
"/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/attributes.py", line
957, in _fire_loader_callables
return state._load_expired(state, passive)
```
^^ And it seems sql alchemy tries to retrieve the object and load it and it
tries to execute SQL command but irt finds out that rollback is Pending and
should be executed.
So this would be rather strange to see it happening with this code:
```
except IntegrityError:
self.log.info('Session rolled back.')
session.rollback()
self.log.info(
'Hit IntegrityError while creating the TIs for %s- %s',
dag_id,
self.run_id,
exc_info=True,
)
```
Can you produce such an exception and see that the line number match and get
the stack trace?
--
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]