You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/04/02 07:33:29 UTC
[GitHub] [airflow] kaojunsong opened a new issue #15150: "duplicate key value violates unique constraint "dag_run_dag_id_execution_date_key" when triggering a DAG
kaojunsong opened a new issue #15150:
URL: https://github.com/apache/airflow/issues/15150
<!--
Welcome to Apache Airflow! For a smooth issue process, try to answer the following questions.
Don't worry if they're not all applicable; just try to include what you can :-)
If you need to include code snippets or logs, please put them in fenced code
blocks. If they're super-long, please use the details tag like
<details><summary>super-long log</summary> lots of stuff </details>
Please delete these comment blocks before submitting the issue.
-->
<!--
IMPORTANT!!!
PLEASE CHECK "SIMILAR TO X EXISTING ISSUES" OPTION IF VISIBLE
NEXT TO "SUBMIT NEW ISSUE" BUTTON!!!
PLEASE CHECK IF THIS ISSUE HAS BEEN REPORTED PREVIOUSLY USING SEARCH!!!
Please complete the next sections or the issue will be closed.
These questions are the first thing we need to know to understand the context.
-->
**Apache Airflow version**:
2.0.0
**Kubernetes version (if you are using kubernetes)** (use `kubectl version`):
1.14
**Environment**:
- **Cloud provider or hardware configuration**:
- **OS** (e.g. from /etc/os-release):
- **Kernel** (e.g. `uname -a`):
- **Install tools**:
- **Others**:
**What happened**:
[2021-04-02 07:23:30,513] [ERROR] app.py:1892 - Exception on /api/v1/dags/auto_test/dagRuns [POST]
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1277, in _execute_context
cursor, statement, parameters, context
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 608, in do_execute
cursor.execute(statement, parameters)
psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "dag_run_dag_id_execution_date_key"
DETAIL: Key (dag_id, execution_date)=(auto_test, 1967-12-13 20:57:42.043+01) already exists.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/usr/local/lib/python3.6/site-packages/connexion/decorators/decorator.py", line 48, in wrapper
response = function(request)
File "/usr/local/lib/python3.6/site-packages/connexion/decorators/uri_parsing.py", line 144, in wrapper
response = function(request)
File "/usr/local/lib/python3.6/site-packages/connexion/decorators/validation.py", line 184, in wrapper
response = function(request)
File "/usr/local/lib/python3.6/site-packages/connexion/decorators/validation.py", line 384, in wrapper
return function(request)
File "/usr/local/lib/python3.6/site-packages/connexion/decorators/response.py", line 103, in wrapper
response = function(request)
File "/usr/local/lib/python3.6/site-packages/connexion/decorators/parameter.py", line 121, in wrapper
return function(**kwargs)
File "/usr/local/lib/python3.6/site-packages/airflow/api_connexion/security.py", line 47, in decorated
return func(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/airflow/utils/session.py", line 65, in wrapper
return func(*args, session=session, **kwargs)
File "/usr/local/lib/python3.6/site-packages/airflow/api_connexion/endpoints/dag_run_endpoint.py", line 231, in post_dag_run
session.commit()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 1046, in commit
self.transaction.commit()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 504, in commit
self._prepare_impl()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 483, in _prepare_impl
self.session.flush()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2540, in flush
self._flush(objects)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2682, in _flush
transaction.rollback(_capture_exception=True)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
with_traceback=exc_tb,
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 182, in raise_
raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2642, in _flush
flush_context.execute()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/unitofwork.py", line 422, in execute
rec.execute(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/unitofwork.py", line 589, in execute
uow,
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/persistence.py", line 245, in save_obj
insert,
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/persistence.py", line 1136, in _emit_insert_statements
statement, params
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1011, in execute
return meth(self, multiparams, params)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/sql/elements.py", line 298, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1130, in _execute_clauseelement
distilled_params,
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1317, in _execute_context
e, statement, parameters, cursor, context
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1511, in _handle_dbapi_exception
sqlalchemy_exception, with_traceback=exc_info[2], from_=e
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 182, in raise_
raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1277, in _execute_context
cursor, statement, parameters, context
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 608, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.IntegrityError: (psycopg2.errors.UniqueViolation) duplicate key value violates unique constraint "dag_run_dag_id_execution_date_key"
DETAIL: Key (dag_id, execution_date)=(auto_test, 1967-12-13 20:57:42.043+01) already exists.
[SQL: INSERT INTO dag_run (dag_id, execution_date, start_date, end_date, state, run_id, creating_job_id, external_trigger, run_type, conf, last_scheduling_decision, dag_hash) VALUES (%(dag_id)s, %(execution_date)s, %(start_date)s, %(end_date)s, %(state)s, %(run_id)s, %(creating_job_id)s, %(external_trigger)s, %(run_type)s, %(conf)s, %(last_scheduling_decision)s, %(dag_hash)s) RETURNING dag_run.id]
[parameters: {'dag_id': 'auto_test', 'execution_date': datetime.datetime(1967, 12, 13, 19, 57, 42, 43000, tzinfo=Timezone('UTC')), 'start_date': datetime.datetime(2021, 4, 2, 7, 23, 30, 511735, tzinfo=Timezone('UTC')), 'end_date': None, 'state': 'running', 'run_id': 'dag_run_id_zstp_4435_postman11', 'creating_job_id': None, 'external_trigger': True, 'run_type': <DagRunType.MANUAL: 'manual'>, 'conf': <psycopg2.extensions.Binary object at 0x7f07b30b71e8>, 'last_scheduling_decision': None, 'dag_hash': None}]
<!-- (please include exact error messages if you can) -->
**What you expected to happen**:
<!-- What do you think went wrong? -->
**How to reproduce it**:
<!---
As minimally and precisely as possible. Keep in mind we do not have access to your cluster or dags.
If you are using kubernetes, please attempt to recreate the issue using minikube or kind.
## Install minikube/kind
- Minikube https://minikube.sigs.k8s.io/docs/start/
- Kind https://kind.sigs.k8s.io/docs/user/quick-start/
If this is a UI bug, please provide a screenshot of the bug or a link to a youtube video of the bug in action
You can include images using the .md style of
![alt text](http://url/to/img.png)
To record a screencast, mac users can use QuickTime and then create an unlisted youtube video with the resulting .mov file.
--->
**Anything else we need to know**:
<!--
How often does this problem occur? Once? Every time etc?
Any relevant logs to include? Put them here in side a detail tag:
<details><summary>x.log</summary> lots of stuff </details>
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] vikramcse commented on issue #15150: "duplicate key value violates unique constraint "dag_run_dag_id_execution_date_key" when triggering a DAG
Posted by GitBox <gi...@apache.org>.
vikramcse commented on issue #15150:
URL: https://github.com/apache/airflow/issues/15150#issuecomment-812834217
Hi @kaxil and @ephraimbuddy
I am able to reproduce the issue and tried to resolve it.
Below is the error message returned by the `/dagRuns` api. My question is does the below returned message detail text is correct?
please let me know if it needs some change.
```javascript
{
"detail": "DAGRun with DAG ID: 'taskflow', DAGRun ID: 'dag_run_id_zstp_4435_postman and DAGRun ExecutionDate '2021-04-03 07:50:16.317733+00:00' already exists",
"status": 409,
"title": "Conflict",
"type": "http://apache-airflow-docs.s3-website.eu-central-1.amazonaws.com/docs/apache-airflow/latest/stable-rest-api-ref.html#section/Errors/AlreadyExists"
}
```
Thank You
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] kaxil edited a comment on issue #15150: "duplicate key value violates unique constraint "dag_run_dag_id_execution_date_key" when triggering a DAG
Posted by GitBox <gi...@apache.org>.
kaxil edited a comment on issue #15150:
URL: https://github.com/apache/airflow/issues/15150#issuecomment-812701161
The DagRun table has the following constraints:
https://github.com/apache/airflow/blob/83d702c345f8f4ce16d32268f4f83ee508fea676/airflow/models/dagrun.py#L96-L97
which is why you can't create / trigger a DagRun that violates it i.e. you can't trigger a DAG with same `execution_date` or with same `run_id`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] kaxil commented on issue #15150: "duplicate key value violates unique constraint "dag_run_dag_id_execution_date_key" when triggering a DAG
Posted by GitBox <gi...@apache.org>.
kaxil commented on issue #15150:
URL: https://github.com/apache/airflow/issues/15150#issuecomment-812761779
> @kaxil Thanks for your reply. I got your point, but the client gets a 500 HTTP code now, and I think it better if it returns 400 or 409 or any other suitable code.
Agreed.
cc @ephraimbuddy
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] vikramcse edited a comment on issue #15150: "duplicate key value violates unique constraint "dag_run_dag_id_execution_date_key" when triggering a DAG
Posted by GitBox <gi...@apache.org>.
vikramcse edited a comment on issue #15150:
URL: https://github.com/apache/airflow/issues/15150#issuecomment-812834217
Hi @kaxil and @ephraimbuddy
I am able to reproduce the issue and tried to resolve it.
Below is the error message returned by the `/dagRuns` api. My question is does the below returned message detail text is correct?
please let me know if it needs some change.
```javascript
{
"detail": "DAGRun with DAG ID: 'taskflow' and DAGRun ExecutionDate '2021-04-03 07:50:16.317733+00:00' already exists",
"status": 409,
"title": "Conflict",
"type": "http://apache-airflow-docs.s3-website.eu-central-1.amazonaws.com/docs/apache-airflow/latest/stable-rest-api-ref.html#section/Errors/AlreadyExists"
}
```
Thank You
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] ephraimbuddy commented on issue #15150: "duplicate key value violates unique constraint "dag_run_dag_id_execution_date_key" when triggering a DAG
Posted by GitBox <gi...@apache.org>.
ephraimbuddy commented on issue #15150:
URL: https://github.com/apache/airflow/issues/15150#issuecomment-812847327
> Hi @kaxil and @ephraimbuddy
>
> I am able to reproduce the issue and tried to resolve it.
>
> Below is the error message returned by the `/dagRuns` api. My question is does the below returned message detail text is correct?
> please let me know if it needs some change.
>
> ```js
> {
> "detail": "DAGRun with DAG ID: 'taskflow' and DAGRun ExecutionDate '2021-04-03 07:50:16.317733+00:00' already exists",
> "status": 409,
> "title": "Conflict",
> "type": "http://apache-airflow-docs.s3-website.eu-central-1.amazonaws.com/docs/apache-airflow/latest/stable-rest-api-ref.html#section/Errors/AlreadyExists"
> }
> ```
>
> Thank You
Yes. It is good. Make a PR then if there are any suggestions, we would give
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] kaxil closed issue #15150: "duplicate key value violates unique constraint "dag_run_dag_id_execution_date_key" when triggering a DAG
Posted by GitBox <gi...@apache.org>.
kaxil closed issue #15150:
URL: https://github.com/apache/airflow/issues/15150
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] vikramcse commented on issue #15150: "duplicate key value violates unique constraint "dag_run_dag_id_execution_date_key" when triggering a DAG
Posted by GitBox <gi...@apache.org>.
vikramcse commented on issue #15150:
URL: https://github.com/apache/airflow/issues/15150#issuecomment-812819336
@kaxil I would like to work on this issue
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] kaxil commented on issue #15150: "duplicate key value violates unique constraint "dag_run_dag_id_execution_date_key" when triggering a DAG
Posted by GitBox <gi...@apache.org>.
kaxil commented on issue #15150:
URL: https://github.com/apache/airflow/issues/15150#issuecomment-812701161
The DagRun table has the following constraints:
https://github.com/apache/airflow/blob/83d702c345f8f4ce16d32268f4f83ee508fea676/airflow/models/dagrun.py#L96-L97
which is why you can't create / trigger a DagRun that violates it i.e. you can't trigger a DAG with same execution_date or with same run_id.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] kaojunsong commented on issue #15150: "duplicate key value violates unique constraint "dag_run_dag_id_execution_date_key" when triggering a DAG
Posted by GitBox <gi...@apache.org>.
kaojunsong commented on issue #15150:
URL: https://github.com/apache/airflow/issues/15150#issuecomment-812757758
@kaxil Thanks for your reply. I got your point, but the client gets a 500 HTTP code now, and I think it better if it returns 400 or 409 or any other suitable code.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] ephraimbuddy commented on issue #15150: "duplicate key value violates unique constraint "dag_run_dag_id_execution_date_key" when triggering a DAG
Posted by GitBox <gi...@apache.org>.
ephraimbuddy commented on issue #15150:
URL: https://github.com/apache/airflow/issues/15150#issuecomment-812820764
> @kaxil I would like to work on this issue
@vikramcse I have assigned it to you
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org