You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "Roger Lahaije (JIRA)" <ji...@apache.org> on 2019/04/04 15:12:00 UTC

[jira] [Created] (AIRFLOW-4238) Experimental API sometimes responds with Bad Request

Roger Lahaije created AIRFLOW-4238:
--------------------------------------

             Summary: 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


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
(v7.6.3#76005)