Skip to main content
๐Ÿ“˜ Complete PDF

Airflow Certification Practice Test 11

Practice Test 11

Question 1 of 20
๐Ÿ“‹ Multiple Choice
Question 201
A daily retail sales aggregation DAG usually finishes in 20 minutes. Today, the pipeline is still running after 2 hours. Operational investigation reveals: - Airflow Scheduler is healthy with low heartbeat latency - Celery/Kubernetes workers are healthy and operating normally - Task logs indicate an external relational database query has been executing for 90 minutes without returning rows What is the MOST likely root cause?
A. Airflow Worker Pool concurrency configuration limit
โœ“
B. Slow source database query caused by missing database indexes or lock contention
C. DAG filename naming convention mismatch
D. XCom message size payload limitation
Answer
โœ… B. Slow source database query caused by missing database indexes or lock contention
Explanation

1. Direct Question Answer & Core Concept โœ… B. Slow source database query caused by missing database indexes or lock contention

Core Concept: Airflow acts as an orchestrator, delegating heavy query execution to external data platforms; long task durations when Airflow components are healthy typically stem from external query performance degradation or database table lock contention.

2. Deep-Dive Analytical Explanation Airflow operators like `PostgresOperator`, `SnowflakeOperator`, or `PythonOperator` initiate execution on external databases and wait synchronously for the database cursor to complete. Airflow scheduler and worker infrastructure are healthy, which proves the issue is not worker starvation or scheduler delay. Worker pools (Option A) restrict concurrency before a task starts, not while it is executing. DAG naming (Option C) affects file discovery. XCom limits (Option D) cause serialization errors upon task completion. A 90-minute query execution on a job that normally takes 20 minutes indicates an external database issue: missing table indexes, an unoptimized execution plan, or exclusive table locks held by an uncommitted transaction in the source database.

3. Comprehensive Option Analysis & Distractor Dissection - **A. Airflow Worker Pool concurrency configuration limit:** Pools control task concurrency queuing before tasks start; they do not cause a running database query to execute slowly. - **C. DAG filename naming convention mismatch:** Naming issues prevent DAG discovery in the webserver; they do not alter query runtimes. - **D. XCom message size payload limitation:** XCom limits cause database serialization errors when returning payloads, not long-running query execution.

4. Architectural & Execution Context / Physical Execution When an Airflow worker executes a database hook, it opens a TCP connection and issues the SQL statement. The worker thread enters a blocking wait state (`socket.recv`), consuming a worker slot until the remote database engine returns the result set.

5. Practical Code Example

/* Diagnosing long-running locked queries on PostgreSQL / MySQL source DB */
SELECT 
    pid, 
    usename, 
    query, 
    now() - query_start AS duration, 
    state, 
    wait_event_type, 
    wait_event
FROM pg_stat_activity
WHERE state != 'idle' 
  AND now() - query_start > interval '30 minutes'
ORDER BY duration DESC;

6. Key Takeaway Distinguish between Airflow orchestration delays and external system execution delays by inspecting task log timestamps and external database activity.

7. Best Practice & Production Recommendation Always configure `execution_timeout` on database tasks (e.g., `execution_timeout=timedelta(minutes=45)`) so that hung external queries fail fast and trigger alerts instead of occupying worker slots indefinitely.

8. Real-World Engineering Scenario A nightly ETL task hung for 4 hours. Inspection revealed an analyst had opened a GUI transaction on the source PostgreSQL table at 5:00 PM and left work without committing, causing Airflow's table lock acquisition to wait all night.

9. Common Exam Trap / Anti-Pattern / Misconception Assuming that because the task appears red or running in the Airflow UI, Airflow compute nodes are under-provisioned; Airflow is merely the messenger waiting for external database execution.

10. Related InsightfulSaga Tutorial Master these concepts in [Monitoring DAGs & Operational Observability in Airflow](/tutorials/airflow/monitoring-dags-airflow).

Answered: 0 / 20
Question Navigator (Test 11)0% Answered