<h3 dir="auto">Apache Airflow version</h3>
<p dir="auto">2.5.0</p>
<h3 dir="auto">What happened</h3>
<p dir="auto">I have a docker-compose local install of Airflow.  When I go to login using LDAP, I get an error message: <code class="notranslate">The CSRF session token is missing</code>.  It's trying to <code class="notranslate">POST</code> to a <code class="notranslate">/login/</code> endpoint.  When I look at the request being submitted via my browser developer console, I see a value being set as part of the payload:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="csrf_token=redacted&amp;username=myuser&amp;password=secret"><pre class="notranslate"><code class="notranslate">csrf_token=redacted&amp;username=myuser&amp;password=secret
</code></pre></div>
<p dir="auto">I <strong>don't</strong> have an issue with Airflow <code class="notranslate">2.3.3</code>.  I've tested it with other versions such as <code class="notranslate">2.3.4</code>, <code class="notranslate">2.4.3</code>, and <code class="notranslate">2.5.0</code> and they all exhibit the same issue.</p>
<p dir="auto">Based on searching, some people talk about ensuring a common secret key is set to ensure communication between the Webserver and the Worker nodes.  I've tried setting the following environment variables in my docker-compose as part of the startup.  This didn't appear to fix the issue.  I also tried setting the number of workers to 1.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="AIRFLOW__LOGGING__LOGGING_LEVEL: DEBUG
# https://airflow.apache.org/docs/apache-airflow/stable/configurations-ref.html#workers
# https://github.com/apache/airflow/issues/23512#issuecomment-1276644397
AIRFLOW__WEBSERVER__WORKERS: 1
# https://airflow.apache.org/docs/apache-airflow/stable/configurations-ref.html#auth-backends
# allows all requests to hit the API
AIRFLOW__API__AUTH_BACKENDS: 'airflow.api.auth.backend.default,airflow.api.auth.backend.session'
# https://stackoverflow.com/questions/68889419/csrf-session-token-is-missing-in-airflow
AIRFLOW__WEBSERVER__SECRET_KEY: 'superdupersecret'"><pre class="notranslate"><code class="notranslate">AIRFLOW__LOGGING__LOGGING_LEVEL: DEBUG
# https://airflow.apache.org/docs/apache-airflow/stable/configurations-ref.html#workers
# https://github.com/apache/airflow/issues/23512#issuecomment-1276644397
AIRFLOW__WEBSERVER__WORKERS: 1
# https://airflow.apache.org/docs/apache-airflow/stable/configurations-ref.html#auth-backends
# allows all requests to hit the API
AIRFLOW__API__AUTH_BACKENDS: 'airflow.api.auth.backend.default,airflow.api.auth.backend.session'
# https://stackoverflow.com/questions/68889419/csrf-session-token-is-missing-in-airflow
AIRFLOW__WEBSERVER__SECRET_KEY: 'superdupersecret'
</code></pre></div>
<h3 dir="auto">What you think should happen instead</h3>
<p dir="auto">I should be able to login and get to the DAG screen.</p>
<h3 dir="auto">How to reproduce</h3>
<p dir="auto">I have the following <code class="notranslate">webserver_config.py</code> file that works with Airflow <code class="notranslate">2.3.3</code>.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import os
from flask_appbuilder.security.manager import AUTH_LDAP

# The authentication type
AUTH_TYPE = AUTH_LDAP

# Will allow user self registration
AUTH_USER_REGISTRATION = True

AUTH_USER_REGISTRATION_ROLE = &quot;Admin&quot;

AUTH_LDAP_SERVER = &quot;ldaps://redacted&quot;
AUTH_LDAP_BIND_USER = &quot;CN=&quot; + os.environ['LDAP_USER'] + &quot;,CN=Users,DC=redacted,DC=redacted,DC=redacted&quot;
AUTH_LDAP_BIND_PASSWORD = os.environ['LDAP_PASSWORD']
AUTH_LDAP_SEARCH = &quot;CN=Users,DC=redacted,DC=redacted,DC=redacted&quot;
AUTH_LDAP_SEARCH_FILTER = &quot;(memberOf=cn=&quot; + os.environ['LDAP_SECURITY_METAGROUP'] + &quot;,CN=Users,DC=redacted,DC=redacted,DC=redacted)&quot;
AUTH_LDAP_UID_FIELD = &quot;sAMAccountName&quot;

AUTH_LDAP_FIRSTNAME_FIELD = &quot;givenName&quot;
AUTH_LDAP_LASTTNAME_FIELD = &quot;sn&quot;

# if we should replace ALL the user's roles each login, or only on registration
AUTH_ROLES_SYNC_AT_LOGIN = True

# force users to re-auth after 30min of inactivity (to keep roles in sync)
PERMANENT_SESSION_LIFETIME = 1800"><pre class="notranslate"><code class="notranslate">import os
from flask_appbuilder.security.manager import AUTH_LDAP

# The authentication type
AUTH_TYPE = AUTH_LDAP

# Will allow user self registration
AUTH_USER_REGISTRATION = True

AUTH_USER_REGISTRATION_ROLE = "Admin"

