0
0
Apache Airflowdevops~20 mins

Atomic operations in pipelines in Apache Airflow - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Atomic Pipeline Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Atomicity in Airflow Tasks

Which statement best describes an atomic operation in an Airflow pipeline task?

AA task that completes fully or does not change the system state at all.
BA task that can be split into multiple smaller tasks for parallel execution.
CA task that runs only once regardless of retries or failures.
DA task that always runs on the same worker node.
Attempts:
2 left
💡 Hint

Think about what it means for a task to be indivisible and consistent.

💻 Command Output
intermediate
2:00remaining
Output of Task Instance State After Failure and Retry

Given an Airflow task configured with retries=1 and retry_delay=5 minutes, what will be the final state of the task instance if it fails once and then succeeds on retry?

Apache Airflow
from airflow.models import TaskInstance
from airflow.utils.state import State

# Simulate task instance
 ti = TaskInstance(task=None, execution_date=None)

# Initial failure
 ti.set_state(State.FAILED)

# Retry attempt
 ti.set_state(State.SUCCESS)
AState.SKIPPED
BState.FAILED
CState.UP_FOR_RETRY
DState.SUCCESS
Attempts:
2 left
💡 Hint

Consider the final state after a successful retry.

Configuration
advanced
2:00remaining
Ensuring Atomicity with XCom in Airflow

Which Airflow task configuration ensures that XCom push operations are atomic and do not cause partial data writes?

ADisable XCom push and use external database for communication.
BUse task instance context manager with commit after XCom push.
CSet retries=0 to avoid multiple XCom pushes.
DUse multiple XCom pushes in parallel tasks.
Attempts:
2 left
💡 Hint

Think about how to commit changes atomically within a task.

Troubleshoot
advanced
2:00remaining
Diagnosing Partial Data Writes in Airflow Pipeline

An Airflow pipeline task writes data to a database but sometimes leaves partial data after failure. What is the most likely cause?

AThe task does not use transactions to wrap database writes.
BThe task uses XCom to pass data between tasks.
CThe task retries are set too high causing duplicate writes.
DThe task runs on multiple workers simultaneously.
Attempts:
2 left
💡 Hint

Consider how database writes can be atomic or not.

🔀 Workflow
expert
3:00remaining
Order of Operations for Atomic Pipeline Execution

Arrange the following steps in the correct order to ensure atomic execution of a data processing pipeline task in Airflow:

  1. Commit database transaction
  2. Process data
  3. Start database transaction
  4. Push XCom result
A3,1,2,4
B1,3,2,4
C3,2,1,4
D2,1,3,4
Attempts:
2 left
💡 Hint

Think about starting a transaction before processing and committing after all steps.