You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python Glue Job在Step Function调用后状态机不推进的问题咨询

Hey there, let's figure out why your Step Function isn't moving past the Glue Job task even though the job itself succeeds. I've run into this exact scenario a few times, so here's what you need to check:

1. Critical Permissions for Step Functions Execution Role

The .sync integration for Glue doesn't just need permission to start the job—it needs to poll the job's status until completion. Your Step Functions execution role is missing these permissions if it's stuck waiting:

  • glue:GetJobRun: Required to fetch detailed status updates for the specific job run
  • glue:GetJobRuns: Used to list all runs for your Glue job (helps with state polling)
  • You already have glue:StartJobRun (since the job starts), but double-check that it's included too

Also, make sure your role's trust policy allows states.amazonaws.com to assume it—this is easy to miss when setting up roles manually.

2. State Machine Configuration Tweaks

Your current state definition uses startJobRun.sync correctly, but there are two gotchas here:

Timeout Mismatch

Step Functions tasks have a default timeout of 3600 seconds (1 hour). If your Glue job runs longer than that, the Step Function will hit a timeout instead of waiting for success. Add a TimeoutSeconds parameter to match your job's actual runtime:

"MyGlueTask": {
  "Type": "Task",
  "Resource": "arn:aws:states:::glue:startJobRun.sync",
  "Parameters": {
    "JobName": "my_glue_job"
  },
  "ResultPath": "$.MyGlueTask",
  "Next": "NextGlueJob",
  "TimeoutSeconds": 10800  // Adjust to 3 hours (or whatever your job needs)
}

Verify Job Run Status in Glue Console

Sometimes a job looks like it succeeded in logs, but Glue marks it as FAILED under the hood (e.g., a final write to S3 failed silently, or an unhandled exception slipped through). Head to the Glue Console → Job Runs, find the specific run tied to your Step Function, and confirm its status is definitely SUCCEEDED.

3. Python Glue Job Script Checks

You don't need any special code in your Python script to signal success to Step Functions—Glue handles that automatically. But avoid these mistakes that can break the status signal:

  • Don't use sys.exit() or uncaught exceptions: Even if your logic completes, an unhandled exception will mark the job as FAILED. Wrap risky operations in try/except blocks, and let the script exit naturally when done.
  • Ensure final operations complete: If your job writes to S3, Redshift, etc., make sure those operations finish without errors. Glue only marks the job as SUCCEEDED when all tasks in the job run finish cleanly.
  • No manual status updates needed: You don't have to call any Glue APIs from your script to update the job status—Step Functions relies on Glue's native state tracking.

4. Troubleshooting Logs to Dig Deeper

If you're still stuck, check these logs:

  • Step Functions Execution Logs: In the Step Functions console, open the failed/stalled execution and look for error messages (e.g., "AccessDenied" when calling glue:GetJobRun).
  • CloudWatch Logs for the Step Functions Role: Search for denied API calls—this will tell you exactly which permission is missing.

内容的提问来源于stack exchange,提问作者Greg McGuffey

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.13 08:53:09