AUTH_LDAP_SERVER = "ldaps://redacted"
AUTH_LDAP_BIND_USER = "CN=" + os.environ['LDAP_USER'] + ",CN=Users,DC=redacted,DC=redacted,DC=redacted"
AUTH_LDAP_BIND_PASSWORD = os.environ['LDAP_PASSWORD']
AUTH_LDAP_SEARCH = "CN=Users,DC=redacted,DC=redacted,DC=redacted"
AUTH_LDAP_SEARCH_FILTER = "(memberOf=cn=" + os.environ['LDAP_SECURITY_METAGROUP'] + ",CN=Users,DC=redacted,DC=redacted,DC=redacted)"
AUTH_LDAP_UID_FIELD = "sAMAccountName"

AUTH_LDAP_FIRSTNAME_FIELD = "givenName"
AUTH_LDAP_LASTTNAME_FIELD = "sn"

# if we should replace ALL the user's roles each login, or only on registration
AUTH_ROLES_SYNC_AT_LOGIN = True

# force users to re-auth after 30min of inactivity (to keep roles in sync)
PERMANENT_SESSION_LIFETIME = 1800
</code></pre></div>
<p dir="auto">This <a href="https://github.com/apache/airflow/discussions/26870" data-hovercard-type="discussion" data-hovercard-url="/apache/airflow/discussions/26870/hovercard">discussion post</a> is <em>exactly</em> what I am experiencing.  They mentioned adjusting <code class="notranslate">webserver_config.py</code>.  Based on <a href="https://github.com/apache/airflow/blob/main/airflow/config_templates/default_webserver_config.py">the default config file in the repo</a>, I have made adjustments to the file.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import os
from flask_appbuilder.security.manager import AUTH_LDAP
from airflow.www.fab_security.manager import AUTH_LDAP
basedir = os.path.abspath(os.path.dirname(__file__))

# I've tried enabling and disabling every combination of these two variables
#CSRF_ENABLED = True
#WTF_CSRF_ENABLED = True

# The authentication type
AUTH_TYPE = AUTH_LDAP
..."><pre class="notranslate"><code class="notranslate">import os
from flask_appbuilder.security.manager import AUTH_LDAP
from airflow.www.fab_security.manager import AUTH_LDAP
basedir = os.path.abspath(os.path.dirname(__file__))

# I've tried enabling and disabling every combination of these two variables
#CSRF_ENABLED = True
#WTF_CSRF_ENABLED = True

