[ https://issues.apache.org/jira/browse/AIRFLOW-4238?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16937613#comment-16937613 ]
Ash Berlin-Taylor commented on AIRFLOW-4238: -------------------------------------------- This is probably caused by the (currently) hard-coded setting of {{replace_microseconds}} causing it to attempt to create a dagrun for a time that already exists. The fix would be to probably to change {code:python} dr = trigger.trigger_dag(dag_id, run_id, conf, execution_date) {code} to be something like {code:python} dr = trigger.trigger_dag(dag_id, run_id, conf, execution_date, replace_microseconds=execution_date is None) {code} > Experimental API sometimes responds with Bad Request > ---------------------------------------------------- > > Key: AIRFLOW-4238 > URL: https://issues.apache.org/jira/browse/AIRFLOW-4238 > Project: Apache Airflow > Issue Type: Bug > Components: api > Affects Versions: 1.10.2 > Reporter: Roger Lahaije > Priority: Minor > > We wanted to use the Airflow api to start Dag runs. > During implementation we notices the API sometimes responded with error 400 > bad request. > The bad request appear to happen when calls are made fast after oneanother. > > The following code can reproduce the bad requests > {code:java} > import requests > import json > from datetime import datetime > start_time = datetime.now() > def millis(): > dt = datetime.now() - start_time > ms = (dt.days * 24 * 60 * 60 + dt.seconds) * 1000 + dt.microseconds / > 1000.0 > return round(ms) > url = f'http://localhost/api/experimental/dags/some dag/dag_runs' > for i in range(1, 40): > r = requests.post(url, json={'conf': {'run_task': 1}}) > print(f"{millis()} {r.status_code}") > sleep(0.4) > >> results > 132 200 > 561 400 > 1006 200 > 1425 400 > 1870 200 > 2295 400 > 2738 200 > 3171 400 > 3594 400 > 4039 200 > ...{code} > > It looks like it's only possible to call the api a maximum of once a second, > which is probably due to the fact dags can only be started once a second. > > Is there any way we can call the API more than 1 time a second? -- This message was sent by Atlassian Jira (v8.3.4#803005)