Incremental Sync and Change Detection
In this article
- List the changes since a saved change token from the source's own version signal, and say when a content hash is needed and when it is not.
- Sort a change into a content edit, a metadata-only change or a delete, and name the action each one gets.
- Apply changes as idempotent upserts and tombstones, and save the checkpoint only after the changes before it are committed, so a crash and a replay leave the same index as a run without the crash.
- Terms defined here: change token, tombstone, idempotent upsert.
Overview
In an invented example, Brightline, a home-internet provider, runs a support assistant on its website that answers customers and can look up an order, issue a refund of at most $50 and hand a conversation to a person on the support team. Before the assistant can search them, Brightline's help pages, router manuals, staff handbook and past conversations are read from the systems where they are kept and turned into documents that a search index can take.
The search index is the store of chunks, the pieces cut from documents for search, arranged so a program finds the matching ones quickly. It has to follow the sources as they change. Every night a sync goes through the about 400 help pages in the website's content system. Tonight the content system lists 40 pages as changed since the last run, and the worker crashes after it has committed 25 of them. The company, its pages and these numbers are made up for the example.
Reading all 400 pages again every night would work, but it repeats the whole ingestion to find a few edits. The better sync remembers three things: how far it has read the source's changes, what version of each page it already holds, and which pages are gone. With those, a crash costs nothing but a replay, and the replay ends in the same index as a run that never crashed.
Sign in to keep reading
The rest of this article opens with an account. An account also keeps your progress and quiz results on every device, and lets you follow news for up to five topics.
Still to read in this article
- Reading only what changed
- Three kinds of change
- Idempotent upsert
- The crash after 25
- Common mistakes
- Sources
- Check yourself, 13 questions