Indexing and sync
The sync service is how source data becomes objects. It reads the change data feed of every backing dataset, turns each changed row into an object version, and writes that version to the object store and the search index in source commit order, exactly once. This page covers the guarantees it holds, how it recovers, how a full backfill and a reindex run without taking the type offline, and how to watch freshness
In the platform today
- The sync service runs in the platform service and reads each backing dataset's change data feed from the last version it applied, overlays active edits under the type's conflict policy and upserts the objects, so applying the same version twice changes nothing
- The search index, including the vectors for similarity search, is kept current from the object change feeds and the document tables' change feeds, and
POST /api/v2/search/reindexrebuilds it - The same change feeds drive push updates to the app
- Each sync is a row in
ops.sync_runs - A source row is refused, and its object kept as it was, when its key is empty (
KEY_MISSING), when the same key appears twice in a full read (DUPLICATE_KEY, neither row is taken), when a required property is empty after edits are overlaid (REQUIRED_PROPERTY) or when it cannot be read (UNREADABLE); the run counts them inrows_rejectedand lists the first 50 with key and reason inrejections - An object an action deleted stays deleted while its source row is still there, and one an action created stays although no source row names it, through
_deletedand_createdmarkers, as described on object storage - The Prometheus endpoint
GET /metricsexportsms_sync_runs_total,ms_sync_rows_upserted_totalandms_sync_last_success_timestamp_secondsper object type
- The commit log with
commitSeq, several jobs per type, the rejected rows tableops.rejected_rowswith a stop threshold, the duplicate key stop at the previous checkpoint, steps of 500,000 rows, index generations with an atomic swap, the freshness targets and theontology_*metrics and alerts on this page
From source commit to object
A backing dataset is a Delta Lake table with one row per object, written by a pipeline or directly by a connector. Every write to it is a commit with a version number. When change data feed is on, which the platform enforces for every backing dataset, each commit also records which rows were inserted, updated or deleted, with the before and after image of each update
The sync service runs one sync job per pair of object type and backing dataset. A type backed by two datasets, for example a Production batch that takes core fields from the MES and costing fields from the ERP, has two jobs, each with its own checkpoint, each owning a declared subset of the type's properties
What a job does with each commit
- Read. The job reads the change data feed for the next dataset version after its checkpoint, or for a range of versions when it is behind. It reads at most 500,000 changed rows per step, so a very large commit is processed in several steps that all carry the same dataset version
- Validate. Each row is checked against the object type: primary key present and unique within the version, required properties non-null, values castable to the property's base type and inside its value type constraints, and values no larger than 5 MB
- Map. Columns become properties through the type's mapping, and the row becomes an object version. Updates carry only the properties this job owns. Deletes become tombstones. Rows whose values did not change after mapping are dropped, so a pipeline that rewrites a whole table does not churn versions
- Commit. The batch is written through the commit log, which assigns a
commitSeq. From here the object store and the search index follow the same ordered log - Checkpoint. When the commit log has acknowledged every row of the dataset version, the job records that version as its checkpoint. A crash before this step replays the version, and idempotency makes the replay harmless
Ordering
Within one job, versions are applied strictly in source commit order. Dataset version 4419 is never applied before 4412, even if a step for 4419 is ready first. Within one dataset version, rows are applied in the order the change feed reports them, and the commit log sees the whole dataset version as one or more consecutive batches with increasing commitSeq
Across jobs there is no global order, because there is no global clock between an MES and an ERP. Two jobs that own different properties of one object never overwrite each other, since each writes only its own properties. If two jobs are declared to own the same property, which the registry allows only with an explicit precedence, the job with the higher precedence wins regardless of arrival order
| Scope | Ordering guarantee |
|---|---|
| One object, one job | Total order by dataset version, then row order |
| One object type, one job | Total order by dataset version. Readers never see version 4419 of one object and 4412 of another from the same job at one snapshot unless 4419 is still being committed in steps |
| One object, several jobs | Property ownership prevents conflicts. Shared properties resolve by declared precedence |
| Sync versus actions | Both go through the commit log. The type's conflict policy decides the effective value, not arrival order |
| Across object types | No order. A link may briefly point at an object that has not arrived yet, and resolves when it does |
Exactly once
The sync service is built on at-least-once delivery: jobs crash, steps time out and the feed is re-read. Exactly-once effect comes from making every write idempotent. The idempotency key for a source row is the pair of dataset version and primary key
- The object store keeps, per object and per backing dataset, the last dataset version applied (
_source_version). The commit log accepts a row only if its dataset version is greater than the stored one. A replayed row has an equal version and is skipped without a new object version - The search index uses external versioning on
commitSeq. A document is replaced only by a highercommitSeq, so a replayed or reordered index write is a no-op - The checkpoint is written after the commit log acknowledges, never before. Losing a checkpoint costs a replay, never a gap
The same key makes the system safe against things that look like duplicates but are not. A row deleted in version 4430 and re-inserted in 4431 produces a tombstone and then a new version, with _version continuing from where it was, because both dataset versions are distinct and greater than the stored one
On request. In the platform service today neither row of a duplicated key is taken in a full read: the object keeps its last good state and the key is listed in the sync run's rejections as DUPLICATE_KEY, while the other keys sync. If one dataset version contains two rows with the same primary key, the job does not pick one. It stops at the previous checkpoint, the type keeps serving its last good state, and the duplicate keys are written to the rejected rows dataset with a DUPLICATE_PRIMARY_KEY reason. Fix the pipeline, and the job resumes on the next commit. Picking a row arbitrarily would make objects depend on file order
Rejected rows
In the platform service today, rows that fail are kept out of the object store and listed in the sync run, as below. On request, rows that fail validation for any other reason go to the rejected rows table, ops.rejected_rows, with the object type, the dataset version, the primary key, the rule that failed and the offending value, and the rest of the commit proceeds. By default a job stops if more than 1% of the rows in one dataset version are rejected, since that usually means a broken pipeline rather than a few bad records. Set the threshold per type, from 0% to 100%
-- In the platform service today: what the last syncs refused, and why
SELECT object_type, started_at, rows_upserted, rows_rejected, rejections
FROM ops.sync_runs
WHERE rows_rejected > 0
ORDER BY started_at DESC
LIMIT 10;
-- batch | … | 412 | 1 | [{"key": "B-0846", "reason": "REQUIRED_PROPERTY", "detail": "line"}]
-- Why did yesterday's batches not show up
SELECT dataset_version, primary_key, rule, property, left(value, 80) AS value
FROM ops.rejected_rows
WHERE object_type = 'batch'
AND rejected_at >= current_date - INTERVAL 1 DAY
ORDER BY rejected_at DESC;
-- 4419 | B-0846 | REQUIRED_PROPERTY_NULL | line | null
-- 4419 | B-0847 | VALUE_TYPE_CONSTRAINT | qaStatus | Held (not a listed value)
Where guarantees stop
Two different promises are easy to confuse. Idempotency is a property of each write: applying the row for dataset version N and key B-0841 twice has the same effect as applying it once, because the commit log rejects a dataset version that is not newer than _source_version. Exactly-once is the end-to-end result the sync service builds from that: every committed change in a backing dataset becomes exactly one object version in the object store and the index, even though jobs crash, steps time out and the feed is re-read. Delivery underneath is at least once; the effect is exactly once
The guarantee starts when a change is committed to a backing dataset's change data feed, and ends when the object version is visible in the object store and the index. Before that point, what counts as a change is decided by the source system, the connector and your pipeline. After it, anything that reads changes back out, such as a subscription, a webhook or your own consumer of the change feed, receives them at least once
| Stage | Guarantee | Who owns it |
|---|---|---|
| Source system commits a change | None from the platform. A change the source never committed, or rewrote without a new commit, is invisible to sync | You and the source system |
| Connector extract into raw tables | Change capture connectors read the source log in order; batch extracts see only what their query returns | Shared. A batch query that skips rows, or a source that edits history in place, is yours to fix |
| Pipeline build of the backing dataset | Each build is one Delta commit; checks block bad builds | You own the step logic and the primary key |
| Backing dataset commit to object version | Exactly-once effect, in source commit order per job, idempotent on dataset version plus primary key | The platform |
| Object version to index | Exactly once by external versioning on commitSeq | The platform |
| Subscriptions, webhooks and change feed reads | At least once, in order per object | Your consumer deduplicates on _key plus _version |
If an ERP job overwrites last week's rows without producing a new commit in its change log, or a nightly extract filters out rows by mistake, the sync service faithfully applies exactly what it was given. Use data quality checks on row counts and freshness to catch those cases before they reach objects
Backfills
Incremental sync covers the steady state. Some events need a full pass over a dataset instead
- The object type is created, or a new backing dataset is added to it
- The backing dataset is overwritten by a non-incremental pipeline build, or its change data feed has gaps because a version was vacuumed before the job read it
- A property mapping changes in a way that affects existing rows, such as a new column mapped to a property
- An administrator requests a backfill to repair drift
A backfill pins a snapshot of the dataset at version N, reads it in parallel by file, and writes every row as if it came from version N. Because writes are idempotent on dataset version, rows already applied at N or later are skipped, and the backfill never moves an object backwards. When the snapshot is done, the job resumes the change feed from N + 1. Incremental changes that arrive during the backfill wait in the feed, and readers keep seeing the existing objects the whole time. Objects missing from the snapshot become tombstones at the end, since their absence is only meaningful once the whole snapshot has been read
A backfill writes at typically 50,000 to 150,000 objects per second per object type, depending on row width, so a type with 20 million objects backfills in a few minutes
Reindex without downtime
A reindex rebuilds the search index for a type from the object store. It is needed when indexing settings change: a property becomes searchable, an analyzer changes, a vector property is added, or the index layout is upgraded in a release. Readers never see a half-built index, because a reindex builds a new index generation beside the live one and swaps them atomically
- Create the new generation. The index for the type is named by generation, such as
batch__g8, created empty with the new settings - Start dual-writing. The index writer records the current
commitSeqas S and from then on writes every change for the type to both generations - Copy. A copy job reads the object store at snapshot S and writes every live object to the new generation. Because the index uses external versioning on
commitSeq, a dual-written change that is newer than the snapshot is never overwritten by the copy - Verify. The service compares object counts per bucket and a checksum of primary keys and versions between the object store and the new generation, and runs a sample of recent production queries against both, comparing result sets
- Swap. The alias moves from the old generation to the new one in one metadata update
- Keep for rollback. The old generation keeps receiving dual writes for 24 hours. Rolling back is another alias swap, and costs nothing
Reindexing runs apart from live indexing, so it does not slow it. Changes on a branch that need a reindex are built when the proposal is merged, and the merge completes when the swap does
Freshness targets
Freshness is measured end to end, from the moment a commit lands in the backing dataset to the moment a query can see the resulting object version. These are design targets for the managed cloud with a healthy pipeline. They exclude the time the pipeline itself takes to produce the backing dataset
| Path | Typical p50 | Typical p99 | Notes |
|---|---|---|---|
| Action edit, visible to the caller | Immediate | Immediate | Read-your-writes through the consistency token |
| Action edit, visible to other readers | Under 1 s | Under 5 s | Index lag behind the commit log |
| Source commit to point read | Under 1 s | Under 10 s | Point reads do not wait for the index |
| Source commit to object set query | Under 2 s | Under 15 s | Commits under 10,000 changed rows |
| Large source commit, 1 million changed rows | Under 30 s | Under 2 min | Processed in steps of 500,000 rows |
| Full backfill | 50,000 to 150,000 objects per second per type | Readers keep the previous state throughout | |
The end-to-end latency a person sees also includes the connector and the pipeline. A change data capture connector from an ERP with an incremental pipeline typically adds 5 to 30 seconds. A file drop that runs every 15 minutes adds up to 15 minutes, and no index can recover that
Monitoring
Every object type has a Sync tab in Build, then Ontology, with the state of each job, its lag, recent dataset versions and rejected rows. The same signals are exported as metrics to your own tools through observability
| Metric | Labels | What it tells you |
|---|---|---|
ontology_sync_lag_seconds | type, dataset | Time from the newest unprocessed source commit to now. Zero when caught up |
ontology_sync_versions_behind | type, dataset | Dataset versions committed but not yet checkpointed |
ontology_sync_rows_total | type, dataset, op | Rows processed by insert, update, delete and unchanged |
ontology_sync_rejected_total | type, dataset, rule | Rows sent to the rejected rows dataset |
ontology_sync_job_state | type, dataset | Running, catching up, backfilling, stopped or failed |
ontology_index_lag_seconds | type | Index checkpoint behind the commit log |
ontology_index_generation | type | The generation the alias points to, and any building one |
ontology_freshness_seconds | type, quantile | End-to-end source commit to queryable, from sampled commits |
Three alerts are on by default for every type, each delivered to the type's owners
alerts:
- name: sync-lagging
expr: ontology_sync_lag_seconds > 300
for: 10m
- name: sync-stopped
expr: ontology_sync_job_state{state=~"stopped|failed"} == 1
for: 1m
- name: rejects-rising
expr: rate(ontology_sync_rejected_total[15m]) > 0.1
for: 15m
Operational screens show a freshness stamp from ontology_sync_lag_seconds next to every list, such as "Deliveries as of 14:02:31". A dispatcher who can see that data is two minutes old makes a different call than one who assumes it is live
Limitations
- There is no ordering across sync jobs or across object types. A link can briefly point at an object that has not arrived yet
- A dataset version with a duplicate primary key stops the job at its last checkpoint. The type serves stale data until the pipeline is fixed and a new commit lands
- Change data feed must stay readable until the job has processed it. A version vacuumed before the job reads it forces a full backfill
- Freshness targets cover only the path from backing dataset commit to query. Connector and pipeline time come on top, and a scheduled file drop cannot be made faster by the index
- Two jobs can own the same property only with an explicit precedence. Without one, the registry refuses the mapping rather than letting arrival order decide
- Rejected rows are kept out of the object store, not repaired. They stay missing until the source or pipeline is fixed and the row is committed again