<@U04S8PLJWMT> Unable to cancel airbyte jobs. &gt...
# ask-ai
s
@kapa.ai Unable to cancel airbyte jobs.
>> res = requests.delete(cancel_job_url, headers=header)
>> print(res.json())
{'status': 409, 'type': 'https://reference.airbyte.com/reference/errors#409-state-conflict', 'title': 'state-conflict', 'detail': 'State conflict', 'documentationUrl': None, 'data': {'message': 'Job is not currently running'}}
k
The error message you are seeing:
Copy code
{'status': 409, 'type': 'https://reference.airbyte.com/reference/errors#409-state-conflict', 'title': 'state-conflict', 'detail': 'State conflict', 'documentationUrl': None, 'data': {'message': 'Job is not currently running'}}
means that the Airbyte job you are trying to cancel is not in a "running" state. The Airbyte API only allows cancellation of jobs that are currently running. If a job has already completed, failed, or is in any other state, attempting to cancel it will result in a 409 state conflict error, as you observed. This behavior is consistent with the Airbyte API specification, which states that the cancel job endpoint (
DELETE /jobs/{jobId}
) is used to cancel a running job. If the job is not running, cancellation is not possible and a conflict error is returned<sup>[Airbyte Public API - Jobs > Methods](https://raw.githubusercontent.com/airbytehq/airbyte-platform/f284238f0099c4c0a3542d4c42a88773c45c363d/airbyte-api/src/main/openapi/api.yaml)</sup>. What you can do: - Before attempting to cancel a job, check its current status. Only jobs with a status of "running" can be cancelled. - If you are seeing jobs stuck in a non-running state (e.g., "pending" or "incomplete"), you may need to investigate further why they are not progressing or being marked as running. If you need to programmatically check the job status before cancelling, you can use the Airbyte API to fetch the job details and inspect the
status
field. If you have further issues with jobs hanging or not transitioning to the "running" state, there may be underlying issues with your Airbyte deployment or resource availability. In such cases, reviewing the Airbyte logs and system health is recommended.
s
@kapa.ai I see the job listed in running api
k
A message from kapa.ai
If you see the job listed as "running" via the API, but receive a 409 "Job is not currently running" error when trying to cancel it, this suggests a possible state inconsistency between the Airbyte API and the underlying job execution system. This issue has been reported by other users as well, where jobs appear stuck in the "running" state in the UI or API, but cannot be cancelled because the backend does not recognize them as truly running. This can happen due to resource issues, stuck worker pods, or other internal errors that prevent the job from progressing or being properly updated in the database. For example, users have reported jobs stuck in "running" that required manual intervention, such as restarting pods or increasing resources, to resolve the state mismatch<sup>[Sync Stuck in Running / K8s](https://discuss.airbyte.io/t/680)</sup>. Additionally, Airbyte has introduced a heartbeat service in newer versions to detect and autorecover from hanging connections that remain perpetually "in-progress" without moving data. This service can help automatically create a new job attempt if a sync is detected as stuck<sup>[Release Notes 1.4 - Autorecovery for hanging connections](https://docs.airbyte.com/release_notes/v-1.4#-bug-fixes)</sup>. What you can do: - Ensure you are running a recent version of Airbyte with the heartbeat/autorecovery service. - Check the Airbyte worker and server logs for errors or resource issues. - If jobs are stuck and cannot be cancelled, try restarting the relevant Airbyte pods or services. - If the issue persists, you may need to manually update the job status in the Airbyte database, but this should be done with caution and is not officially documented. If you continue to experience this issue, it may be a bug or a deeper infrastructure problem, and you may want to open a support ticket or GitHub issue with detailed logs and version information.
s
@kapa.ai How to do this f jobs are stuck and cannot be cancelled, try restarting the relevant Airbyte pods or services.
k
A message from kapa.ai
To restart Airbyte pods or services when jobs are stuck and cannot be cancelled, you can follow these general steps, depending on your deployment type: ### For Kubernetes Deployments You can delete the stuck pods, and Kubernetes will automatically recreate them. For example, to restart all Airbyte pods in the
airbyte
namespace:
Copy code
bash kubectl delete pods --all -n airbyte
Or, to restart a specific pod (replace
<pod-name>
with the actual pod name):
Copy code
bash kubectl delete pod <pod-name> -n airbyte
This approach has been suggested in community discussions when jobs or the UI become unresponsive. Deleting failed or stuck jobs and restarting pods can help restore Airbyte to a working state if there are no deeper infrastructure issues. However, if the problem persists after restarting, you may need to investigate logs for further troubleshooting<sup>[Sync Stuck in Running / K8s](https://discuss.airbyte.io/t/680)</sup>. ### For Docker Compose Deployments You can restart all Airbyte services with:
Copy code
bash docker-compose restart
Or, to stop everything and start fresh (note: this does not delete your data):
Copy code
bash docker-compose down docker-compose up -d
This method has been reported to resolve issues where all syncs are stuck in "pending" or "running" states<sup>[All Airbyte Syncs stopped for several days](https://discuss.airbyte.io/t/1018)</sup>. --- Note: Restarting pods or services will interrupt any running jobs, but it is a common first step to recover from stuck or unresponsive states in Airbyte. If you continue to experience issues, further investigation into logs and resource allocation is recommended.