Keep the edges equal to the source
The graph should match the source system's current edges, without a gap while it catches up.
The situation
For a team whose source system knows each node's current edges: what a package depends on, who maintains what. The usual way to sync is to delete the run, then reload it: a full rebuild, with readers seeing missing data meanwhile.
Step by step
-
Problem 1. Delete, then reload
Every sync deletes the edges and writes them all again. While it runs, readers see some of them missing, and every edge is rewritten, changed or not.
Readers see edges missing: while the reload runs · Edges written: all of them · Before anything is written: —
-
With graphos 2. Send the set as the source has it
The source sends the whole set to
POST …/graph/edges:reconcile. Its scope is one node's edges of a type (here, whatappdepends on), or every edge of a type between two labels.A type's set can be up to 10,000 edges as JSON, or up to 200,000 as an NDJSON stream.
-
How it works 3. A dry run first
With
?dry_run=true, graphos answers what it would do and writes nothing: so many added, changed, kept and removed.Before anything is written: a dry run, with the counts
-
With graphos 4. Only the difference, in one transaction
graphos makes the stored set equal to the one sent, in one transaction: a missing edge is added, a changed one rewritten, and an edge the source no longer has is removed.
Readers see the old set or the new one, never a half-way state.
Readers see edges missing: never: one transaction · Edges written: only what differs
-
How it works 5. A kept edge isn't touched
An edge that hasn't changed isn't written, so its revision stays. A wanted edge whose other end doesn't exist is skipped and counted, with the first 100 listed.
-
How it works 6. On the change feed
The reconciliation is recorded as one upsert and one delete in the change feed, with the edges' ids listed, up to 10,000.
What graphos does here
- Writes through the API
- Writes only the difference.
- Reconcile
- Makes a scope's stored edges equal to the set sent.
- Change feed
- Records what was added, changed and removed.
What shows it: Tested
Tested: graphos's tests check that a node scope adds, changes, keeps and removes only inside it, the incoming direction and a dry run, and that a type scope from NDJSON equals a fresh load and is recorded. No benchmark covers it. Edges only: there is no reconcile for nodes. The package names drawn are examples.
In graphos's latest release and covered by graphos's automated tests; no result is measured for it here.
Try it
The usage guide's section on reconciling shows both scopes, the dry run and the Python calls.
Related use cases
- Load a big graph, and load it again · Tens of thousands of edges should go in fast, and sending them again after a failure should be safe.
- Follow every change · A search index, a cache or another service should learn what changed in the graph, and never miss a write.
- A spreadsheet in, checked first · A CSV file from a spreadsheet or another system should become nodes, with every row checked before anything is written.