Repository navigation
Conversation
…llections Typesense 30.2 loses an async_reference written while its referent’s collection is being imported. Every batch import now goes through a lock shared by its join component: imports into one collection still overlap, an import into another waits, and waiters go in arrival order. One run now resolves every join, blue/green included. ADR 39 amends ADR 19; the second ADR 31 is renumbered to 38.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Typesense 30.2 permanently loses an
async_referencewritten while the referenced collection is being imported. Until now the docs said to run the indexer twice on a first build. That fails forREBUILD_MODE=blue-green, because every blue/green run is a first build.Every batch import (upsert or update) now goes through a lock shared by its join component. Any number of imports into one collection run at once. An import into another collection of the component waits until none is in flight. Waiters go in arrival order, and all waiters of the admitted collection go in together, so a busy collection cannot starve the others. A type outside any join never waits.
Where the lock lives. The issue proposed
searchIndexWriter, but the router only sees a stream of documents per type. The batches are cut inside@lde/search-typesense(documents.ts), so the router cannot tell when an import is in flight. Locking a wholewriteper type would deadlock a write call that feeds two collections of one component. So the lock wraps the one function that sends an import to Typesense. Each writer looks the lock up from its schema’s join component, the wayjoinGraphcaches its graph per schema. No new option or interface. The writers of a component share the lock as long as they get the sameSearchSchema, whichsearchIndexWriteralways passes.Why a local lock. I checked the dependency tree first.
async-lockis a keyed mutex: exclusive per key, so imports into one collection could not overlap. Readers-writer locks such as@esfx/async-readerwriterlockhave one shared group and one exclusive one. They fit a component of two collections only by making one of them exclusive with itself, and LOL’s component has three. Nothing I found gives concurrency within a group and exclusion between any number of groups, soGroupLockis about 50 local lines with unit tests.Test. The joins end-to-end test now runs the indexer once, on 900 datasets, 900 works and 50 publishers with a batch size of 600. That makes datasets land before their publishers exist and the flush land all three collections at once. A proxied client checks after every import into a referenced collection, before the lock lets the next import start, that every referrer pointing at the just-imported documents already joins to them. That confirms Typesense finishes back-filling before the import call returns. With the lock disabled, the test failed 5 runs out of 5 (“publishers: 600 of 902 datasets joined”). With the lock, it passed 6 out of 6.
Docs. The “run the indexer twice” warning is gone from
search-typesense.mdandsearch.md. New ADR 39, “Serialise imports across a join component’s collections”, amends ADR 19’s limitation. The duplicate ADR 31 (local files through the data dump path) is now 38, with its three links updated. The issue asked for 35 and 34, but both had been taken since (34–37 exist on main), so I used the next free numbers.Still open: a Linked Open Limburg run timed before and after this change.
Part of #1023