Page MenuHomePhabricator

Improve handling of new stream onboarding in Refine
Closed, ResolvedPublic

Description

Problem / Context:
When adding a new stream to Refine, we currently need to coordinate three jobs:
1/ Canary events creation
2/ Gobblin ingestion to HDFS
3/ Refinement of the partition

The problematic interaction is:

  • ESC makes it immediately accessible from Canary & Refine.
  • Canary-events dag generates events without delay.
  • Gobblin, on a new topic, starts ingestion from the last event onward.
  • Refine fetches the config from ESC with a 1h25min delay.
  • Refine then "senses" for data for 2 consecutive hours.

Observed Failure:
When a new job is declared, Refine times out while sensing for data in a partition because:

  • Canary events may not yet exist for the stream.
  • Gobblin may not have imported the first canary events to HDFS.

This leads to unnecessary job failures on first runs of new streams.

Proposed Solution:
When building the list of streams to refine at the start of the Refine DAG run, fetch only the list of streams for which canary events were produced at least 3 hours ago.

  • This ensures Canary has a head start over Refine.
  • Keeps the pipeline consistent by avoiding streams that aren’t ready.
  • Cost is minimal since the filtering is lightweight.

Drawback: we may miss the Refinement of an hour or two. But those are likely to be empty. And this will be documented.

Details

Related Changes in GitLab:
TitleReferenceAuthorSource BranchDest Branch
Refine bootstrap newly declared streamrepos/data-engineering/airflow-dags!1617aquT402186_refine_onbording_new_streamsmain
Customize query in GitLab

Event Timeline

Gobblin may not have imported the first canary events to HDFS.

Alternate solution: change gobblin setting to consume from beginning of topic if no offset is saved. I think this will be fine for any/all event topics. In rare edge cases it may make gobblin do way too much work or consume duplicates (e.g. if the gobblin jobs state with saved offsets is lost somehow).

I'm not sure if this is better or worse than your proposed solution though!

Antoine_Quhen changed the task status from Open to In Progress.Aug 21 2025, 1:52 PM
Antoine_Quhen claimed this task.
Antoine_Quhen moved this task from Incoming (new tickets) to Next Up on the Data-Engineering board.

We now have an implemented solution.

The problem is, with the new stream, event if Gobblin ingest since beginning of stream. It's not enough to mark the first hour as refinable.

As soon as the stream is declared on ESC in hour H:

  • the canary events dag will add an event in hour H for this stream
  • whereas Refine will organise its work (including fetching the stream) for H-2.

Refine then "senses" for data for 2 consecutive hours.

Ah, I see. Hm. Is there a way to vary the sensor? If this is the first run of the mapped task, don't bother sensing for H-2?

I'm guessing the answer is no, because Airflow can't (easily) know about past state of mapped tasks?

This could be a solution but it's much simpler to filter out the new streams at beginning in place of adding a layer of customization to the sensor.

Also, current solution keeps the number of requests to Airflow DB low. (1 extra request on top of dag)

The fix is in production. Notice the line Retrieved 201 stream(s) from canary_events at 2025-09-10 06:35:00+00:00 in the logs.

Screenshot 2025-09-10 at 1.52.46 PM.png (1,510×615 px, 172 KB)