Idempotent schedule ingestion

A scheduling component that can’t double-book: zero duplicate entries, 85% fewer conflicts.

Organisation
Gotel Communication
Role
Systems Engineer — design and engineering
Period
2015 – 2016
Status
Shipped
Fig. 07: Idempotent schedule ingestion — simplified architectureShipped
  1. Schedule updateMay arrive more than once
  2. Content identitySHA-256 + deterministic UUID
  3. Distributed lockRedis
  4. Transactional upsertPostgreSQL
  5. Playout databasesKept in sync by reconcilers
Simplified write path. Any step can be retried without creating a duplicate.

In brief

A broadcast schedule is the backbone of a channel, and network retries were creating duplicate entries in it. I designed the ingestion component for the core programme-scheduling system so the same update can arrive twice — or ten times — and still be recorded once.

For engineers

Python (Django/Flask, Celery) and JavaScript. SHA-256 payload hashing and deterministic UUIDs give each entry an identity derived from its content; Redis distributed locks serialise concurrent writers; PostgreSQL transactional upserts make every write safe to repeat.

  • Python
  • Django / Flask
  • Celery
  • Redis
  • PostgreSQL
  • JavaScript

Context

Gotel Communication’s programme-scheduling system decides what airs, and when. Downstream playout databases depend on it being right.

Problem

Network retries were creating duplicate schedule entries, and timeslot conflicts were causing scheduling errors.

Approach

Each payload is hashed with SHA-256 and given a deterministic UUID, so a retried message resolves to the same entry.

Redis distributed locks stop concurrent workers writing the same entry at once.

Writes are PostgreSQL transactional upserts: repeating one updates the entry and never duplicates it.

A JavaScript validation interface warns about timeslot collisions in real time, and reconciler daemons keep the playout databases in sync.

Architecture

The components in Fig. 07, in the order a request moves through them:

Schedule update
Input · May arrive more than once
Content identity
Processing · SHA-256 + deterministic UUID
Distributed lock
Guardrail · Redis
Transactional upsert
Data · PostgreSQL
Playout databases
Output · Kept in sync by reconcilers

Stack: Python · Django / Flask · Celery · Redis · PostgreSQL · JavaScript

Key decisions

  1. Identity from content

    If the ID is derived from the payload, a retry can’t create a new record — it can only find the existing one.

  2. Locks for concurrency, upserts for safety

    The lock prevents simultaneous writes; the upsert makes any repeated write harmless.

  3. Catch conflicts at entry

    Warning schedulers about collisions as they work is cheaper than fixing a conflict after it airs.

Outcome

  • 100%

    of duplicate entries eliminated during network retries

  • 85%

    fewer scheduling conflict errors

  • 60%

    less manual data-entry time

  • 50%

    higher ingestion throughput

Start a conversation

Have a difficult problem,
interesting market,
or ambitious idea?

Let’s explore whether there’s something worth building together.