# The authentication type
AUTH_TYPE = AUTH_LDAP
...
</code></pre></div>
<p dir="auto">This still doesn't work for me.</p>
<p dir="auto">I'm not sure what else to try.  <a href="https://github.com/apache/airflow/commit/48d4c5da19217174c8996b2882bb71f40381ae2c">This change</a> seemed to make adjustments to the underlying FAB security system.  However, I can't find any examples in the official documentation or elsewhere for <em>new</em> working LDAP examples.</p>
<p dir="auto">Thank you.</p>
<h3 dir="auto">Operating System</h3>
<p dir="auto">Linux (Ubuntu) within container</p>
<h3 dir="auto">Versions of Apache Airflow Providers</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Deployment</h3>
<p dir="auto">Docker-Compose</p>
<h3 dir="auto">Deployment details</h3>
<p dir="auto">docker-compose on Windows</p>
<h3 dir="auto">Anything else</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Are you willing to submit PR?</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> Yes I am willing to submit a PR!</li>
</ul>
<h3 dir="auto">Code of Conduct</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I agree to follow this project's <a href="https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md">Code of Conduct</a></li>
</ul>
<h3 dir="auto">Apache Airflow version</h3>
<p dir="auto">Other Airflow 2 version (please specify below)</p>
<h3 dir="auto">What happened</h3>
<p dir="auto"><strong>Airflow 2.4.3</strong></p>
<p dir="auto">After upgrading from Airflow 2.2.5 to 2.4.3, when we go to load the web page, it loads it in a different and weird format and style with each refresh, and every time its loaded these errors are printed in the web pod logs:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="airflow-web sqlalchemy.exc.IntegrityError: (psycopg2.errors.UniqueViolation) duplicate key value violates unique constraint &quot;session_session_id_key&quot;
airflow-web DETAIL: Key (session_id)=(7582aee0-4289-4152-99d2-918c98ff64d6) already exists.
airflow-web
airflow-web [SQL: INSERT INTO session (session_id, data, expiry) VALUES (%(session_id)s, %(data)s, %(expiry)s) RETURNING session.id]
airflow-web [parameters: {'session_id': '7582aee0-4289-4152-99d2-918c98ff64d6', 'data': &lt;psycopg2.extensions.Binary object at 0x7fbd53ad71b0&gt;, 'expiry': datetime.datetime(2022, 11, 23, 16, 5, 59, 467562, tzinfo=datetime.timezone.utc)}]
airflow-web (Background on this error at: https://sqlalche.me/e/14/gkpj)
airflow-web"><pre class="notranslate"><code class="notranslate">airflow-web sqlalchemy.exc.IntegrityError: (psycopg2.errors.UniqueViolation) duplicate key value violates unique constraint "session_session_id_key"
airflow-web DETAIL: Key (session_id)=(7582aee0-4289-4152-99d2-918c98ff64d6) already exists.
airflow-web
airflow-web [SQL: INSERT INTO session (session_id, data, expiry) VALUES (%(session_id)s, %(data)s, %(expiry)s) RETURNING session.id]
airflow-web [parameters: {'session_id': '7582aee0-4289-4152-99d2-918c98ff64d6', 'data': &lt;psycopg2.extensions.Binary object at 0x7fbd53ad71b0&gt;, 'expiry': datetime.datetime(2022, 11, 23, 16, 5, 59, 467562, tzinfo=datetime.timezone.utc)}]
airflow-web (Background on this error at: https://sqlalche.me/e/14/gkpj)
airflow-web
</code></pre></div>
<p dir="auto">The full logs are below:</p>
<details>
<summary>webserver.logs</summary>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="airflow-web 127.0.0.1 - - [23/Nov/2022:15:35:59 +0000] &quot;GET /login/ HTTP/1.1&quot; 200 16330 &quot;https://login.microsoftonline.com/&quot; &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36 Edg/106.0.1370.52&quot;
airflow-web 127.0.0.1 - - [23/Nov/2022:15:35:59 +0000] &quot;GET /static/appbuilder/css/font-awesome.min.css HTTP/1.1&quot; 200 0 &quot;https://url/login/&quot; &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36 Edg/106.0.1370.52&quot;
airflow-web [2022-11-23 15:35:59,423] {app.py:1741} ERROR - Exception on /static/appbuilder/css/bootstrap.min.css [GET]
airflow-web Traceback (most recent call last):
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py&quot;, line 1802, in _execute_context
airflow-web self.dialect.do_execute(
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/default.py&quot;, line 719, in do_execute
airflow-web cursor.execute(statement, parameters)
airflow-web psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint &quot;session_session_id_key&quot;
airflow-web DETAIL: Key (session_id)=(7582aee0-4289-4152-99d2-918c98ff64d6) already exists.
airflow-web
airflow-web return super().save_session(*args, **kwargs)
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/flask_session/sessions.py&quot;, line 578, in save_session
airflow-web self.db.session.commit()
airflow-web File &quot;&quot;, line 2, in commit
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/session.py&quot;, line 1428, in commit
airflow-web self._transaction.commit(_to_root=self.future)
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/session.py&quot;, line 829, in commit
airflow-web self._prepare_impl()
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/session.py&quot;, line 808, in _prepare_impl
airflow-web self.session.flush()
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/session.py&quot;, line 3345, in flush
airflow-web self._flush(objects)
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/session.py&quot;, line 3485, in flush
airflow-web transaction.rollback(capture_exception=True)
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/util/langhelpers.py&quot;, line 70, in exit
airflow-web compat.raise(
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/util/compat.py&quot;, line 207, in raise
airflow-web raise exception
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/session.py&quot;, line 3445, in _flush
airflow-web flush_context.execute()
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/unitofwork.py&quot;, line 456, in execute
airflow-web rec.execute(self)
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/unitofwork.py&quot;, line 630, in execute
airflow-web util.preloaded.orm_persistence.save_obj(
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/persistence.py&quot;, line 244, in save_obj
airflow-web _emit_insert_statements(
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/persistence.py&quot;, line 1221, in _emit_insert_statements
airflow-web result = connection._execute_20(
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py&quot;, line 1614, in _execute_20
airflow-web return meth(self, args_10style, kwargs_10style, execution_options)
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/sql/elements.py&quot;, line 325, in _execute_on_connection
airflow-web return connection._execute_clauseelement(
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py&quot;, line 1481, in _execute_clauseelement
airflow-web ret = self._execute_context(
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py&quot;, line 1845, in _execute_context
airflow-web self.handle_dbapi_exception(
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py&quot;, line 2026, in handle_dbapi_exception
airflow-web util.raise(
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/util/compat.py&quot;, line 207, in raise
airflow-web raise exception
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py&quot;, line 1802, in _execute_context
airflow-web self.dialect.do_execute(
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/default.py&quot;, line 719, in do_execute
airflow-web cursor.execute(statement, parameters)
airflow-web sqlalchemy.exc.IntegrityError: (psycopg2.errors.UniqueViolation) duplicate key value violates unique constraint &quot;session_session_id_key&quot;
airflow-web DETAIL: Key (session_id)=(7582aee0-4289-4152-99d2-918c98ff64d6) already exists.
airflow-web
airflow-web [SQL: INSERT INTO session (session_id, data, expiry) VALUES (%(session_id)s, %(data)s, %(expiry)s) RETURNING session.id]
airflow-web [parameters: {'session_id': '7582aee0-4289-4152-99d2-918c98ff64d6', 'data': &lt;psycopg2.extensions.Binary object at 0x7fbd53ad71b0&gt;, 'expiry': datetime.datetime(2022, 11, 23, 16, 5, 59, 467562, tzinfo=datetime.timezone.utc)}]
airflow-web (Background on this error at: https://sqlalche.me/e/14/gkpj)
airflow-web
airflow-web During handling of the above exception, another exception occurred:
airflow-web
airflow-web Traceback (most recent call last):
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/flask/app.py&quot;, line 1844, in finalize_request
airflow-web response = self.process_response(response)
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/flask/app.py&quot;, line 2340, in process_response
airflow-web self.session_interface.save_session(self, ctx.session, response)
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/airflow/www/session.py&quot;, line 33, in save_session
airflow-web return super().save_session(*args, **kwargs)
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/flask_session/sessions.py&quot;, line 553, in save_session
airflow-web saved_session = self.sql_session_model.query.filter_by(
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/query.py&quot;, line 2810, in first
airflow-web return self.limit(1)._iter().first()
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/query.py&quot;, line 2894, in _iter
airflow-web result = self.session.execute(
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/session.py&quot;, line 1688, in execute
airflow-web conn = self._connection_for_bind(bind)
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/session.py&quot;, line 1529, in _connection_for_bind
airflow-web return self._transaction._connection_for_bind(
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/session.py&quot;, line 721, in _connection_for_bind
airflow-web self._assert_active()
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/session.py&quot;, line 601, in _assert_active
airflow-web raise sa_exc.PendingRollbackError(
airflow-web sqlalchemy.exc.PendingRollbackError: This Session's transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). Original exception was: (psycopg2.errors.UniqueViolation) duplicate key value violates unique constraint &quot;session_session_id_key&quot;
airflow-web DETAIL: Key (session_id)=(7582aee0-4289-4152-99d2-918c98ff64d6) already exists.
airflow-web
airflow-web [SQL: INSERT INTO session (session_id, data, expiry) VALUES (%(session_id)s, %(data)s, %(expiry)s) RETURNING session.id]
airflow-web [parameters: {'session_id': '7582aee0-4289-4152-99d2-918c98ff64d6', 'data': &lt;psycopg2.extensions.Binary object at 0x7fbd53ad71b0&gt;, 'expiry': datetime.datetime(2022, 11, 23, 16, 5, 59, 467562, tzinfo=datetime.timezone.utc)}]
airflow-web (Background on this error at: https://sqlalche.me/e/14/gkpj) (Background on this error at: https://sqlalche.me/e/14/7s2a)
airflow-web 127.0.0.1 - - [23/Nov/2022:15:35:59 +0000] &quot;GET /static/appbuilder/css/flags/flags16.css HTTP/1.1&quot; 500 1575 &quot;https://url/login/&quot; &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36 Edg/106.0.1370.52&quot;
airflow-web 127.0.0.1 - - [23/Nov/2022:15:35:59 +0000] &quot;GET /static/appbuilder/css/ab.css HTTP/1.1&quot; 500 1575 &quot;https://url/login/&quot; &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36 Edg/106.0.1370.52&quot;
airflow-web 127.0.0.1 - - [23/Nov/2022:15:35:59 +0000] &quot;GET /static/dist/airflowDefaultTheme.731e57571b52cca4350d.css HTTP/1.1&quot; 200 0 &quot;https://url/login/&quot; &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36 Edg/106.0.1370.52&quot;
airflow-web [2022-11-23 15:35:59,534] {app.py:1741} ERROR - Exception on /static/dist/materialIcons.f9559e4953177b8b9a4a.css [GET]
airflow-web Traceback (most recent call last):
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py&quot;, line 1802, in _execute_context
airflow-web self.dialect.do_execute(
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/default.py&quot;, line 719, in do_execute
airflow-web cursor.execute(statement, parameters)
airflow-web psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint &quot;session_session_id_key&quot;
airflow-web DETAIL: Key (session_id)=(7582aee0-4289-4152-99d2-918c98ff64d6) already exists.
airflow-web
airflow-web
airflow-web The above exception was the direct cause of the following exception:
airflow-web
airflow-web Traceback (most recent call last):
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/flask/app.py&quot;, line 2525, in wsgi_app
airflow-web response = self.full_dispatch_request()
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/flask/app.py&quot;, line 1823, in full_dispatch_request
airflow-web return self.finalize_request(rv)
airflow-web return meth(self, args_10style, kwargs_10style, execution_options)
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/sql/elements.py&quot;, line 325, in _execute_on_connection
airflow-web return connection._execute_clauseelement(
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py&quot;, line 1481, in _execute_clauseelement
airflow-web ret = self._execute_context(
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py&quot;, line 1845, in _execute_context
airflow-web self.handle_dbapi_exception(
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py&quot;, line 2026, in handle_dbapi_exception
airflow-web util.raise(
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/util/compat.py&quot;, line 207, in raise
airflow-web raise exception
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py&quot;, line 1802, in _execute_context
airflow-web self.dialect.do_execute(
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/default.py&quot;, line 719, in do_execute
airflow-web cursor.execute(statement, parameters)
airflow-web sqlalchemy.exc.IntegrityError: (psycopg2.errors.UniqueViolation) duplicate key value violates unique constraint &quot;session_session_id_key&quot;
airflow-web DETAIL: Key (session_id)=(7582aee0-4289-4152-99d2-918c98ff64d6) already exists.
airflow-web
airflow-web [SQL: INSERT INTO session (session_id, data, expiry) VALUES (%(session_id)s, %(data)s, %(expiry)s) RETURNING session.id]
airflow-web [parameters: {'session_id': '7582aee0-4289-4152-99d2-918c98ff64d6', 'data': &lt;psycopg2.extensions.Binary object at 0x7fbd4c9fd900&gt;, 'expiry': datetime.datetime(2022, 11, 23, 16, 5, 59, 574672, tzinfo=datetime.timezone.utc)}]
airflow-web (Background on this error at: https://sqlalche.me/e/14/gkpj)
airflow-web [2022-11-23 15:35:59,591] {app.py:1741} ERROR - Exception on /static/dist/loadingDots.5da42d00b5455806e709.css [GET]
airflow-web Traceback (most recent call last):
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py&quot;, line 1802, in _execute_context
airflow-web self.dialect.do_execute(
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/default.py&quot;, line 719, in do_execute
airflow-web cursor.execute(statement, parameters)
airflow-web psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint &quot;session_session_id_key&quot;
airflow-web DETAIL: Key (session_id)=(7582aee0-4289-4152-99d2-918c98ff64d6) already exists.
airflow-web
airflow-web
airflow-web The above exception was the direct cause of the following exception:
airflow-web
airflow-web Traceback (most recent call last):
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/flask/app.py&quot;, line 2525, in wsgi_app
airflow-web response = self.full_dispatch_request()
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/flask/app.py&quot;, line 1823, in full_dispatch_request
airflow-web return self.finalize_request(rv)
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/flask/app.py&quot;, line 1844, in finalize_request
airflow-web response = self.process_response(response)
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/flask/app.py&quot;, line 2340, in process_response
airflow-web self.session_interface.save_session(self, ctx.session, response)
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/airflow/www/session.py&quot;, line 33, in save_session
airflow-web return super().save_session(*args, **kwargs)
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/flask_session/sessions.py&quot;, line 578, in save_session
airflow-web self.db.session.commit()
airflow-web File &quot;&quot;, line 2, in commit
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/session.py&quot;, line 1428, in commit
airflow-web self._transaction.commit(_to_root=self.future)
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/session.py&quot;, line 829, in commit
airflow-web self._prepare_impl()
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/session.py&quot;, line 808, in _prepare_impl
airflow-web self.session.flush()
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/session.py&quot;, line 3345, in flush
airflow-web self._flush(objects)
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/session.py&quot;, line 3485, in flush
airflow-web transaction.rollback(capture_exception=True)
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/util/langhelpers.py&quot;, line 70, in exit
airflow-web compat.raise(
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/util/compat.py&quot;, line 207, in raise
airflow-web raise exception
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/session.py&quot;, line 3445, in _flush
airflow-web flush_context.execute()
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/unitofwork.py&quot;, line 456, in execute
airflow-web rec.execute(self)
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/unitofwork.py&quot;, line 630, in execute
airflow-web util.preloaded.orm_persistence.save_obj(
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/persistence.py&quot;, line 244, in save_obj
airflow-web _emit_insert_statements(
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/persistence.py&quot;, line 1221, in _emit_insert_statements
airflow-web result = connection._execute_20(
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py&quot;, line 1614, in _execute_20
airflow-web return meth(self, args_10style, kwargs_10style, execution_options)
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/sql/elements.py&quot;, line 325, in _execute_on_connection
airflow-web return connection._execute_clauseelement(
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py&quot;, line 1481, in _execute_clauseelement
airflow-web ret = self._execute_context(
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py&quot;, line 1845, in _execute_context
airflow-web self.handle_dbapi_exception(
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py&quot;, line 2026, in handle_dbapi_exception
airflow-web util.raise(
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/util/compat.py&quot;, line 207, in raise
airflow-web raise exception
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py&quot;, line 1802, in _execute_context
airflow-web self.dialect.do_execute(
airflow-web File &quot;/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/default.py&quot;, line 719, in do_execute
airflow-web cursor.execute(statement, parameters)
airflow-web sqlalchemy.exc.IntegrityError: (psycopg2.errors.UniqueViolation) duplicate key value violates unique constraint &quot;session_session_id_key&quot;
airflow-web DETAIL: Key (session_id)=(7582aee0-4289-4152-99d2-918c98ff64d6) already exists."><pre class="notranslate"><code class="notranslate">airflow-web 127.0.0.1 - - [23/Nov/2022:15:35:59 +0000] "GET /login/ HTTP/1.1" 200 16330 "https://login.microsoftonline.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36 Edg/106.0.1370.52"
airflow-web 127.0.0.1 - - [23/Nov/2022:15:35:59 +0000] "GET /static/appbuilder/css/font-awesome.min.css HTTP/1.1" 200 0 "https://url/login/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36 Edg/106.0.1370.52"
airflow-web [2022-11-23 15:35:59,423] {app.py:1741} ERROR - Exception on /static/appbuilder/css/bootstrap.min.css [GET]
airflow-web Traceback (most recent call last):
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1802, in _execute_context
airflow-web self.dialect.do_execute(
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 719, in do_execute
airflow-web cursor.execute(statement, parameters)
airflow-web psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "session_session_id_key"
airflow-web DETAIL: Key (session_id)=(7582aee0-4289-4152-99d2-918c98ff64d6) already exists.
airflow-web
airflow-web return super().save_session(*args, **kwargs)
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/flask_session/sessions.py", line 578, in save_session
airflow-web self.db.session.commit()
airflow-web File "", line 2, in commit
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/session.py", line 1428, in commit
airflow-web self._transaction.commit(_to_root=self.future)
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/session.py", line 829, in commit
airflow-web self._prepare_impl()
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/session.py", line 808, in _prepare_impl
airflow-web self.session.flush()
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/session.py", line 3345, in flush
airflow-web self._flush(objects)
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/session.py", line 3485, in flush
airflow-web transaction.rollback(capture_exception=True)
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/util/langhelpers.py", line 70, in exit
airflow-web compat.raise(
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 207, in raise
airflow-web raise exception
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/session.py", line 3445, in _flush
airflow-web flush_context.execute()
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/unitofwork.py", line 456, in execute
airflow-web rec.execute(self)
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/unitofwork.py", line 630, in execute
airflow-web util.preloaded.orm_persistence.save_obj(
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/persistence.py", line 244, in save_obj
airflow-web _emit_insert_statements(
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/persistence.py", line 1221, in _emit_insert_statements
airflow-web result = connection._execute_20(
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1614, in _execute_20
airflow-web return meth(self, args_10style, kwargs_10style, execution_options)
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/sql/elements.py", line 325, in _execute_on_connection
airflow-web return connection._execute_clauseelement(
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1481, in _execute_clauseelement
airflow-web ret = self._execute_context(
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1845, in _execute_context
airflow-web self.handle_dbapi_exception(
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 2026, in handle_dbapi_exception
airflow-web util.raise(
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 207, in raise
airflow-web raise exception
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1802, in _execute_context
airflow-web self.dialect.do_execute(
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 719, in do_execute
airflow-web cursor.execute(statement, parameters)
airflow-web sqlalchemy.exc.IntegrityError: (psycopg2.errors.UniqueViolation) duplicate key value violates unique constraint "session_session_id_key"
airflow-web DETAIL: Key (session_id)=(7582aee0-4289-4152-99d2-918c98ff64d6) already exists.
airflow-web
airflow-web [SQL: INSERT INTO session (session_id, data, expiry) VALUES (%(session_id)s, %(data)s, %(expiry)s) RETURNING session.id]
airflow-web [parameters: {'session_id': '7582aee0-4289-4152-99d2-918c98ff64d6', 'data': &lt;psycopg2.extensions.Binary object at 0x7fbd53ad71b0&gt;, 'expiry': datetime.datetime(2022, 11, 23, 16, 5, 59, 467562, tzinfo=datetime.timezone.utc)}]
airflow-web (Background on this error at: https://sqlalche.me/e/14/gkpj)
airflow-web
airflow-web During handling of the above exception, another exception occurred:
airflow-web
airflow-web Traceback (most recent call last):
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/flask/app.py", line 1844, in finalize_request
airflow-web response = self.process_response(response)
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/flask/app.py", line 2340, in process_response
airflow-web self.session_interface.save_session(self, ctx.session, response)
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/airflow/www/session.py", line 33, in save_session
airflow-web return super().save_session(*args, **kwargs)
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/flask_session/sessions.py", line 553, in save_session
airflow-web saved_session = self.sql_session_model.query.filter_by(
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/query.py", line 2810, in first
airflow-web return self.limit(1)._iter().first()
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/query.py", line 2894, in _iter
airflow-web result = self.session.execute(
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/session.py", line 1688, in execute
airflow-web conn = self._connection_for_bind(bind)
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/session.py", line 1529, in _connection_for_bind
airflow-web return self._transaction._connection_for_bind(
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/session.py", line 721, in _connection_for_bind
airflow-web self._assert_active()
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/session.py", line 601, in _assert_active
airflow-web raise sa_exc.PendingRollbackError(
airflow-web sqlalchemy.exc.PendingRollbackError: This Session's transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). Original exception was: (psycopg2.errors.UniqueViolation) duplicate key value violates unique constraint "session_session_id_key"
airflow-web DETAIL: Key (session_id)=(7582aee0-4289-4152-99d2-918c98ff64d6) already exists.
airflow-web
airflow-web [SQL: INSERT INTO session (session_id, data, expiry) VALUES (%(session_id)s, %(data)s, %(expiry)s) RETURNING session.id]
airflow-web [parameters: {'session_id': '7582aee0-4289-4152-99d2-918c98ff64d6', 'data': &lt;psycopg2.extensions.Binary object at 0x7fbd53ad71b0&gt;, 'expiry': datetime.datetime(2022, 11, 23, 16, 5, 59, 467562, tzinfo=datetime.timezone.utc)}]
airflow-web (Background on this error at: https://sqlalche.me/e/14/gkpj) (Background on this error at: https://sqlalche.me/e/14/7s2a)
airflow-web 127.0.0.1 - - [23/Nov/2022:15:35:59 +0000] "GET /static/appbuilder/css/flags/flags16.css HTTP/1.1" 500 1575 "https://url/login/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36 Edg/106.0.1370.52"
airflow-web 127.0.0.1 - - [23/Nov/2022:15:35:59 +0000] "GET /static/appbuilder/css/ab.css HTTP/1.1" 500 1575 "https://url/login/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36 Edg/106.0.1370.52"
airflow-web 127.0.0.1 - - [23/Nov/2022:15:35:59 +0000] "GET /static/dist/airflowDefaultTheme.731e57571b52cca4350d.css HTTP/1.1" 200 0 "https://url/login/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36 Edg/106.0.1370.52"
airflow-web [2022-11-23 15:35:59,534] {app.py:1741} ERROR - Exception on /static/dist/materialIcons.f9559e4953177b8b9a4a.css [GET]
airflow-web Traceback (most recent call last):
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1802, in _execute_context
airflow-web self.dialect.do_execute(
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 719, in do_execute
airflow-web cursor.execute(statement, parameters)
airflow-web psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "session_session_id_key"
airflow-web DETAIL: Key (session_id)=(7582aee0-4289-4152-99d2-918c98ff64d6) already exists.
airflow-web
airflow-web
airflow-web The above exception was the direct cause of the following exception:
airflow-web
airflow-web Traceback (most recent call last):
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/flask/app.py", line 2525, in wsgi_app
airflow-web response = self.full_dispatch_request()
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/flask/app.py", line 1823, in full_dispatch_request
airflow-web return self.finalize_request(rv)
airflow-web return meth(self, args_10style, kwargs_10style, execution_options)
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/sql/elements.py", line 325, in _execute_on_connection
airflow-web return connection._execute_clauseelement(
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1481, in _execute_clauseelement
airflow-web ret = self._execute_context(
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1845, in _execute_context
airflow-web self.handle_dbapi_exception(
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 2026, in handle_dbapi_exception
airflow-web util.raise(
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 207, in raise
airflow-web raise exception
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1802, in _execute_context
airflow-web self.dialect.do_execute(
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 719, in do_execute
airflow-web cursor.execute(statement, parameters)
airflow-web sqlalchemy.exc.IntegrityError: (psycopg2.errors.UniqueViolation) duplicate key value violates unique constraint "session_session_id_key"
airflow-web DETAIL: Key (session_id)=(7582aee0-4289-4152-99d2-918c98ff64d6) already exists.
airflow-web
airflow-web [SQL: INSERT INTO session (session_id, data, expiry) VALUES (%(session_id)s, %(data)s, %(expiry)s) RETURNING session.id]
airflow-web [parameters: {'session_id': '7582aee0-4289-4152-99d2-918c98ff64d6', 'data': &lt;psycopg2.extensions.Binary object at 0x7fbd4c9fd900&gt;, 'expiry': datetime.datetime(2022, 11, 23, 16, 5, 59, 574672, tzinfo=datetime.timezone.utc)}]
airflow-web (Background on this error at: https://sqlalche.me/e/14/gkpj)
airflow-web [2022-11-23 15:35:59,591] {app.py:1741} ERROR - Exception on /static/dist/loadingDots.5da42d00b5455806e709.css [GET]
airflow-web Traceback (most recent call last):
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1802, in _execute_context
airflow-web self.dialect.do_execute(
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 719, in do_execute
airflow-web cursor.execute(statement, parameters)
airflow-web psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "session_session_id_key"
airflow-web DETAIL: Key (session_id)=(7582aee0-4289-4152-99d2-918c98ff64d6) already exists.
airflow-web
airflow-web
airflow-web The above exception was the direct cause of the following exception:
airflow-web
airflow-web Traceback (most recent call last):
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/flask/app.py", line 2525, in wsgi_app
airflow-web response = self.full_dispatch_request()
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/flask/app.py", line 1823, in full_dispatch_request
airflow-web return self.finalize_request(rv)
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/flask/app.py", line 1844, in finalize_request
airflow-web response = self.process_response(response)
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/flask/app.py", line 2340, in process_response
airflow-web self.session_interface.save_session(self, ctx.session, response)
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/airflow/www/session.py", line 33, in save_session
airflow-web return super().save_session(*args, **kwargs)
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/flask_session/sessions.py", line 578, in save_session
airflow-web self.db.session.commit()
airflow-web File "", line 2, in commit
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/session.py", line 1428, in commit
airflow-web self._transaction.commit(_to_root=self.future)
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/session.py", line 829, in commit
airflow-web self._prepare_impl()
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/session.py", line 808, in _prepare_impl
airflow-web self.session.flush()
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/session.py", line 3345, in flush
airflow-web self._flush(objects)
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/session.py", line 3485, in flush
airflow-web transaction.rollback(capture_exception=True)
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/util/langhelpers.py", line 70, in exit
airflow-web compat.raise(
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 207, in raise
airflow-web raise exception
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/session.py", line 3445, in _flush
airflow-web flush_context.execute()
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/unitofwork.py", line 456, in execute
airflow-web rec.execute(self)
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/unitofwork.py", line 630, in execute
airflow-web util.preloaded.orm_persistence.save_obj(
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/persistence.py", line 244, in save_obj
airflow-web _emit_insert_statements(
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/orm/persistence.py", line 1221, in _emit_insert_statements
airflow-web result = connection._execute_20(
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1614, in _execute_20
airflow-web return meth(self, args_10style, kwargs_10style, execution_options)
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/sql/elements.py", line 325, in _execute_on_connection
airflow-web return connection._execute_clauseelement(
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1481, in _execute_clauseelement
airflow-web ret = self._execute_context(
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1845, in _execute_context
airflow-web self.handle_dbapi_exception(
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 2026, in handle_dbapi_exception
airflow-web util.raise(
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 207, in raise
airflow-web raise exception
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1802, in _execute_context
airflow-web self.dialect.do_execute(
airflow-web File "/home/airflow/.local/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 719, in do_execute
airflow-web cursor.execute(statement, parameters)
airflow-web sqlalchemy.exc.IntegrityError: (psycopg2.errors.UniqueViolation) duplicate key value violates unique constraint "session_session_id_key"
airflow-web DETAIL: Key (session_id)=(7582aee0-4289-4152-99d2-918c98ff64d6) already exists.
</code></pre></div>
</details>
<h3 dir="auto">What you think should happen instead</h3>
<p dir="auto">The webserver should load just fine and there should be no errors.</p>
<h3 dir="auto">How to reproduce</h3>
<p dir="auto">We are running the community helm chart version 8.6.1, Airflow 2.4.3, and are using a postgres external database. I have produced this issue using the default webserver_config.py file and setting AIRFLOW__WEBSERVER__SESSION_LIFETIME_MINUTES: "30" in my helm chart.</p>
<h3 dir="auto">Operating System</h3>
<p dir="auto">Debian GNU/Linux 11 (bullseye)</p>
<h3 dir="auto">Versions of Apache Airflow Providers</h3>
<p dir="auto">apache-airflow-providers-amazon==6.0.0<br>
apache-airflow-providers-celery==3.0.0<br>
apache-airflow-providers-cncf-kubernetes==4.4.0<br>
apache-airflow-providers-common-sql==1.2.0<br>
apache-airflow-providers-docker==3.2.0<br>
apache-airflow-providers-elasticsearch==4.2.1<br>
apache-airflow-providers-ftp==3.1.0<br>
apache-airflow-providers-google==8.4.0<br>
apache-airflow-providers-grpc==3.0.0<br>
apache-airflow-providers-hashicorp==3.1.0<br>
apache-airflow-providers-http==4.0.0<br>
apache-airflow-providers-imap==3.0.0<br>
apache-airflow-providers-microsoft-azure==4.3.0<br>
apache-airflow-providers-mysql==3.2.1<br>
apache-airflow-providers-odbc==3.1.2<br>
apache-airflow-providers-postgres==5.2.2<br>
apache-airflow-providers-redis==3.0.0<br>
apache-airflow-providers-sendgrid==3.0.0<br>
apache-airflow-providers-sftp==4.1.0<br>
apache-airflow-providers-slack==6.0.0<br>
apache-airflow-providers-sqlite==3.2.1<br>
apache-airflow-providers-ssh==3.2.0</p>
<h3 dir="auto">Deployment</h3>
<p dir="auto">Other 3rd-party Helm chart</p>
<h3 dir="auto">Deployment details</h3>
<p dir="auto">We are currently running Airflow 2.4.3 on Kubernetes with the Airflow Community helm chart version 8.6.1 (located here: <a href="https://github.com/airflow-helm/charts">https://github.com/airflow-helm/charts</a>). We are also using a postgres external database as our metadata db.</p>
<h3 dir="auto">Anything else</h3>
<p dir="auto">There have been multiple other issues and discussions opened up about this issue, which are linked below. one issue, <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1497807642" data-permission-text="Title is private" data-url="https://github.com/apache/airflow/issues/28373" data-hovercard-type="issue" data-hovercard-url="/apache/airflow/issues/28373/hovercard" href="https://github.com/apache/airflow/issues/28373">#28373</a>, describes the current workaround. The workaround is to set session_backend = securecookie instead of database. In this issue, they are using an external postgres just like me, so my guess is there is something up with Airflow 2.4.3's storing sessions in a postgres database.</p>
<p dir="auto">Other discussion:<br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="4627191" data-permission-text="Title is private" data-url="https://github.com/apache/airflow/discussions/28099" data-hovercard-type="discussion" data-hovercard-url="/apache/airflow/discussions/28099/hovercard" href="https://github.com/apache/airflow/discussions/28099">#28099</a></p>
<h3 dir="auto">Are you willing to submit PR?</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Yes I am willing to submit a PR!</li>
</ul>
<h3 dir="auto">Code of Conduct</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I agree to follow this project's <a href="https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md">Code of Conduct</a></li>
</ul>