Skip to content

Attempt to stabilise tests for xcom_arg_map - #33150

Merged
potiuk merged 1 commit into
apache:mainfrom
potiuk:unflake-test-xcom-args-map
Aug 6, 2023
Merged

Attempt to stabilise tests for xcom_arg_map#33150
potiuk merged 1 commit into
apache:mainfrom
potiuk:unflake-test-xcom-args-map

Conversation

@potiuk

Copy link
Copy Markdown
Member

Similarly to #33145 - this is an attempt to stabilise flaky tests for the test_xcom_arg_map.

Even if the mechanism is not entirely clear (provide_session should also close the connection) seems like using pytest-fixture provided session works better than relying on a new session created in run() methods.


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
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.

Similarly to apache#33145 - this is an attempt to stabilise flaky tests
for the test_xcom_arg_map.
Even if the mechanism is not entirely clear (provide_session should
also close the connection) seems like using pytest-fixture provided
session works better than relying on a new session created in run()
methods.
@potiuk

Copy link
Copy Markdown
MemberAuthor

Example failure: https://github.com/apache/airflow/actions/runs/5775967682/job/15654656922?pr=32991

________________________ test_xcom_map_error_fails_task ________________________
self = <sqlalchemy.future.engine.Connection object at 0x7f5a70b28c70>
dialect = <sqlalchemy.dialects.sqlite.pysqlite.SQLiteDialect_pysqlite object at 0x7f5ad1451db0>
constructor = <bound method DefaultExecutionContext._init_compiled of <class 'sqlalchemy.dialects.sqlite.base.SQLiteExecutionContext'>>
statement = <sqlalchemy.dialects.sqlite.base.SQLiteCompiler object at 0x7f5ad06c7970>
parameters = []
execution_options = immutabledict({'_sa_orm_load_options': default_load_options(_legacy_uniquing=True), '_result_disable_adapt_to_context': True, 'future_result': True})
args = (<sqlalchemy.dialects.sqlite.base.SQLiteCompiler object at 0x7f5ad06c7970>, [], <sqlalchemy.sql.selectable.Select obje...0720 run_id)s', 'test', type_=String(length=250)), BindParameter('%(140026414543824 map_index)s', 0, type_=Integer())])
kw = {'cache_hit': symbol('CACHE_HIT')}
branched = <sqlalchemy.future.engine.Connection object at 0x7f5a70b28c70>
yp = None
conn = <sqlalchemy.pool.base._ConnectionFairy object at 0x7f5a70b2add0>
def _execute_context(
self,
dialect,
constructor,
statement,
parameters,
execution_options,
*args,
**kw
):
"""Create an :class:`.ExecutionContext` and execute, returning
a :class:`_engine.CursorResult`."""
branched = self
if self.__branch_from:
# if this is a "branched" connection, do everything in terms
# of the "root" connection, *except* for .close(), which is
# the only feature that branching provides
self = self.__branch_from
if execution_options:
yp = execution_options.get("yield_per", None)
if yp:
execution_options = execution_options.union(
{"stream_results": True, "max_row_buffer": yp}
)
try:
conn = self._dbapi_connection
if conn is None:
conn = self._revalidate_connection()
> context = constructor(
dialect, self, conn, execution_options, *args, **kw
)
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1810: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1020: in _init_compiled
self.cursor = self.create_cursor()
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1391: in create_cursor
return self.create_default_cursor()
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1394: in create_default_cursor
return self._dbapi_connection.cursor()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <sqlalchemy.pool.base._ConnectionFairy object at 0x7f5a70b2add0>
args = (), kwargs = {}
def cursor(self, *args, **kwargs):
"""Return a new DBAPI cursor for the underlying connection.
This method is a proxy for the ``connection.cursor()`` DBAPI
method.
"""
> return self.dbapi_connection.cursor(*args, **kwargs)
E sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 140026872592128 and this is thread id 140028343548800.
/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py:1133: ProgrammingError
The above exception was the direct cause of the following exception:
@contextlib.contextmanager
def create_session() -> Generator[settings.SASession, None, None]:
"""Contextmanager that will create and teardown a session."""
Session = getattr(settings, "Session", None)
if Session is None:
raise RuntimeError("Session must be set before!")
session = Session()
try:
> yield session
airflow/utils/session.py:36: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ airflow/utils/session.py:77: in wrapper
return func(*args, session=session, **kwargs)
airflow/models/taskinstance.py:1840: in run
self._run_raw_task(
airflow/utils/session.py:74: in wrapper
return func(*args, **kwargs)
airflow/models/taskinstance.py:1488: in _run_raw_task
self.refresh_from_db(session=session)
airflow/utils/session.py:74: in wrapper
return func(*args, **kwargs)
airflow/models/taskinstance.py:866: in refresh_from_db
ti = qry.one_or_none()
/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/query.py:2850: in one_or_none
return self._iter().one_or_none()
/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/query.py:2916: in _iter
result = self.session.execute(
/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/session.py:1717: in execute
result = conn._execute_20(statement, params or {}, execution_options)
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1710: in _execute_20
return meth(self, args_10style, kwargs_10style, execution_options)
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/elements.py:334: in _execute_on_connection
return connection._execute_clauseelement(
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1577: in _execute_clauseelement
ret = self._execute_context(
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1816: in _execute_context
self._handle_dbapi_exception(
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:2134: in _handle_dbapi_exception
util.raise_(
/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py:211: in raise_
raise exception
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1810: in _execute_context
context = constructor(
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1020: in _init_compiled
self.cursor = self.create_cursor()
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1391: in create_cursor
return self.create_default_cursor()
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1394: in create_default_cursor
return self._dbapi_connection.cursor()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <sqlalchemy.pool.base._ConnectionFairy object at 0x7f5a70b2add0>
args = (), kwargs = {}
def cursor(self, *args, **kwargs):
"""Return a new DBAPI cursor for the underlying connection.
This method is a proxy for the ``connection.cursor()`` DBAPI
method.
"""
> return self.dbapi_connection.cursor(*args, **kwargs)
E sqlalchemy.exc.ProgrammingError: (sqlite3.ProgrammingError) SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 140026872592128 and this is thread id 140028343548800.
E [SQL: SELECT task_instance.task_id AS task_instance_task_id, task_instance.dag_id AS task_instance_dag_id, task_instance.run_id AS task_instance_run_id, task_instance.map_index AS task_instance_map_index, task_instance.start_date AS task_instance_start_date, task_instance.end_date AS task_instance_end_date, task_instance.duration AS task_instance_duration, task_instance.state AS task_instance_state, task_instance.try_number AS task_instance_try_number, task_instance.max_tries AS task_instance_max_tries, task_instance.hostname AS task_instance_hostname, task_instance.unixname AS task_instance_unixname, task_instance.job_id AS task_instance_job_id, task_instance.pool AS task_instance_pool, task_instance.pool_slots AS task_instance_pool_slots, task_instance.queue AS task_instance_queue, task_instance.priority_weight AS task_instance_priority_weight, task_instance.operator AS task_instance_operator, task_instance.custom_operator_name AS task_instance_custom_operator_name, task_instance.queued_dttm AS task_instance_queued_dttm, task_instance.queued_by_job_id AS task_instance_queued_by_job_id, task_instance.pid AS task_instance_pid, task_instance.executor_config AS task_instance_executor_config, task_instance.updated_at AS task_instance_updated_at, task_instance.external_executor_id AS task_instance_external_executor_id, task_instance.trigger_id AS task_instance_trigger_id, task_instance.trigger_timeout AS task_instance_trigger_timeout, task_instance.next_method AS task_instance_next_method, task_instance.next_kwargs AS task_instance_next_kwargs E FROM task_instance E WHERE task_instance.dag_id = ? AND task_instance.task_id = ? AND task_instance.run_id = ? AND task_instance.map_index = ?]
E (Background on this error at: https://sqlalche.me/e/14/f405)
/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py:1133: ProgrammingError
During handling of the above exception, another exception occurred:
self = <sqlalchemy.future.engine.Connection object at 0x7f5a70b28c70>
def _rollback_impl(self):
assert not self.__branch_from
if self._has_events or self.engine._has_events:
self.dispatch.rollback(self)
if self._still_open_and_dbapi_connection_is_valid:
if self._echo:
if self._is_autocommit_isolation():
self._log_info(
"ROLLBACK using DBAPI connection.rollback(), "
"DBAPI should ignore due to autocommit mode"
)
else:
self._log_info("ROLLBACK")
try:
> self.engine.dialect.do_rollback(self.connection)
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1062: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <sqlalchemy.dialects.sqlite.pysqlite.SQLiteDialect_pysqlite object at 0x7f5ad1451db0>
dbapi_connection = <sqlalchemy.pool.base._ConnectionFairy object at 0x7f5a70b2add0>
def do_rollback(self, dbapi_connection):
> dbapi_connection.rollback()
E sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 140026872592128 and this is thread id 140028343548800.
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:683: ProgrammingError

@potiuk

Copy link
Copy Markdown
MemberAuthor

It's a bit strange what happens though.... The @provide_session in run_method does actually call close_session in context manager, so this is quite strange... But let's see after merge if we can get it more stable.

@potiukpotiuk added this to the Airflow 2.7.0 milestone Aug 6, 2023
@potiuk
potiuk merged commit 3dd0c99 into apache:mainAug 6, 2023
@potiuk
potiuk deleted the unflake-test-xcom-args-map branch August 6, 2023 11:24
potiuk added a commit to potiuk/airflow that referenced this pull request Aug 6, 2023
Using same session in different steps of the same test has the
potential of not flishing/committing the changes between.
Seems that the apache#33150 traded one flakiness with another. Attempting to
make sure that the flash/commit is executed before the second run.
Error:
The test RuntimeError: number of values in row (0) differ from number of
column processors (29)
The error is strange however and indicates a bug in sqlite library.
potiuk added a commit that referenced this pull request Aug 6, 2023
)
Using same session in different steps of the same test has the
potential of not flishing/committing the changes between.
Seems that the #33150 traded one flakiness with another. Attempting to
make sure that the flash/commit is executed before the second run.
Error:
The test RuntimeError: number of values in row (0) differ from number of
column processors (29)
The error is strange however and indicates a bug in sqlite library.
@ephraimbuddyephraimbuddy added the changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) label Aug 8, 2023
ephraimbuddy pushed a commit that referenced this pull request Aug 8, 2023
Similarly to #33145 - this is an attempt to stabilise flaky tests
for the test_xcom_arg_map.
Even if the mechanism is not entirely clear (provide_session should
also close the connection) seems like using pytest-fixture provided
session works better than relying on a new session created in run()
methods.
(cherry picked from commit 3dd0c99)
ephraimbuddy pushed a commit that referenced this pull request Aug 8, 2023
)
Using same session in different steps of the same test has the
potential of not flishing/committing the changes between.
Seems that the #33150 traded one flakiness with another. Attempting to
make sure that the flash/commit is executed before the second run.
Error:
The test RuntimeError: number of values in row (0) differ from number of
column processors (29)
The error is strange however and indicates a bug in sqlite library.
(cherry picked from commit 6b21b79)
ephraimbuddy pushed a commit that referenced this pull request Aug 8, 2023
)
Using same session in different steps of the same test has the
potential of not flishing/committing the changes between.
Seems that the #33150 traded one flakiness with another. Attempting to
make sure that the flash/commit is executed before the second run.
Error:
The test RuntimeError: number of values in row (0) differ from number of
column processors (29)
The error is strange however and indicates a bug in sqlite library.
(cherry picked from commit 6b21b79)
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog:skipChanges that should be skipped from the changelog (CI, tests, etc..)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@potiuk@ephraimbuddy@hussein-awala
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Attempt to stabilise tests for xcom_arg_map by potiuk · Pull Request #33150 · apache/airflow · GitHub
Skip to content

Attempt to stabilise tests for xcom_arg_map - #33150

Merged
potiuk merged 1 commit into
apache:mainfrom
potiuk:unflake-test-xcom-args-map
Aug 6, 2023
Merged

Attempt to stabilise tests for xcom_arg_map#33150
potiuk merged 1 commit into
apache:mainfrom
potiuk:unflake-test-xcom-args-map

Conversation

@potiuk

Copy link
Copy Markdown
Member

Similarly to #33145 - this is an attempt to stabilise flaky tests for the test_xcom_arg_map.

Even if the mechanism is not entirely clear (provide_session should also close the connection) seems like using pytest-fixture provided session works better than relying on a new session created in run() methods.


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
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.

Similarly to apache#33145 - this is an attempt to stabilise flaky tests
for the test_xcom_arg_map.
Even if the mechanism is not entirely clear (provide_session should
also close the connection) seems like using pytest-fixture provided
session works better than relying on a new session created in run()
methods.
@potiuk

Copy link
Copy Markdown
MemberAuthor

Example failure: https://github.com/apache/airflow/actions/runs/5775967682/job/15654656922?pr=32991

________________________ test_xcom_map_error_fails_task ________________________
self = <sqlalchemy.future.engine.Connection object at 0x7f5a70b28c70>
dialect = <sqlalchemy.dialects.sqlite.pysqlite.SQLiteDialect_pysqlite object at 0x7f5ad1451db0>
constructor = <bound method DefaultExecutionContext._init_compiled of <class 'sqlalchemy.dialects.sqlite.base.SQLiteExecutionContext'>>
statement = <sqlalchemy.dialects.sqlite.base.SQLiteCompiler object at 0x7f5ad06c7970>
parameters = []
execution_options = immutabledict({'_sa_orm_load_options': default_load_options(_legacy_uniquing=True), '_result_disable_adapt_to_context': True, 'future_result': True})
args = (<sqlalchemy.dialects.sqlite.base.SQLiteCompiler object at 0x7f5ad06c7970>, [], <sqlalchemy.sql.selectable.Select obje...0720 run_id)s', 'test', type_=String(length=250)), BindParameter('%(140026414543824 map_index)s', 0, type_=Integer())])
kw = {'cache_hit': symbol('CACHE_HIT')}
branched = <sqlalchemy.future.engine.Connection object at 0x7f5a70b28c70>
yp = None
conn = <sqlalchemy.pool.base._ConnectionFairy object at 0x7f5a70b2add0>
def _execute_context(
self,
dialect,
constructor,
statement,
parameters,
execution_options,
*args,
**kw
):
"""Create an :class:`.ExecutionContext` and execute, returning
a :class:`_engine.CursorResult`."""
branched = self
if self.__branch_from:
# if this is a "branched" connection, do everything in terms
# of the "root" connection, *except* for .close(), which is
# the only feature that branching provides
self = self.__branch_from
if execution_options:
yp = execution_options.get("yield_per", None)
if yp:
execution_options = execution_options.union(
{"stream_results": True, "max_row_buffer": yp}
)
try:
conn = self._dbapi_connection
if conn is None:
conn = self._revalidate_connection()
> context = constructor(
dialect, self, conn, execution_options, *args, **kw
)
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1810: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1020: in _init_compiled
self.cursor = self.create_cursor()
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1391: in create_cursor
return self.create_default_cursor()
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1394: in create_default_cursor
return self._dbapi_connection.cursor()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <sqlalchemy.pool.base._ConnectionFairy object at 0x7f5a70b2add0>
args = (), kwargs = {}
def cursor(self, *args, **kwargs):
"""Return a new DBAPI cursor for the underlying connection.
This method is a proxy for the ``connection.cursor()`` DBAPI
method.
"""
> return self.dbapi_connection.cursor(*args, **kwargs)
E sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 140026872592128 and this is thread id 140028343548800.
/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py:1133: ProgrammingError
The above exception was the direct cause of the following exception:
@contextlib.contextmanager
def create_session() -> Generator[settings.SASession, None, None]:
"""Contextmanager that will create and teardown a session."""
Session = getattr(settings, "Session", None)
if Session is None:
raise RuntimeError("Session must be set before!")
session = Session()
try:
> yield session
airflow/utils/session.py:36: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ airflow/utils/session.py:77: in wrapper
return func(*args, session=session, **kwargs)
airflow/models/taskinstance.py:1840: in run
self._run_raw_task(
airflow/utils/session.py:74: in wrapper
return func(*args, **kwargs)
airflow/models/taskinstance.py:1488: in _run_raw_task
self.refresh_from_db(session=session)
airflow/utils/session.py:74: in wrapper
return func(*args, **kwargs)
airflow/models/taskinstance.py:866: in refresh_from_db
ti = qry.one_or_none()
/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/query.py:2850: in one_or_none
return self._iter().one_or_none()
/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/query.py:2916: in _iter
result = self.session.execute(
/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/session.py:1717: in execute
result = conn._execute_20(statement, params or {}, execution_options)
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1710: in _execute_20
return meth(self, args_10style, kwargs_10style, execution_options)
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/elements.py:334: in _execute_on_connection
return connection._execute_clauseelement(
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1577: in _execute_clauseelement
ret = self._execute_context(
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1816: in _execute_context
self._handle_dbapi_exception(
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:2134: in _handle_dbapi_exception
util.raise_(
/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py:211: in raise_
raise exception
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1810: in _execute_context
context = constructor(
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1020: in _init_compiled
self.cursor = self.create_cursor()
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1391: in create_cursor
return self.create_default_cursor()
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1394: in create_default_cursor
return self._dbapi_connection.cursor()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <sqlalchemy.pool.base._ConnectionFairy object at 0x7f5a70b2add0>
args = (), kwargs = {}
def cursor(self, *args, **kwargs):
"""Return a new DBAPI cursor for the underlying connection.
This method is a proxy for the ``connection.cursor()`` DBAPI
method.
"""
> return self.dbapi_connection.cursor(*args, **kwargs)
E sqlalchemy.exc.ProgrammingError: (sqlite3.ProgrammingError) SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 140026872592128 and this is thread id 140028343548800.
E [SQL: SELECT task_instance.task_id AS task_instance_task_id, task_instance.dag_id AS task_instance_dag_id, task_instance.run_id AS task_instance_run_id, task_instance.map_index AS task_instance_map_index, task_instance.start_date AS task_instance_start_date, task_instance.end_date AS task_instance_end_date, task_instance.duration AS task_instance_duration, task_instance.state AS task_instance_state, task_instance.try_number AS task_instance_try_number, task_instance.max_tries AS task_instance_max_tries, task_instance.hostname AS task_instance_hostname, task_instance.unixname AS task_instance_unixname, task_instance.job_id AS task_instance_job_id, task_instance.pool AS task_instance_pool, task_instance.pool_slots AS task_instance_pool_slots, task_instance.queue AS task_instance_queue, task_instance.priority_weight AS task_instance_priority_weight, task_instance.operator AS task_instance_operator, task_instance.custom_operator_name AS task_instance_custom_operator_name, task_instance.queued_dttm AS task_instance_queued_dttm, task_instance.queued_by_job_id AS task_instance_queued_by_job_id, task_instance.pid AS task_instance_pid, task_instance.executor_config AS task_instance_executor_config, task_instance.updated_at AS task_instance_updated_at, task_instance.external_executor_id AS task_instance_external_executor_id, task_instance.trigger_id AS task_instance_trigger_id, task_instance.trigger_timeout AS task_instance_trigger_timeout, task_instance.next_method AS task_instance_next_method, task_instance.next_kwargs AS task_instance_next_kwargs E FROM task_instance E WHERE task_instance.dag_id = ? AND task_instance.task_id = ? AND task_instance.run_id = ? AND task_instance.map_index = ?]
E (Background on this error at: https://sqlalche.me/e/14/f405)
/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py:1133: ProgrammingError
During handling of the above exception, another exception occurred:
self = <sqlalchemy.future.engine.Connection object at 0x7f5a70b28c70>
def _rollback_impl(self):
assert not self.__branch_from
if self._has_events or self.engine._has_events:
self.dispatch.rollback(self)
if self._still_open_and_dbapi_connection_is_valid:
if self._echo:
if self._is_autocommit_isolation():
self._log_info(
"ROLLBACK using DBAPI connection.rollback(), "
"DBAPI should ignore due to autocommit mode"
)
else:
self._log_info("ROLLBACK")
try:
> self.engine.dialect.do_rollback(self.connection)
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1062: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <sqlalchemy.dialects.sqlite.pysqlite.SQLiteDialect_pysqlite object at 0x7f5ad1451db0>
dbapi_connection = <sqlalchemy.pool.base._ConnectionFairy object at 0x7f5a70b2add0>
def do_rollback(self, dbapi_connection):
> dbapi_connection.rollback()
E sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 140026872592128 and this is thread id 140028343548800.
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:683: ProgrammingError

@potiuk

Copy link
Copy Markdown
MemberAuthor

It's a bit strange what happens though.... The @provide_session in run_method does actually call close_session in context manager, so this is quite strange... But let's see after merge if we can get it more stable.

@potiukpotiuk added this to the Airflow 2.7.0 milestone Aug 6, 2023
@potiuk
potiuk merged commit 3dd0c99 into apache:mainAug 6, 2023
@potiuk
potiuk deleted the unflake-test-xcom-args-map branch August 6, 2023 11:24
potiuk added a commit to potiuk/airflow that referenced this pull request Aug 6, 2023
Using same session in different steps of the same test has the
potential of not flishing/committing the changes between.
Seems that the apache#33150 traded one flakiness with another. Attempting to
make sure that the flash/commit is executed before the second run.
Error:
The test RuntimeError: number of values in row (0) differ from number of
column processors (29)
The error is strange however and indicates a bug in sqlite library.
potiuk added a commit that referenced this pull request Aug 6, 2023
)
Using same session in different steps of the same test has the
potential of not flishing/committing the changes between.
Seems that the #33150 traded one flakiness with another. Attempting to
make sure that the flash/commit is executed before the second run.
Error:
The test RuntimeError: number of values in row (0) differ from number of
column processors (29)
The error is strange however and indicates a bug in sqlite library.
@ephraimbuddyephraimbuddy added the changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) label Aug 8, 2023
ephraimbuddy pushed a commit that referenced this pull request Aug 8, 2023
Similarly to #33145 - this is an attempt to stabilise flaky tests
for the test_xcom_arg_map.
Even if the mechanism is not entirely clear (provide_session should
also close the connection) seems like using pytest-fixture provided
session works better than relying on a new session created in run()
methods.
(cherry picked from commit 3dd0c99)
ephraimbuddy pushed a commit that referenced this pull request Aug 8, 2023
)
Using same session in different steps of the same test has the
potential of not flishing/committing the changes between.
Seems that the #33150 traded one flakiness with another. Attempting to
make sure that the flash/commit is executed before the second run.
Error:
The test RuntimeError: number of values in row (0) differ from number of
column processors (29)
The error is strange however and indicates a bug in sqlite library.
(cherry picked from commit 6b21b79)
ephraimbuddy pushed a commit that referenced this pull request Aug 8, 2023
)
Using same session in different steps of the same test has the
potential of not flishing/committing the changes between.
Seems that the #33150 traded one flakiness with another. Attempting to
make sure that the flash/commit is executed before the second run.
Error:
The test RuntimeError: number of values in row (0) differ from number of
column processors (29)
The error is strange however and indicates a bug in sqlite library.
(cherry picked from commit 6b21b79)
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog:skipChanges that should be skipped from the changelog (CI, tests, etc..)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@potiuk@ephraimbuddy@hussein-awala
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Attempt to stabilise tests for xcom_arg_map by potiuk · Pull Request #33150 · apache/airflow · GitHub
Skip to content

Attempt to stabilise tests for xcom_arg_map - #33150

Merged
potiuk merged 1 commit into
apache:mainfrom
potiuk:unflake-test-xcom-args-map
Aug 6, 2023
Merged

Attempt to stabilise tests for xcom_arg_map#33150
potiuk merged 1 commit into
apache:mainfrom
potiuk:unflake-test-xcom-args-map

Conversation

@potiuk

Copy link
Copy Markdown
Member

Similarly to #33145 - this is an attempt to stabilise flaky tests for the test_xcom_arg_map.

Even if the mechanism is not entirely clear (provide_session should also close the connection) seems like using pytest-fixture provided session works better than relying on a new session created in run() methods.


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
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.

Similarly to apache#33145 - this is an attempt to stabilise flaky tests
for the test_xcom_arg_map.
Even if the mechanism is not entirely clear (provide_session should
also close the connection) seems like using pytest-fixture provided
session works better than relying on a new session created in run()
methods.
@potiuk

Copy link
Copy Markdown
MemberAuthor

Example failure: https://github.com/apache/airflow/actions/runs/5775967682/job/15654656922?pr=32991

________________________ test_xcom_map_error_fails_task ________________________
self = <sqlalchemy.future.engine.Connection object at 0x7f5a70b28c70>
dialect = <sqlalchemy.dialects.sqlite.pysqlite.SQLiteDialect_pysqlite object at 0x7f5ad1451db0>
constructor = <bound method DefaultExecutionContext._init_compiled of <class 'sqlalchemy.dialects.sqlite.base.SQLiteExecutionContext'>>
statement = <sqlalchemy.dialects.sqlite.base.SQLiteCompiler object at 0x7f5ad06c7970>
parameters = []
execution_options = immutabledict({'_sa_orm_load_options': default_load_options(_legacy_uniquing=True), '_result_disable_adapt_to_context': True, 'future_result': True})
args = (<sqlalchemy.dialects.sqlite.base.SQLiteCompiler object at 0x7f5ad06c7970>, [], <sqlalchemy.sql.selectable.Select obje...0720 run_id)s', 'test', type_=String(length=250)), BindParameter('%(140026414543824 map_index)s', 0, type_=Integer())])
kw = {'cache_hit': symbol('CACHE_HIT')}
branched = <sqlalchemy.future.engine.Connection object at 0x7f5a70b28c70>
yp = None
conn = <sqlalchemy.pool.base._ConnectionFairy object at 0x7f5a70b2add0>
def _execute_context(
self,
dialect,
constructor,
statement,
parameters,
execution_options,
*args,
**kw
):
"""Create an :class:`.ExecutionContext` and execute, returning
a :class:`_engine.CursorResult`."""
branched = self
if self.__branch_from:
# if this is a "branched" connection, do everything in terms
# of the "root" connection, *except* for .close(), which is
# the only feature that branching provides
self = self.__branch_from
if execution_options:
yp = execution_options.get("yield_per", None)
if yp:
execution_options = execution_options.union(
{"stream_results": True, "max_row_buffer": yp}
)
try:
conn = self._dbapi_connection
if conn is None:
conn = self._revalidate_connection()
> context = constructor(
dialect, self, conn, execution_options, *args, **kw
)
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1810: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1020: in _init_compiled
self.cursor = self.create_cursor()
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1391: in create_cursor
return self.create_default_cursor()
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1394: in create_default_cursor
return self._dbapi_connection.cursor()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <sqlalchemy.pool.base._ConnectionFairy object at 0x7f5a70b2add0>
args = (), kwargs = {}
def cursor(self, *args, **kwargs):
"""Return a new DBAPI cursor for the underlying connection.
This method is a proxy for the ``connection.cursor()`` DBAPI
method.
"""
> return self.dbapi_connection.cursor(*args, **kwargs)
E sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 140026872592128 and this is thread id 140028343548800.
/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py:1133: ProgrammingError
The above exception was the direct cause of the following exception:
@contextlib.contextmanager
def create_session() -> Generator[settings.SASession, None, None]:
"""Contextmanager that will create and teardown a session."""
Session = getattr(settings, "Session", None)
if Session is None:
raise RuntimeError("Session must be set before!")
session = Session()
try:
> yield session
airflow/utils/session.py:36: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ airflow/utils/session.py:77: in wrapper
return func(*args, session=session, **kwargs)
airflow/models/taskinstance.py:1840: in run
self._run_raw_task(
airflow/utils/session.py:74: in wrapper
return func(*args, **kwargs)
airflow/models/taskinstance.py:1488: in _run_raw_task
self.refresh_from_db(session=session)
airflow/utils/session.py:74: in wrapper
return func(*args, **kwargs)
airflow/models/taskinstance.py:866: in refresh_from_db
ti = qry.one_or_none()
/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/query.py:2850: in one_or_none
return self._iter().one_or_none()
/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/query.py:2916: in _iter
result = self.session.execute(
/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/session.py:1717: in execute
result = conn._execute_20(statement, params or {}, execution_options)
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1710: in _execute_20
return meth(self, args_10style, kwargs_10style, execution_options)
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/elements.py:334: in _execute_on_connection
return connection._execute_clauseelement(
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1577: in _execute_clauseelement
ret = self._execute_context(
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1816: in _execute_context
self._handle_dbapi_exception(
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:2134: in _handle_dbapi_exception
util.raise_(
/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py:211: in raise_
raise exception
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1810: in _execute_context
context = constructor(
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1020: in _init_compiled
self.cursor = self.create_cursor()
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1391: in create_cursor
return self.create_default_cursor()
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1394: in create_default_cursor
return self._dbapi_connection.cursor()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <sqlalchemy.pool.base._ConnectionFairy object at 0x7f5a70b2add0>
args = (), kwargs = {}
def cursor(self, *args, **kwargs):
"""Return a new DBAPI cursor for the underlying connection.
This method is a proxy for the ``connection.cursor()`` DBAPI
method.
"""
> return self.dbapi_connection.cursor(*args, **kwargs)
E sqlalchemy.exc.ProgrammingError: (sqlite3.ProgrammingError) SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 140026872592128 and this is thread id 140028343548800.
E [SQL: SELECT task_instance.task_id AS task_instance_task_id, task_instance.dag_id AS task_instance_dag_id, task_instance.run_id AS task_instance_run_id, task_instance.map_index AS task_instance_map_index, task_instance.start_date AS task_instance_start_date, task_instance.end_date AS task_instance_end_date, task_instance.duration AS task_instance_duration, task_instance.state AS task_instance_state, task_instance.try_number AS task_instance_try_number, task_instance.max_tries AS task_instance_max_tries, task_instance.hostname AS task_instance_hostname, task_instance.unixname AS task_instance_unixname, task_instance.job_id AS task_instance_job_id, task_instance.pool AS task_instance_pool, task_instance.pool_slots AS task_instance_pool_slots, task_instance.queue AS task_instance_queue, task_instance.priority_weight AS task_instance_priority_weight, task_instance.operator AS task_instance_operator, task_instance.custom_operator_name AS task_instance_custom_operator_name, task_instance.queued_dttm AS task_instance_queued_dttm, task_instance.queued_by_job_id AS task_instance_queued_by_job_id, task_instance.pid AS task_instance_pid, task_instance.executor_config AS task_instance_executor_config, task_instance.updated_at AS task_instance_updated_at, task_instance.external_executor_id AS task_instance_external_executor_id, task_instance.trigger_id AS task_instance_trigger_id, task_instance.trigger_timeout AS task_instance_trigger_timeout, task_instance.next_method AS task_instance_next_method, task_instance.next_kwargs AS task_instance_next_kwargs E FROM task_instance E WHERE task_instance.dag_id = ? AND task_instance.task_id = ? AND task_instance.run_id = ? AND task_instance.map_index = ?]
E (Background on this error at: https://sqlalche.me/e/14/f405)
/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py:1133: ProgrammingError
During handling of the above exception, another exception occurred:
self = <sqlalchemy.future.engine.Connection object at 0x7f5a70b28c70>
def _rollback_impl(self):
assert not self.__branch_from
if self._has_events or self.engine._has_events:
self.dispatch.rollback(self)
if self._still_open_and_dbapi_connection_is_valid:
if self._echo:
if self._is_autocommit_isolation():
self._log_info(
"ROLLBACK using DBAPI connection.rollback(), "
"DBAPI should ignore due to autocommit mode"
)
else:
self._log_info("ROLLBACK")
try:
> self.engine.dialect.do_rollback(self.connection)
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1062: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <sqlalchemy.dialects.sqlite.pysqlite.SQLiteDialect_pysqlite object at 0x7f5ad1451db0>
dbapi_connection = <sqlalchemy.pool.base._ConnectionFairy object at 0x7f5a70b2add0>
def do_rollback(self, dbapi_connection):
> dbapi_connection.rollback()
E sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 140026872592128 and this is thread id 140028343548800.
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:683: ProgrammingError

@potiuk

Copy link
Copy Markdown
MemberAuthor

It's a bit strange what happens though.... The @provide_session in run_method does actually call close_session in context manager, so this is quite strange... But let's see after merge if we can get it more stable.

@potiukpotiuk added this to the Airflow 2.7.0 milestone Aug 6, 2023
@potiuk
potiuk merged commit 3dd0c99 into apache:mainAug 6, 2023
@potiuk
potiuk deleted the unflake-test-xcom-args-map branch August 6, 2023 11:24
potiuk added a commit to potiuk/airflow that referenced this pull request Aug 6, 2023
Using same session in different steps of the same test has the
potential of not flishing/committing the changes between.
Seems that the apache#33150 traded one flakiness with another. Attempting to
make sure that the flash/commit is executed before the second run.
Error:
The test RuntimeError: number of values in row (0) differ from number of
column processors (29)
The error is strange however and indicates a bug in sqlite library.
potiuk added a commit that referenced this pull request Aug 6, 2023
)
Using same session in different steps of the same test has the
potential of not flishing/committing the changes between.
Seems that the #33150 traded one flakiness with another. Attempting to
make sure that the flash/commit is executed before the second run.
Error:
The test RuntimeError: number of values in row (0) differ from number of
column processors (29)
The error is strange however and indicates a bug in sqlite library.
@ephraimbuddyephraimbuddy added the changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) label Aug 8, 2023
ephraimbuddy pushed a commit that referenced this pull request Aug 8, 2023
Similarly to #33145 - this is an attempt to stabilise flaky tests
for the test_xcom_arg_map.
Even if the mechanism is not entirely clear (provide_session should
also close the connection) seems like using pytest-fixture provided
session works better than relying on a new session created in run()
methods.
(cherry picked from commit 3dd0c99)
ephraimbuddy pushed a commit that referenced this pull request Aug 8, 2023
)
Using same session in different steps of the same test has the
potential of not flishing/committing the changes between.
Seems that the #33150 traded one flakiness with another. Attempting to
make sure that the flash/commit is executed before the second run.
Error:
The test RuntimeError: number of values in row (0) differ from number of
column processors (29)
The error is strange however and indicates a bug in sqlite library.
(cherry picked from commit 6b21b79)
ephraimbuddy pushed a commit that referenced this pull request Aug 8, 2023
)
Using same session in different steps of the same test has the
potential of not flishing/committing the changes between.
Seems that the #33150 traded one flakiness with another. Attempting to
make sure that the flash/commit is executed before the second run.
Error:
The test RuntimeError: number of values in row (0) differ from number of
column processors (29)
The error is strange however and indicates a bug in sqlite library.
(cherry picked from commit 6b21b79)
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog:skipChanges that should be skipped from the changelog (CI, tests, etc..)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@potiuk@ephraimbuddy@hussein-awala
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Attempt to stabilise tests for xcom_arg_map by potiuk · Pull Request #33150 · apache/airflow · GitHub
Skip to content

Attempt to stabilise tests for xcom_arg_map - #33150

Merged
potiuk merged 1 commit into
apache:mainfrom
potiuk:unflake-test-xcom-args-map
Aug 6, 2023
Merged

Attempt to stabilise tests for xcom_arg_map#33150
potiuk merged 1 commit into
apache:mainfrom
potiuk:unflake-test-xcom-args-map

Conversation

@potiuk

Copy link
Copy Markdown
Member

Similarly to #33145 - this is an attempt to stabilise flaky tests for the test_xcom_arg_map.

Even if the mechanism is not entirely clear (provide_session should also close the connection) seems like using pytest-fixture provided session works better than relying on a new session created in run() methods.


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
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.

Similarly to apache#33145 - this is an attempt to stabilise flaky tests
for the test_xcom_arg_map.
Even if the mechanism is not entirely clear (provide_session should
also close the connection) seems like using pytest-fixture provided
session works better than relying on a new session created in run()
methods.
@potiuk

Copy link
Copy Markdown
MemberAuthor

Example failure: https://github.com/apache/airflow/actions/runs/5775967682/job/15654656922?pr=32991

________________________ test_xcom_map_error_fails_task ________________________
self = <sqlalchemy.future.engine.Connection object at 0x7f5a70b28c70>
dialect = <sqlalchemy.dialects.sqlite.pysqlite.SQLiteDialect_pysqlite object at 0x7f5ad1451db0>
constructor = <bound method DefaultExecutionContext._init_compiled of <class 'sqlalchemy.dialects.sqlite.base.SQLiteExecutionContext'>>
statement = <sqlalchemy.dialects.sqlite.base.SQLiteCompiler object at 0x7f5ad06c7970>
parameters = []
execution_options = immutabledict({'_sa_orm_load_options': default_load_options(_legacy_uniquing=True), '_result_disable_adapt_to_context': True, 'future_result': True})
args = (<sqlalchemy.dialects.sqlite.base.SQLiteCompiler object at 0x7f5ad06c7970>, [], <sqlalchemy.sql.selectable.Select obje...0720 run_id)s', 'test', type_=String(length=250)), BindParameter('%(140026414543824 map_index)s', 0, type_=Integer())])
kw = {'cache_hit': symbol('CACHE_HIT')}
branched = <sqlalchemy.future.engine.Connection object at 0x7f5a70b28c70>
yp = None
conn = <sqlalchemy.pool.base._ConnectionFairy object at 0x7f5a70b2add0>
def _execute_context(
self,
dialect,
constructor,
statement,
parameters,
execution_options,
*args,
**kw
):
"""Create an :class:`.ExecutionContext` and execute, returning
a :class:`_engine.CursorResult`."""
branched = self
if self.__branch_from:
# if this is a "branched" connection, do everything in terms
# of the "root" connection, *except* for .close(), which is
# the only feature that branching provides
self = self.__branch_from
if execution_options:
yp = execution_options.get("yield_per", None)
if yp:
execution_options = execution_options.union(
{"stream_results": True, "max_row_buffer": yp}
)
try:
conn = self._dbapi_connection
if conn is None:
conn = self._revalidate_connection()
> context = constructor(
dialect, self, conn, execution_options, *args, **kw
)
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1810: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1020: in _init_compiled
self.cursor = self.create_cursor()
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1391: in create_cursor
return self.create_default_cursor()
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1394: in create_default_cursor
return self._dbapi_connection.cursor()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <sqlalchemy.pool.base._ConnectionFairy object at 0x7f5a70b2add0>
args = (), kwargs = {}
def cursor(self, *args, **kwargs):
"""Return a new DBAPI cursor for the underlying connection.
This method is a proxy for the ``connection.cursor()`` DBAPI
method.
"""
> return self.dbapi_connection.cursor(*args, **kwargs)
E sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 140026872592128 and this is thread id 140028343548800.
/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py:1133: ProgrammingError
The above exception was the direct cause of the following exception:
@contextlib.contextmanager
def create_session() -> Generator[settings.SASession, None, None]:
"""Contextmanager that will create and teardown a session."""
Session = getattr(settings, "Session", None)
if Session is None:
raise RuntimeError("Session must be set before!")
session = Session()
try:
> yield session
airflow/utils/session.py:36: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ airflow/utils/session.py:77: in wrapper
return func(*args, session=session, **kwargs)
airflow/models/taskinstance.py:1840: in run
self._run_raw_task(
airflow/utils/session.py:74: in wrapper
return func(*args, **kwargs)
airflow/models/taskinstance.py:1488: in _run_raw_task
self.refresh_from_db(session=session)
airflow/utils/session.py:74: in wrapper
return func(*args, **kwargs)
airflow/models/taskinstance.py:866: in refresh_from_db
ti = qry.one_or_none()
/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/query.py:2850: in one_or_none
return self._iter().one_or_none()
/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/query.py:2916: in _iter
result = self.session.execute(
/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/session.py:1717: in execute
result = conn._execute_20(statement, params or {}, execution_options)
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1710: in _execute_20
return meth(self, args_10style, kwargs_10style, execution_options)
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/elements.py:334: in _execute_on_connection
return connection._execute_clauseelement(
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1577: in _execute_clauseelement
ret = self._execute_context(
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1816: in _execute_context
self._handle_dbapi_exception(
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:2134: in _handle_dbapi_exception
util.raise_(
/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py:211: in raise_
raise exception
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1810: in _execute_context
context = constructor(
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1020: in _init_compiled
self.cursor = self.create_cursor()
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1391: in create_cursor
return self.create_default_cursor()
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1394: in create_default_cursor
return self._dbapi_connection.cursor()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <sqlalchemy.pool.base._ConnectionFairy object at 0x7f5a70b2add0>
args = (), kwargs = {}
def cursor(self, *args, **kwargs):
"""Return a new DBAPI cursor for the underlying connection.
This method is a proxy for the ``connection.cursor()`` DBAPI
method.
"""
> return self.dbapi_connection.cursor(*args, **kwargs)
E sqlalchemy.exc.ProgrammingError: (sqlite3.ProgrammingError) SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 140026872592128 and this is thread id 140028343548800.
E [SQL: SELECT task_instance.task_id AS task_instance_task_id, task_instance.dag_id AS task_instance_dag_id, task_instance.run_id AS task_instance_run_id, task_instance.map_index AS task_instance_map_index, task_instance.start_date AS task_instance_start_date, task_instance.end_date AS task_instance_end_date, task_instance.duration AS task_instance_duration, task_instance.state AS task_instance_state, task_instance.try_number AS task_instance_try_number, task_instance.max_tries AS task_instance_max_tries, task_instance.hostname AS task_instance_hostname, task_instance.unixname AS task_instance_unixname, task_instance.job_id AS task_instance_job_id, task_instance.pool AS task_instance_pool, task_instance.pool_slots AS task_instance_pool_slots, task_instance.queue AS task_instance_queue, task_instance.priority_weight AS task_instance_priority_weight, task_instance.operator AS task_instance_operator, task_instance.custom_operator_name AS task_instance_custom_operator_name, task_instance.queued_dttm AS task_instance_queued_dttm, task_instance.queued_by_job_id AS task_instance_queued_by_job_id, task_instance.pid AS task_instance_pid, task_instance.executor_config AS task_instance_executor_config, task_instance.updated_at AS task_instance_updated_at, task_instance.external_executor_id AS task_instance_external_executor_id, task_instance.trigger_id AS task_instance_trigger_id, task_instance.trigger_timeout AS task_instance_trigger_timeout, task_instance.next_method AS task_instance_next_method, task_instance.next_kwargs AS task_instance_next_kwargs E FROM task_instance E WHERE task_instance.dag_id = ? AND task_instance.task_id = ? AND task_instance.run_id = ? AND task_instance.map_index = ?]
E (Background on this error at: https://sqlalche.me/e/14/f405)
/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py:1133: ProgrammingError
During handling of the above exception, another exception occurred:
self = <sqlalchemy.future.engine.Connection object at 0x7f5a70b28c70>
def _rollback_impl(self):
assert not self.__branch_from
if self._has_events or self.engine._has_events:
self.dispatch.rollback(self)
if self._still_open_and_dbapi_connection_is_valid:
if self._echo:
if self._is_autocommit_isolation():
self._log_info(
"ROLLBACK using DBAPI connection.rollback(), "
"DBAPI should ignore due to autocommit mode"
)
else:
self._log_info("ROLLBACK")
try:
> self.engine.dialect.do_rollback(self.connection)
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1062: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <sqlalchemy.dialects.sqlite.pysqlite.SQLiteDialect_pysqlite object at 0x7f5ad1451db0>
dbapi_connection = <sqlalchemy.pool.base._ConnectionFairy object at 0x7f5a70b2add0>
def do_rollback(self, dbapi_connection):
> dbapi_connection.rollback()
E sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 140026872592128 and this is thread id 140028343548800.
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:683: ProgrammingError

@potiuk

Copy link
Copy Markdown
MemberAuthor

It's a bit strange what happens though.... The @provide_session in run_method does actually call close_session in context manager, so this is quite strange... But let's see after merge if we can get it more stable.

@potiukpotiuk added this to the Airflow 2.7.0 milestone Aug 6, 2023
@potiuk
potiuk merged commit 3dd0c99 into apache:mainAug 6, 2023
@potiuk
potiuk deleted the unflake-test-xcom-args-map branch August 6, 2023 11:24
potiuk added a commit to potiuk/airflow that referenced this pull request Aug 6, 2023
Using same session in different steps of the same test has the
potential of not flishing/committing the changes between.
Seems that the apache#33150 traded one flakiness with another. Attempting to
make sure that the flash/commit is executed before the second run.
Error:
The test RuntimeError: number of values in row (0) differ from number of
column processors (29)
The error is strange however and indicates a bug in sqlite library.
potiuk added a commit that referenced this pull request Aug 6, 2023
)
Using same session in different steps of the same test has the
potential of not flishing/committing the changes between.
Seems that the #33150 traded one flakiness with another. Attempting to
make sure that the flash/commit is executed before the second run.
Error:
The test RuntimeError: number of values in row (0) differ from number of
column processors (29)
The error is strange however and indicates a bug in sqlite library.
@ephraimbuddyephraimbuddy added the changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) label Aug 8, 2023
ephraimbuddy pushed a commit that referenced this pull request Aug 8, 2023
Similarly to #33145 - this is an attempt to stabilise flaky tests
for the test_xcom_arg_map.
Even if the mechanism is not entirely clear (provide_session should
also close the connection) seems like using pytest-fixture provided
session works better than relying on a new session created in run()
methods.
(cherry picked from commit 3dd0c99)
ephraimbuddy pushed a commit that referenced this pull request Aug 8, 2023
)
Using same session in different steps of the same test has the
potential of not flishing/committing the changes between.
Seems that the #33150 traded one flakiness with another. Attempting to
make sure that the flash/commit is executed before the second run.
Error:
The test RuntimeError: number of values in row (0) differ from number of
column processors (29)
The error is strange however and indicates a bug in sqlite library.
(cherry picked from commit 6b21b79)
ephraimbuddy pushed a commit that referenced this pull request Aug 8, 2023
)
Using same session in different steps of the same test has the
potential of not flishing/committing the changes between.
Seems that the #33150 traded one flakiness with another. Attempting to
make sure that the flash/commit is executed before the second run.
Error:
The test RuntimeError: number of values in row (0) differ from number of
column processors (29)
The error is strange however and indicates a bug in sqlite library.
(cherry picked from commit 6b21b79)
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog:skipChanges that should be skipped from the changelog (CI, tests, etc..)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@potiuk@ephraimbuddy@hussein-awala
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' Attempt to stabilise tests for xcom_arg_map by potiuk · Pull Request #33150 · apache/airflow · GitHub
Skip to content

Attempt to stabilise tests for xcom_arg_map - #33150

Merged
potiuk merged 1 commit into
apache:mainfrom
potiuk:unflake-test-xcom-args-map
Aug 6, 2023
Merged

Attempt to stabilise tests for xcom_arg_map#33150
potiuk merged 1 commit into
apache:mainfrom
potiuk:unflake-test-xcom-args-map

Conversation

@potiuk

Copy link
Copy Markdown
Member

Similarly to #33145 - this is an attempt to stabilise flaky tests for the test_xcom_arg_map.

Even if the mechanism is not entirely clear (provide_session should also close the connection) seems like using pytest-fixture provided session works better than relying on a new session created in run() methods.


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
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.

Similarly to apache#33145 - this is an attempt to stabilise flaky tests
for the test_xcom_arg_map.
Even if the mechanism is not entirely clear (provide_session should
also close the connection) seems like using pytest-fixture provided
session works better than relying on a new session created in run()
methods.
@potiuk

Copy link
Copy Markdown
MemberAuthor

Example failure: https://github.com/apache/airflow/actions/runs/5775967682/job/15654656922?pr=32991

________________________ test_xcom_map_error_fails_task ________________________
self = <sqlalchemy.future.engine.Connection object at 0x7f5a70b28c70>
dialect = <sqlalchemy.dialects.sqlite.pysqlite.SQLiteDialect_pysqlite object at 0x7f5ad1451db0>
constructor = <bound method DefaultExecutionContext._init_compiled of <class 'sqlalchemy.dialects.sqlite.base.SQLiteExecutionContext'>>
statement = <sqlalchemy.dialects.sqlite.base.SQLiteCompiler object at 0x7f5ad06c7970>
parameters = []
execution_options = immutabledict({'_sa_orm_load_options': default_load_options(_legacy_uniquing=True), '_result_disable_adapt_to_context': True, 'future_result': True})
args = (<sqlalchemy.dialects.sqlite.base.SQLiteCompiler object at 0x7f5ad06c7970>, [], <sqlalchemy.sql.selectable.Select obje...0720 run_id)s', 'test', type_=String(length=250)), BindParameter('%(140026414543824 map_index)s', 0, type_=Integer())])
kw = {'cache_hit': symbol('CACHE_HIT')}
branched = <sqlalchemy.future.engine.Connection object at 0x7f5a70b28c70>
yp = None
conn = <sqlalchemy.pool.base._ConnectionFairy object at 0x7f5a70b2add0>
def _execute_context(
self,
dialect,
constructor,
statement,
parameters,
execution_options,
*args,
**kw
):
"""Create an :class:`.ExecutionContext` and execute, returning
a :class:`_engine.CursorResult`."""
branched = self
if self.__branch_from:
# if this is a "branched" connection, do everything in terms
# of the "root" connection, *except* for .close(), which is
# the only feature that branching provides
self = self.__branch_from
if execution_options:
yp = execution_options.get("yield_per", None)
if yp:
execution_options = execution_options.union(
{"stream_results": True, "max_row_buffer": yp}
)
try:
conn = self._dbapi_connection
if conn is None:
conn = self._revalidate_connection()
> context = constructor(
dialect, self, conn, execution_options, *args, **kw
)
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1810: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1020: in _init_compiled
self.cursor = self.create_cursor()
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1391: in create_cursor
return self.create_default_cursor()
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1394: in create_default_cursor
return self._dbapi_connection.cursor()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <sqlalchemy.pool.base._ConnectionFairy object at 0x7f5a70b2add0>
args = (), kwargs = {}
def cursor(self, *args, **kwargs):
"""Return a new DBAPI cursor for the underlying connection.
This method is a proxy for the ``connection.cursor()`` DBAPI
method.
"""
> return self.dbapi_connection.cursor(*args, **kwargs)
E sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 140026872592128 and this is thread id 140028343548800.
/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py:1133: ProgrammingError
The above exception was the direct cause of the following exception:
@contextlib.contextmanager
def create_session() -> Generator[settings.SASession, None, None]:
"""Contextmanager that will create and teardown a session."""
Session = getattr(settings, "Session", None)
if Session is None:
raise RuntimeError("Session must be set before!")
session = Session()
try:
> yield session
airflow/utils/session.py:36: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ airflow/utils/session.py:77: in wrapper
return func(*args, session=session, **kwargs)
airflow/models/taskinstance.py:1840: in run
self._run_raw_task(
airflow/utils/session.py:74: in wrapper
return func(*args, **kwargs)
airflow/models/taskinstance.py:1488: in _run_raw_task
self.refresh_from_db(session=session)
airflow/utils/session.py:74: in wrapper
return func(*args, **kwargs)
airflow/models/taskinstance.py:866: in refresh_from_db
ti = qry.one_or_none()
/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/query.py:2850: in one_or_none
return self._iter().one_or_none()
/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/query.py:2916: in _iter
result = self.session.execute(
/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/session.py:1717: in execute
result = conn._execute_20(statement, params or {}, execution_options)
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1710: in _execute_20
return meth(self, args_10style, kwargs_10style, execution_options)
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/elements.py:334: in _execute_on_connection
return connection._execute_clauseelement(
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1577: in _execute_clauseelement
ret = self._execute_context(
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1816: in _execute_context
self._handle_dbapi_exception(
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:2134: in _handle_dbapi_exception
util.raise_(
/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py:211: in raise_
raise exception
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1810: in _execute_context
context = constructor(
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1020: in _init_compiled
self.cursor = self.create_cursor()
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1391: in create_cursor
return self.create_default_cursor()
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1394: in create_default_cursor
return self._dbapi_connection.cursor()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <sqlalchemy.pool.base._ConnectionFairy object at 0x7f5a70b2add0>
args = (), kwargs = {}
def cursor(self, *args, **kwargs):
"""Return a new DBAPI cursor for the underlying connection.
This method is a proxy for the ``connection.cursor()`` DBAPI
method.
"""
> return self.dbapi_connection.cursor(*args, **kwargs)
E sqlalchemy.exc.ProgrammingError: (sqlite3.ProgrammingError) SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 140026872592128 and this is thread id 140028343548800.
E [SQL: SELECT task_instance.task_id AS task_instance_task_id, task_instance.dag_id AS task_instance_dag_id, task_instance.run_id AS task_instance_run_id, task_instance.map_index AS task_instance_map_index, task_instance.start_date AS task_instance_start_date, task_instance.end_date AS task_instance_end_date, task_instance.duration AS task_instance_duration, task_instance.state AS task_instance_state, task_instance.try_number AS task_instance_try_number, task_instance.max_tries AS task_instance_max_tries, task_instance.hostname AS task_instance_hostname, task_instance.unixname AS task_instance_unixname, task_instance.job_id AS task_instance_job_id, task_instance.pool AS task_instance_pool, task_instance.pool_slots AS task_instance_pool_slots, task_instance.queue AS task_instance_queue, task_instance.priority_weight AS task_instance_priority_weight, task_instance.operator AS task_instance_operator, task_instance.custom_operator_name AS task_instance_custom_operator_name, task_instance.queued_dttm AS task_instance_queued_dttm, task_instance.queued_by_job_id AS task_instance_queued_by_job_id, task_instance.pid AS task_instance_pid, task_instance.executor_config AS task_instance_executor_config, task_instance.updated_at AS task_instance_updated_at, task_instance.external_executor_id AS task_instance_external_executor_id, task_instance.trigger_id AS task_instance_trigger_id, task_instance.trigger_timeout AS task_instance_trigger_timeout, task_instance.next_method AS task_instance_next_method, task_instance.next_kwargs AS task_instance_next_kwargs E FROM task_instance E WHERE task_instance.dag_id = ? AND task_instance.task_id = ? AND task_instance.run_id = ? AND task_instance.map_index = ?]
E (Background on this error at: https://sqlalche.me/e/14/f405)
/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py:1133: ProgrammingError
During handling of the above exception, another exception occurred:
self = <sqlalchemy.future.engine.Connection object at 0x7f5a70b28c70>
def _rollback_impl(self):
assert not self.__branch_from
if self._has_events or self.engine._has_events:
self.dispatch.rollback(self)
if self._still_open_and_dbapi_connection_is_valid:
if self._echo:
if self._is_autocommit_isolation():
self._log_info(
"ROLLBACK using DBAPI connection.rollback(), "
"DBAPI should ignore due to autocommit mode"
)
else:
self._log_info("ROLLBACK")
try:
> self.engine.dialect.do_rollback(self.connection)
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1062: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <sqlalchemy.dialects.sqlite.pysqlite.SQLiteDialect_pysqlite object at 0x7f5ad1451db0>
dbapi_connection = <sqlalchemy.pool.base._ConnectionFairy object at 0x7f5a70b2add0>
def do_rollback(self, dbapi_connection):
> dbapi_connection.rollback()
E sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 140026872592128 and this is thread id 140028343548800.
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:683: ProgrammingError

@potiuk

Copy link
Copy Markdown
MemberAuthor

It's a bit strange what happens though.... The @provide_session in run_method does actually call close_session in context manager, so this is quite strange... But let's see after merge if we can get it more stable.

@potiukpotiuk added this to the Airflow 2.7.0 milestone Aug 6, 2023
@potiuk
potiuk merged commit 3dd0c99 into apache:mainAug 6, 2023
@potiuk
potiuk deleted the unflake-test-xcom-args-map branch August 6, 2023 11:24
potiuk added a commit to potiuk/airflow that referenced this pull request Aug 6, 2023
Using same session in different steps of the same test has the
potential of not flishing/committing the changes between.
Seems that the apache#33150 traded one flakiness with another. Attempting to
make sure that the flash/commit is executed before the second run.
Error:
The test RuntimeError: number of values in row (0) differ from number of
column processors (29)
The error is strange however and indicates a bug in sqlite library.
potiuk added a commit that referenced this pull request Aug 6, 2023
)
Using same session in different steps of the same test has the
potential of not flishing/committing the changes between.
Seems that the #33150 traded one flakiness with another. Attempting to
make sure that the flash/commit is executed before the second run.
Error:
The test RuntimeError: number of values in row (0) differ from number of
column processors (29)
The error is strange however and indicates a bug in sqlite library.
@ephraimbuddyephraimbuddy added the changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) label Aug 8, 2023
ephraimbuddy pushed a commit that referenced this pull request Aug 8, 2023
Similarly to #33145 - this is an attempt to stabilise flaky tests
for the test_xcom_arg_map.
Even if the mechanism is not entirely clear (provide_session should
also close the connection) seems like using pytest-fixture provided
session works better than relying on a new session created in run()
methods.
(cherry picked from commit 3dd0c99)
ephraimbuddy pushed a commit that referenced this pull request Aug 8, 2023
)
Using same session in different steps of the same test has the
potential of not flishing/committing the changes between.
Seems that the #33150 traded one flakiness with another. Attempting to
make sure that the flash/commit is executed before the second run.
Error:
The test RuntimeError: number of values in row (0) differ from number of
column processors (29)
The error is strange however and indicates a bug in sqlite library.
(cherry picked from commit 6b21b79)
ephraimbuddy pushed a commit that referenced this pull request Aug 8, 2023
)
Using same session in different steps of the same test has the
potential of not flishing/committing the changes between.
Seems that the #33150 traded one flakiness with another. Attempting to
make sure that the flash/commit is executed before the second run.
Error:
The test RuntimeError: number of values in row (0) differ from number of
column processors (29)
The error is strange however and indicates a bug in sqlite library.
(cherry picked from commit 6b21b79)
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog:skipChanges that should be skipped from the changelog (CI, tests, etc..)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@potiuk@ephraimbuddy@hussein-awala
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Attempt to stabilise tests for xcom_arg_map by potiuk · Pull Request #33150 · apache/airflow · GitHub
Skip to content

Attempt to stabilise tests for xcom_arg_map - #33150

Merged
potiuk merged 1 commit into
apache:mainfrom
potiuk:unflake-test-xcom-args-map
Aug 6, 2023
Merged

Attempt to stabilise tests for xcom_arg_map#33150
potiuk merged 1 commit into
apache:mainfrom
potiuk:unflake-test-xcom-args-map

Conversation

@potiuk

Copy link
Copy Markdown
Member

Similarly to #33145 - this is an attempt to stabilise flaky tests for the test_xcom_arg_map.

Even if the mechanism is not entirely clear (provide_session should also close the connection) seems like using pytest-fixture provided session works better than relying on a new session created in run() methods.


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
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.

Similarly to apache#33145 - this is an attempt to stabilise flaky tests
for the test_xcom_arg_map.
Even if the mechanism is not entirely clear (provide_session should
also close the connection) seems like using pytest-fixture provided
session works better than relying on a new session created in run()
methods.
@potiuk

Copy link
Copy Markdown
MemberAuthor

Example failure: https://github.com/apache/airflow/actions/runs/5775967682/job/15654656922?pr=32991

________________________ test_xcom_map_error_fails_task ________________________
self = <sqlalchemy.future.engine.Connection object at 0x7f5a70b28c70>
dialect = <sqlalchemy.dialects.sqlite.pysqlite.SQLiteDialect_pysqlite object at 0x7f5ad1451db0>
constructor = <bound method DefaultExecutionContext._init_compiled of <class 'sqlalchemy.dialects.sqlite.base.SQLiteExecutionContext'>>
statement = <sqlalchemy.dialects.sqlite.base.SQLiteCompiler object at 0x7f5ad06c7970>
parameters = []
execution_options = immutabledict({'_sa_orm_load_options': default_load_options(_legacy_uniquing=True), '_result_disable_adapt_to_context': True, 'future_result': True})
args = (<sqlalchemy.dialects.sqlite.base.SQLiteCompiler object at 0x7f5ad06c7970>, [], <sqlalchemy.sql.selectable.Select obje...0720 run_id)s', 'test', type_=String(length=250)), BindParameter('%(140026414543824 map_index)s', 0, type_=Integer())])
kw = {'cache_hit': symbol('CACHE_HIT')}
branched = <sqlalchemy.future.engine.Connection object at 0x7f5a70b28c70>
yp = None
conn = <sqlalchemy.pool.base._ConnectionFairy object at 0x7f5a70b2add0>
def _execute_context(
self,
dialect,
constructor,
statement,
parameters,
execution_options,
*args,
**kw
):
"""Create an :class:`.ExecutionContext` and execute, returning
a :class:`_engine.CursorResult`."""
branched = self
if self.__branch_from:
# if this is a "branched" connection, do everything in terms
# of the "root" connection, *except* for .close(), which is
# the only feature that branching provides
self = self.__branch_from
if execution_options:
yp = execution_options.get("yield_per", None)
if yp:
execution_options = execution_options.union(
{"stream_results": True, "max_row_buffer": yp}
)
try:
conn = self._dbapi_connection
if conn is None:
conn = self._revalidate_connection()
> context = constructor(
dialect, self, conn, execution_options, *args, **kw
)
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1810: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1020: in _init_compiled
self.cursor = self.create_cursor()
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1391: in create_cursor
return self.create_default_cursor()
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1394: in create_default_cursor
return self._dbapi_connection.cursor()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <sqlalchemy.pool.base._ConnectionFairy object at 0x7f5a70b2add0>
args = (), kwargs = {}
def cursor(self, *args, **kwargs):
"""Return a new DBAPI cursor for the underlying connection.
This method is a proxy for the ``connection.cursor()`` DBAPI
method.
"""
> return self.dbapi_connection.cursor(*args, **kwargs)
E sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 140026872592128 and this is thread id 140028343548800.
/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py:1133: ProgrammingError
The above exception was the direct cause of the following exception:
@contextlib.contextmanager
def create_session() -> Generator[settings.SASession, None, None]:
"""Contextmanager that will create and teardown a session."""
Session = getattr(settings, "Session", None)
if Session is None:
raise RuntimeError("Session must be set before!")
session = Session()
try:
> yield session
airflow/utils/session.py:36: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ airflow/utils/session.py:77: in wrapper
return func(*args, session=session, **kwargs)
airflow/models/taskinstance.py:1840: in run
self._run_raw_task(
airflow/utils/session.py:74: in wrapper
return func(*args, **kwargs)
airflow/models/taskinstance.py:1488: in _run_raw_task
self.refresh_from_db(session=session)
airflow/utils/session.py:74: in wrapper
return func(*args, **kwargs)
airflow/models/taskinstance.py:866: in refresh_from_db
ti = qry.one_or_none()
/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/query.py:2850: in one_or_none
return self._iter().one_or_none()
/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/query.py:2916: in _iter
result = self.session.execute(
/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/session.py:1717: in execute
result = conn._execute_20(statement, params or {}, execution_options)
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1710: in _execute_20
return meth(self, args_10style, kwargs_10style, execution_options)
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/elements.py:334: in _execute_on_connection
return connection._execute_clauseelement(
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1577: in _execute_clauseelement
ret = self._execute_context(
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1816: in _execute_context
self._handle_dbapi_exception(
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:2134: in _handle_dbapi_exception
util.raise_(
/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py:211: in raise_
raise exception
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1810: in _execute_context
context = constructor(
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1020: in _init_compiled
self.cursor = self.create_cursor()
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1391: in create_cursor
return self.create_default_cursor()
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1394: in create_default_cursor
return self._dbapi_connection.cursor()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <sqlalchemy.pool.base._ConnectionFairy object at 0x7f5a70b2add0>
args = (), kwargs = {}
def cursor(self, *args, **kwargs):
"""Return a new DBAPI cursor for the underlying connection.
This method is a proxy for the ``connection.cursor()`` DBAPI
method.
"""
> return self.dbapi_connection.cursor(*args, **kwargs)
E sqlalchemy.exc.ProgrammingError: (sqlite3.ProgrammingError) SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 140026872592128 and this is thread id 140028343548800.
E [SQL: SELECT task_instance.task_id AS task_instance_task_id, task_instance.dag_id AS task_instance_dag_id, task_instance.run_id AS task_instance_run_id, task_instance.map_index AS task_instance_map_index, task_instance.start_date AS task_instance_start_date, task_instance.end_date AS task_instance_end_date, task_instance.duration AS task_instance_duration, task_instance.state AS task_instance_state, task_instance.try_number AS task_instance_try_number, task_instance.max_tries AS task_instance_max_tries, task_instance.hostname AS task_instance_hostname, task_instance.unixname AS task_instance_unixname, task_instance.job_id AS task_instance_job_id, task_instance.pool AS task_instance_pool, task_instance.pool_slots AS task_instance_pool_slots, task_instance.queue AS task_instance_queue, task_instance.priority_weight AS task_instance_priority_weight, task_instance.operator AS task_instance_operator, task_instance.custom_operator_name AS task_instance_custom_operator_name, task_instance.queued_dttm AS task_instance_queued_dttm, task_instance.queued_by_job_id AS task_instance_queued_by_job_id, task_instance.pid AS task_instance_pid, task_instance.executor_config AS task_instance_executor_config, task_instance.updated_at AS task_instance_updated_at, task_instance.external_executor_id AS task_instance_external_executor_id, task_instance.trigger_id AS task_instance_trigger_id, task_instance.trigger_timeout AS task_instance_trigger_timeout, task_instance.next_method AS task_instance_next_method, task_instance.next_kwargs AS task_instance_next_kwargs E FROM task_instance E WHERE task_instance.dag_id = ? AND task_instance.task_id = ? AND task_instance.run_id = ? AND task_instance.map_index = ?]
E (Background on this error at: https://sqlalche.me/e/14/f405)
/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py:1133: ProgrammingError
During handling of the above exception, another exception occurred:
self = <sqlalchemy.future.engine.Connection object at 0x7f5a70b28c70>
def _rollback_impl(self):
assert not self.__branch_from
if self._has_events or self.engine._has_events:
self.dispatch.rollback(self)
if self._still_open_and_dbapi_connection_is_valid:
if self._echo:
if self._is_autocommit_isolation():
self._log_info(
"ROLLBACK using DBAPI connection.rollback(), "
"DBAPI should ignore due to autocommit mode"
)
else:
self._log_info("ROLLBACK")
try:
> self.engine.dialect.do_rollback(self.connection)
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1062: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <sqlalchemy.dialects.sqlite.pysqlite.SQLiteDialect_pysqlite object at 0x7f5ad1451db0>
dbapi_connection = <sqlalchemy.pool.base._ConnectionFairy object at 0x7f5a70b2add0>
def do_rollback(self, dbapi_connection):
> dbapi_connection.rollback()
E sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 140026872592128 and this is thread id 140028343548800.
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:683: ProgrammingError

@potiuk

Copy link
Copy Markdown
MemberAuthor

It's a bit strange what happens though.... The @provide_session in run_method does actually call close_session in context manager, so this is quite strange... But let's see after merge if we can get it more stable.

@potiukpotiuk added this to the Airflow 2.7.0 milestone Aug 6, 2023
@potiuk
potiuk merged commit 3dd0c99 into apache:mainAug 6, 2023
@potiuk
potiuk deleted the unflake-test-xcom-args-map branch August 6, 2023 11:24
potiuk added a commit to potiuk/airflow that referenced this pull request Aug 6, 2023
Using same session in different steps of the same test has the
potential of not flishing/committing the changes between.
Seems that the apache#33150 traded one flakiness with another. Attempting to
make sure that the flash/commit is executed before the second run.
Error:
The test RuntimeError: number of values in row (0) differ from number of
column processors (29)
The error is strange however and indicates a bug in sqlite library.
potiuk added a commit that referenced this pull request Aug 6, 2023
)
Using same session in different steps of the same test has the
potential of not flishing/committing the changes between.
Seems that the #33150 traded one flakiness with another. Attempting to
make sure that the flash/commit is executed before the second run.
Error:
The test RuntimeError: number of values in row (0) differ from number of
column processors (29)
The error is strange however and indicates a bug in sqlite library.
@ephraimbuddyephraimbuddy added the changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) label Aug 8, 2023
ephraimbuddy pushed a commit that referenced this pull request Aug 8, 2023
Similarly to #33145 - this is an attempt to stabilise flaky tests
for the test_xcom_arg_map.
Even if the mechanism is not entirely clear (provide_session should
also close the connection) seems like using pytest-fixture provided
session works better than relying on a new session created in run()
methods.
(cherry picked from commit 3dd0c99)
ephraimbuddy pushed a commit that referenced this pull request Aug 8, 2023
)
Using same session in different steps of the same test has the
potential of not flishing/committing the changes between.
Seems that the #33150 traded one flakiness with another. Attempting to
make sure that the flash/commit is executed before the second run.
Error:
The test RuntimeError: number of values in row (0) differ from number of
column processors (29)
The error is strange however and indicates a bug in sqlite library.
(cherry picked from commit 6b21b79)
ephraimbuddy pushed a commit that referenced this pull request Aug 8, 2023
)
Using same session in different steps of the same test has the
potential of not flishing/committing the changes between.
Seems that the #33150 traded one flakiness with another. Attempting to
make sure that the flash/commit is executed before the second run.
Error:
The test RuntimeError: number of values in row (0) differ from number of
column processors (29)
The error is strange however and indicates a bug in sqlite library.
(cherry picked from commit 6b21b79)
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog:skipChanges that should be skipped from the changelog (CI, tests, etc..)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@potiuk@ephraimbuddy@hussein-awala
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Attempt to stabilise tests for xcom_arg_map by potiuk · Pull Request #33150 · apache/airflow · GitHub
Skip to content

Attempt to stabilise tests for xcom_arg_map - #33150

Merged
potiuk merged 1 commit into
apache:mainfrom
potiuk:unflake-test-xcom-args-map
Aug 6, 2023
Merged

Attempt to stabilise tests for xcom_arg_map#33150
potiuk merged 1 commit into
apache:mainfrom
potiuk:unflake-test-xcom-args-map

Conversation

@potiuk

Copy link
Copy Markdown
Member

Similarly to #33145 - this is an attempt to stabilise flaky tests for the test_xcom_arg_map.

Even if the mechanism is not entirely clear (provide_session should also close the connection) seems like using pytest-fixture provided session works better than relying on a new session created in run() methods.


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
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.

Similarly to apache#33145 - this is an attempt to stabilise flaky tests
for the test_xcom_arg_map.
Even if the mechanism is not entirely clear (provide_session should
also close the connection) seems like using pytest-fixture provided
session works better than relying on a new session created in run()
methods.
@potiuk

Copy link
Copy Markdown
MemberAuthor

Example failure: https://github.com/apache/airflow/actions/runs/5775967682/job/15654656922?pr=32991

________________________ test_xcom_map_error_fails_task ________________________
self = <sqlalchemy.future.engine.Connection object at 0x7f5a70b28c70>
dialect = <sqlalchemy.dialects.sqlite.pysqlite.SQLiteDialect_pysqlite object at 0x7f5ad1451db0>
constructor = <bound method DefaultExecutionContext._init_compiled of <class 'sqlalchemy.dialects.sqlite.base.SQLiteExecutionContext'>>
statement = <sqlalchemy.dialects.sqlite.base.SQLiteCompiler object at 0x7f5ad06c7970>
parameters = []
execution_options = immutabledict({'_sa_orm_load_options': default_load_options(_legacy_uniquing=True), '_result_disable_adapt_to_context': True, 'future_result': True})
args = (<sqlalchemy.dialects.sqlite.base.SQLiteCompiler object at 0x7f5ad06c7970>, [], <sqlalchemy.sql.selectable.Select obje...0720 run_id)s', 'test', type_=String(length=250)), BindParameter('%(140026414543824 map_index)s', 0, type_=Integer())])
kw = {'cache_hit': symbol('CACHE_HIT')}
branched = <sqlalchemy.future.engine.Connection object at 0x7f5a70b28c70>
yp = None
conn = <sqlalchemy.pool.base._ConnectionFairy object at 0x7f5a70b2add0>
def _execute_context(
self,
dialect,
constructor,
statement,
parameters,
execution_options,
*args,
**kw
):
"""Create an :class:`.ExecutionContext` and execute, returning
a :class:`_engine.CursorResult`."""
branched = self
if self.__branch_from:
# if this is a "branched" connection, do everything in terms
# of the "root" connection, *except* for .close(), which is
# the only feature that branching provides
self = self.__branch_from
if execution_options:
yp = execution_options.get("yield_per", None)
if yp:
execution_options = execution_options.union(
{"stream_results": True, "max_row_buffer": yp}
)
try:
conn = self._dbapi_connection
if conn is None:
conn = self._revalidate_connection()
> context = constructor(
dialect, self, conn, execution_options, *args, **kw
)
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1810: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1020: in _init_compiled
self.cursor = self.create_cursor()
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1391: in create_cursor
return self.create_default_cursor()
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1394: in create_default_cursor
return self._dbapi_connection.cursor()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <sqlalchemy.pool.base._ConnectionFairy object at 0x7f5a70b2add0>
args = (), kwargs = {}
def cursor(self, *args, **kwargs):
"""Return a new DBAPI cursor for the underlying connection.
This method is a proxy for the ``connection.cursor()`` DBAPI
method.
"""
> return self.dbapi_connection.cursor(*args, **kwargs)
E sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 140026872592128 and this is thread id 140028343548800.
/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py:1133: ProgrammingError
The above exception was the direct cause of the following exception:
@contextlib.contextmanager
def create_session() -> Generator[settings.SASession, None, None]:
"""Contextmanager that will create and teardown a session."""
Session = getattr(settings, "Session", None)
if Session is None:
raise RuntimeError("Session must be set before!")
session = Session()
try:
> yield session
airflow/utils/session.py:36: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ airflow/utils/session.py:77: in wrapper
return func(*args, session=session, **kwargs)
airflow/models/taskinstance.py:1840: in run
self._run_raw_task(
airflow/utils/session.py:74: in wrapper
return func(*args, **kwargs)
airflow/models/taskinstance.py:1488: in _run_raw_task
self.refresh_from_db(session=session)
airflow/utils/session.py:74: in wrapper
return func(*args, **kwargs)
airflow/models/taskinstance.py:866: in refresh_from_db
ti = qry.one_or_none()
/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/query.py:2850: in one_or_none
return self._iter().one_or_none()
/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/query.py:2916: in _iter
result = self.session.execute(
/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/session.py:1717: in execute
result = conn._execute_20(statement, params or {}, execution_options)
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1710: in _execute_20
return meth(self, args_10style, kwargs_10style, execution_options)
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/elements.py:334: in _execute_on_connection
return connection._execute_clauseelement(
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1577: in _execute_clauseelement
ret = self._execute_context(
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1816: in _execute_context
self._handle_dbapi_exception(
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:2134: in _handle_dbapi_exception
util.raise_(
/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py:211: in raise_
raise exception
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1810: in _execute_context
context = constructor(
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1020: in _init_compiled
self.cursor = self.create_cursor()
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1391: in create_cursor
return self.create_default_cursor()
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1394: in create_default_cursor
return self._dbapi_connection.cursor()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <sqlalchemy.pool.base._ConnectionFairy object at 0x7f5a70b2add0>
args = (), kwargs = {}
def cursor(self, *args, **kwargs):
"""Return a new DBAPI cursor for the underlying connection.
This method is a proxy for the ``connection.cursor()`` DBAPI
method.
"""
> return self.dbapi_connection.cursor(*args, **kwargs)
E sqlalchemy.exc.ProgrammingError: (sqlite3.ProgrammingError) SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 140026872592128 and this is thread id 140028343548800.
E [SQL: SELECT task_instance.task_id AS task_instance_task_id, task_instance.dag_id AS task_instance_dag_id, task_instance.run_id AS task_instance_run_id, task_instance.map_index AS task_instance_map_index, task_instance.start_date AS task_instance_start_date, task_instance.end_date AS task_instance_end_date, task_instance.duration AS task_instance_duration, task_instance.state AS task_instance_state, task_instance.try_number AS task_instance_try_number, task_instance.max_tries AS task_instance_max_tries, task_instance.hostname AS task_instance_hostname, task_instance.unixname AS task_instance_unixname, task_instance.job_id AS task_instance_job_id, task_instance.pool AS task_instance_pool, task_instance.pool_slots AS task_instance_pool_slots, task_instance.queue AS task_instance_queue, task_instance.priority_weight AS task_instance_priority_weight, task_instance.operator AS task_instance_operator, task_instance.custom_operator_name AS task_instance_custom_operator_name, task_instance.queued_dttm AS task_instance_queued_dttm, task_instance.queued_by_job_id AS task_instance_queued_by_job_id, task_instance.pid AS task_instance_pid, task_instance.executor_config AS task_instance_executor_config, task_instance.updated_at AS task_instance_updated_at, task_instance.external_executor_id AS task_instance_external_executor_id, task_instance.trigger_id AS task_instance_trigger_id, task_instance.trigger_timeout AS task_instance_trigger_timeout, task_instance.next_method AS task_instance_next_method, task_instance.next_kwargs AS task_instance_next_kwargs E FROM task_instance E WHERE task_instance.dag_id = ? AND task_instance.task_id = ? AND task_instance.run_id = ? AND task_instance.map_index = ?]
E (Background on this error at: https://sqlalche.me/e/14/f405)
/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py:1133: ProgrammingError
During handling of the above exception, another exception occurred:
self = <sqlalchemy.future.engine.Connection object at 0x7f5a70b28c70>
def _rollback_impl(self):
assert not self.__branch_from
if self._has_events or self.engine._has_events:
self.dispatch.rollback(self)
if self._still_open_and_dbapi_connection_is_valid:
if self._echo:
if self._is_autocommit_isolation():
self._log_info(
"ROLLBACK using DBAPI connection.rollback(), "
"DBAPI should ignore due to autocommit mode"
)
else:
self._log_info("ROLLBACK")
try:
> self.engine.dialect.do_rollback(self.connection)
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1062: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <sqlalchemy.dialects.sqlite.pysqlite.SQLiteDialect_pysqlite object at 0x7f5ad1451db0>
dbapi_connection = <sqlalchemy.pool.base._ConnectionFairy object at 0x7f5a70b2add0>
def do_rollback(self, dbapi_connection):
> dbapi_connection.rollback()
E sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 140026872592128 and this is thread id 140028343548800.
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:683: ProgrammingError

@potiuk

Copy link
Copy Markdown
MemberAuthor

It's a bit strange what happens though.... The @provide_session in run_method does actually call close_session in context manager, so this is quite strange... But let's see after merge if we can get it more stable.

@potiukpotiuk added this to the Airflow 2.7.0 milestone Aug 6, 2023
@potiuk
potiuk merged commit 3dd0c99 into apache:mainAug 6, 2023
@potiuk
potiuk deleted the unflake-test-xcom-args-map branch August 6, 2023 11:24
potiuk added a commit to potiuk/airflow that referenced this pull request Aug 6, 2023
Using same session in different steps of the same test has the
potential of not flishing/committing the changes between.
Seems that the apache#33150 traded one flakiness with another. Attempting to
make sure that the flash/commit is executed before the second run.
Error:
The test RuntimeError: number of values in row (0) differ from number of
column processors (29)
The error is strange however and indicates a bug in sqlite library.
potiuk added a commit that referenced this pull request Aug 6, 2023
)
Using same session in different steps of the same test has the
potential of not flishing/committing the changes between.
Seems that the #33150 traded one flakiness with another. Attempting to
make sure that the flash/commit is executed before the second run.
Error:
The test RuntimeError: number of values in row (0) differ from number of
column processors (29)
The error is strange however and indicates a bug in sqlite library.
@ephraimbuddyephraimbuddy added the changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) label Aug 8, 2023
ephraimbuddy pushed a commit that referenced this pull request Aug 8, 2023
Similarly to #33145 - this is an attempt to stabilise flaky tests
for the test_xcom_arg_map.
Even if the mechanism is not entirely clear (provide_session should
also close the connection) seems like using pytest-fixture provided
session works better than relying on a new session created in run()
methods.
(cherry picked from commit 3dd0c99)
ephraimbuddy pushed a commit that referenced this pull request Aug 8, 2023
)
Using same session in different steps of the same test has the
potential of not flishing/committing the changes between.
Seems that the #33150 traded one flakiness with another. Attempting to
make sure that the flash/commit is executed before the second run.
Error:
The test RuntimeError: number of values in row (0) differ from number of
column processors (29)
The error is strange however and indicates a bug in sqlite library.
(cherry picked from commit 6b21b79)
ephraimbuddy pushed a commit that referenced this pull request Aug 8, 2023
)
Using same session in different steps of the same test has the
potential of not flishing/committing the changes between.
Seems that the #33150 traded one flakiness with another. Attempting to
make sure that the flash/commit is executed before the second run.
Error:
The test RuntimeError: number of values in row (0) differ from number of
column processors (29)
The error is strange however and indicates a bug in sqlite library.
(cherry picked from commit 6b21b79)
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog:skipChanges that should be skipped from the changelog (CI, tests, etc..)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@potiuk@ephraimbuddy@hussein-awala
, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })(); Attempt to stabilise tests for xcom_arg_map by potiuk · Pull Request #33150 · apache/airflow · GitHub
Skip to content

Attempt to stabilise tests for xcom_arg_map - #33150

Merged
potiuk merged 1 commit into
apache:mainfrom
potiuk:unflake-test-xcom-args-map
Aug 6, 2023
Merged

Attempt to stabilise tests for xcom_arg_map#33150
potiuk merged 1 commit into
apache:mainfrom
potiuk:unflake-test-xcom-args-map

Conversation

@potiuk

Copy link
Copy Markdown
Member

Similarly to #33145 - this is an attempt to stabilise flaky tests for the test_xcom_arg_map.

Even if the mechanism is not entirely clear (provide_session should also close the connection) seems like using pytest-fixture provided session works better than relying on a new session created in run() methods.


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
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.

Similarly to apache#33145 - this is an attempt to stabilise flaky tests
for the test_xcom_arg_map.
Even if the mechanism is not entirely clear (provide_session should
also close the connection) seems like using pytest-fixture provided
session works better than relying on a new session created in run()
methods.
@potiuk

Copy link
Copy Markdown
MemberAuthor

Example failure: https://github.com/apache/airflow/actions/runs/5775967682/job/15654656922?pr=32991

________________________ test_xcom_map_error_fails_task ________________________
self = <sqlalchemy.future.engine.Connection object at 0x7f5a70b28c70>
dialect = <sqlalchemy.dialects.sqlite.pysqlite.SQLiteDialect_pysqlite object at 0x7f5ad1451db0>
constructor = <bound method DefaultExecutionContext._init_compiled of <class 'sqlalchemy.dialects.sqlite.base.SQLiteExecutionContext'>>
statement = <sqlalchemy.dialects.sqlite.base.SQLiteCompiler object at 0x7f5ad06c7970>
parameters = []
execution_options = immutabledict({'_sa_orm_load_options': default_load_options(_legacy_uniquing=True), '_result_disable_adapt_to_context': True, 'future_result': True})
args = (<sqlalchemy.dialects.sqlite.base.SQLiteCompiler object at 0x7f5ad06c7970>, [], <sqlalchemy.sql.selectable.Select obje...0720 run_id)s', 'test', type_=String(length=250)), BindParameter('%(140026414543824 map_index)s', 0, type_=Integer())])
kw = {'cache_hit': symbol('CACHE_HIT')}
branched = <sqlalchemy.future.engine.Connection object at 0x7f5a70b28c70>
yp = None
conn = <sqlalchemy.pool.base._ConnectionFairy object at 0x7f5a70b2add0>
def _execute_context(
self,
dialect,
constructor,
statement,
parameters,
execution_options,
*args,
**kw
):
"""Create an :class:`.ExecutionContext` and execute, returning
a :class:`_engine.CursorResult`."""
branched = self
if self.__branch_from:
# if this is a "branched" connection, do everything in terms
# of the "root" connection, *except* for .close(), which is
# the only feature that branching provides
self = self.__branch_from
if execution_options:
yp = execution_options.get("yield_per", None)
if yp:
execution_options = execution_options.union(
{"stream_results": True, "max_row_buffer": yp}
)
try:
conn = self._dbapi_connection
if conn is None:
conn = self._revalidate_connection()
> context = constructor(
dialect, self, conn, execution_options, *args, **kw
)
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1810: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1020: in _init_compiled
self.cursor = self.create_cursor()
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1391: in create_cursor
return self.create_default_cursor()
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1394: in create_default_cursor
return self._dbapi_connection.cursor()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <sqlalchemy.pool.base._ConnectionFairy object at 0x7f5a70b2add0>
args = (), kwargs = {}
def cursor(self, *args, **kwargs):
"""Return a new DBAPI cursor for the underlying connection.
This method is a proxy for the ``connection.cursor()`` DBAPI
method.
"""
> return self.dbapi_connection.cursor(*args, **kwargs)
E sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 140026872592128 and this is thread id 140028343548800.
/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py:1133: ProgrammingError
The above exception was the direct cause of the following exception:
@contextlib.contextmanager
def create_session() -> Generator[settings.SASession, None, None]:
"""Contextmanager that will create and teardown a session."""
Session = getattr(settings, "Session", None)
if Session is None:
raise RuntimeError("Session must be set before!")
session = Session()
try:
> yield session
airflow/utils/session.py:36: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ airflow/utils/session.py:77: in wrapper
return func(*args, session=session, **kwargs)
airflow/models/taskinstance.py:1840: in run
self._run_raw_task(
airflow/utils/session.py:74: in wrapper
return func(*args, **kwargs)
airflow/models/taskinstance.py:1488: in _run_raw_task
self.refresh_from_db(session=session)
airflow/utils/session.py:74: in wrapper
return func(*args, **kwargs)
airflow/models/taskinstance.py:866: in refresh_from_db
ti = qry.one_or_none()
/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/query.py:2850: in one_or_none
return self._iter().one_or_none()
/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/query.py:2916: in _iter
result = self.session.execute(
/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/session.py:1717: in execute
result = conn._execute_20(statement, params or {}, execution_options)
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1710: in _execute_20
return meth(self, args_10style, kwargs_10style, execution_options)
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/elements.py:334: in _execute_on_connection
return connection._execute_clauseelement(
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1577: in _execute_clauseelement
ret = self._execute_context(
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1816: in _execute_context
self._handle_dbapi_exception(
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:2134: in _handle_dbapi_exception
util.raise_(
/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py:211: in raise_
raise exception
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1810: in _execute_context
context = constructor(
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1020: in _init_compiled
self.cursor = self.create_cursor()
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1391: in create_cursor
return self.create_default_cursor()
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:1394: in create_default_cursor
return self._dbapi_connection.cursor()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <sqlalchemy.pool.base._ConnectionFairy object at 0x7f5a70b2add0>
args = (), kwargs = {}
def cursor(self, *args, **kwargs):
"""Return a new DBAPI cursor for the underlying connection.
This method is a proxy for the ``connection.cursor()`` DBAPI
method.
"""
> return self.dbapi_connection.cursor(*args, **kwargs)
E sqlalchemy.exc.ProgrammingError: (sqlite3.ProgrammingError) SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 140026872592128 and this is thread id 140028343548800.
E [SQL: SELECT task_instance.task_id AS task_instance_task_id, task_instance.dag_id AS task_instance_dag_id, task_instance.run_id AS task_instance_run_id, task_instance.map_index AS task_instance_map_index, task_instance.start_date AS task_instance_start_date, task_instance.end_date AS task_instance_end_date, task_instance.duration AS task_instance_duration, task_instance.state AS task_instance_state, task_instance.try_number AS task_instance_try_number, task_instance.max_tries AS task_instance_max_tries, task_instance.hostname AS task_instance_hostname, task_instance.unixname AS task_instance_unixname, task_instance.job_id AS task_instance_job_id, task_instance.pool AS task_instance_pool, task_instance.pool_slots AS task_instance_pool_slots, task_instance.queue AS task_instance_queue, task_instance.priority_weight AS task_instance_priority_weight, task_instance.operator AS task_instance_operator, task_instance.custom_operator_name AS task_instance_custom_operator_name, task_instance.queued_dttm AS task_instance_queued_dttm, task_instance.queued_by_job_id AS task_instance_queued_by_job_id, task_instance.pid AS task_instance_pid, task_instance.executor_config AS task_instance_executor_config, task_instance.updated_at AS task_instance_updated_at, task_instance.external_executor_id AS task_instance_external_executor_id, task_instance.trigger_id AS task_instance_trigger_id, task_instance.trigger_timeout AS task_instance_trigger_timeout, task_instance.next_method AS task_instance_next_method, task_instance.next_kwargs AS task_instance_next_kwargs E FROM task_instance E WHERE task_instance.dag_id = ? AND task_instance.task_id = ? AND task_instance.run_id = ? AND task_instance.map_index = ?]
E (Background on this error at: https://sqlalche.me/e/14/f405)
/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py:1133: ProgrammingError
During handling of the above exception, another exception occurred:
self = <sqlalchemy.future.engine.Connection object at 0x7f5a70b28c70>
def _rollback_impl(self):
assert not self.__branch_from
if self._has_events or self.engine._has_events:
self.dispatch.rollback(self)
if self._still_open_and_dbapi_connection_is_valid:
if self._echo:
if self._is_autocommit_isolation():
self._log_info(
"ROLLBACK using DBAPI connection.rollback(), "
"DBAPI should ignore due to autocommit mode"
)
else:
self._log_info("ROLLBACK")
try:
> self.engine.dialect.do_rollback(self.connection)
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1062: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <sqlalchemy.dialects.sqlite.pysqlite.SQLiteDialect_pysqlite object at 0x7f5ad1451db0>
dbapi_connection = <sqlalchemy.pool.base._ConnectionFairy object at 0x7f5a70b2add0>
def do_rollback(self, dbapi_connection):
> dbapi_connection.rollback()
E sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 140026872592128 and this is thread id 140028343548800.
/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py:683: ProgrammingError

@potiuk

Copy link
Copy Markdown
MemberAuthor

It's a bit strange what happens though.... The @provide_session in run_method does actually call close_session in context manager, so this is quite strange... But let's see after merge if we can get it more stable.

@potiukpotiuk added this to the Airflow 2.7.0 milestone Aug 6, 2023
@potiuk
potiuk merged commit 3dd0c99 into apache:mainAug 6, 2023
@potiuk
potiuk deleted the unflake-test-xcom-args-map branch August 6, 2023 11:24
potiuk added a commit to potiuk/airflow that referenced this pull request Aug 6, 2023
Using same session in different steps of the same test has the
potential of not flishing/committing the changes between.
Seems that the apache#33150 traded one flakiness with another. Attempting to
make sure that the flash/commit is executed before the second run.
Error:
The test RuntimeError: number of values in row (0) differ from number of
column processors (29)
The error is strange however and indicates a bug in sqlite library.
potiuk added a commit that referenced this pull request Aug 6, 2023
)
Using same session in different steps of the same test has the
potential of not flishing/committing the changes between.
Seems that the #33150 traded one flakiness with another. Attempting to
make sure that the flash/commit is executed before the second run.
Error:
The test RuntimeError: number of values in row (0) differ from number of
column processors (29)
The error is strange however and indicates a bug in sqlite library.
@ephraimbuddyephraimbuddy added the changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) label Aug 8, 2023
ephraimbuddy pushed a commit that referenced this pull request Aug 8, 2023
Similarly to #33145 - this is an attempt to stabilise flaky tests
for the test_xcom_arg_map.
Even if the mechanism is not entirely clear (provide_session should
also close the connection) seems like using pytest-fixture provided
session works better than relying on a new session created in run()
methods.
(cherry picked from commit 3dd0c99)
ephraimbuddy pushed a commit that referenced this pull request Aug 8, 2023
)
Using same session in different steps of the same test has the
potential of not flishing/committing the changes between.
Seems that the #33150 traded one flakiness with another. Attempting to
make sure that the flash/commit is executed before the second run.
Error:
The test RuntimeError: number of values in row (0) differ from number of
column processors (29)
The error is strange however and indicates a bug in sqlite library.
(cherry picked from commit 6b21b79)
ephraimbuddy pushed a commit that referenced this pull request Aug 8, 2023
)
Using same session in different steps of the same test has the
potential of not flishing/committing the changes between.
Seems that the #33150 traded one flakiness with another. Attempting to
make sure that the flash/commit is executed before the second run.
Error:
The test RuntimeError: number of values in row (0) differ from number of
column processors (29)
The error is strange however and indicates a bug in sqlite library.
(cherry picked from commit 6b21b79)
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog:skipChanges that should be skipped from the changelog (CI, tests, etc..)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@potiuk@ephraimbuddy@hussein-awala