Repository navigation
feat(spiraldb): writable SpiralDB database, stage D: public writable keyword, writer lease in runs, every table kind (ITL-1844) #693
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
eywalker
merged 76 commits into
main
from
eywalker/itl-1844-spiraldb-store-stage-d-public-switch-on
Dec 3, 2026
Merged
Changes from all commits
Commits
Show all changes
76 commits
Select commit
Hold shift + click to select a range
38fd064
build(deps): pin spiral-sdk 0.16.78, which reads and writes table met…
eywalker eb19792
feat(spiraldb): add generation-table writer leases (ITL-1838)
eywalker 60bf0af
test(spiraldb): type the fake client boundary
eywalker 10ac3d0
feat(spiraldb): store table identity record and codec, provisional an…
eywalker 76ac9fe
fix(spiraldb): type leases without the optional SDK
eywalker faa21c3
fix(spiraldb): reserve numbered lease generations consistently
eywalker 2745f9a
fix(spiraldb): preserve tables with colliding lease names
eywalker cdfa2e6
fix(spiraldb): keep plain-field extension metadata; one store path do…
eywalker 384426d
feat(spiraldb): internal store mode under ConnectorArrowDatabase (ITL…
eywalker 5574a4c
Merge remote-tracking branch 'origin/eywalker/itl-1837-spiraldb-store…
eywalker 36ba2a9
refactor(spiraldb): store mode uses the shared store path domain; sta…
eywalker 216f198
docs(spiraldb): the store path rule is SpiralDB's component syntax; p…
eywalker 2f10d99
Merge remote-tracking branch 'origin/eywalker/itl-1837-spiraldb-store…
eywalker c8e15d0
fix(spiraldb): store mode review round 1: order-free key check, name …
eywalker ba14378
fix(spiraldb): store mode review round 2: one identifier-preserving d…
eywalker d3ed38e
fix: recover writer lease claims and skip reserved names
eywalker 1e2964c
fix(spiraldb): keep the flush key read until the lease; schema test s…
eywalker a02aeaa
fix: reconcile interrupted lease creation and align migration listings
eywalker 215b9ce
Test lease name recognition parity
eywalker 6fb1b6e
fix(spiraldb): open the table afresh at every write; run the schema c…
eywalker ed788d9
fix(spiraldb): refuse stored values the codec cannot restore; record …
eywalker 1e35702
Merge remote-tracking branch 'origin/main' into eywalker/itl-1837-spi…
eywalker 8334616
Merge remote-tracking branch 'origin/main' into eywalker/itl-1838-spi…
eywalker 66aaa87
Merge remote-tracking branch 'origin/eywalker/itl-1837-spiraldb-store…
eywalker 06eac39
Merge remote-tracking branch 'origin/eywalker/itl-1838-spiraldb-store…
eywalker acc6007
feat(spiraldb): public store keyword; job runs hold the dataset's wri…
eywalker ad9a91c
docs(spiraldb): the SpiralDB store page, changelog fragment and end-t…
eywalker fb61329
fix(spiraldb): store mode review round 3: per-operation judgments, ad…
eywalker 406c806
fix(pipeline): issue the run-completion warnings from run() and run_a…
eywalker 537d66f
build(deps): pin spiral-sdk 0.16.80; ignore its keyed-table deprecati…
eywalker 4a8947a
Merge branch 'eywalker/itl-1837-spiraldb-store-stage-a-on-current-mai…
eywalker 57f1b66
fix(spiraldb): open and create every store table through the connecto…
eywalker 1e9b900
fix(spiraldb): keep the keyed-table deprecation filter first; route t…
eywalker bba26c1
Merge #691 head 1e9b9009a into stage B (ITL-1840)
eywalker 363bf0c
Merge #692's head bba26c12f into stage D (ITL-1844)
eywalker b761f72
Merge origin/main (#691 squashed as ea0138de7) into stage B (ITL-1840)
eywalker 123d900
Merge origin/main into the stage C lease branch
eywalker 7cf03b1
fix(spiraldb): the evaluation script lists its tables per job name an…
eywalker 06020f7
Merge remote-tracking branch 'origin/main' into eywalker/itl-1844-spi…
eywalker d263e6e
Merge commit 'b761f7227' into eywalker/itl-1844-spiraldb-store-stage-…
eywalker b15af75
Merge #690's head 123d9009a into stage D; one set of connector helper…
eywalker 19e49f3
fix(spiraldb): list a table of another store format as a marked path,…
eywalker 8c10bd5
fix(spiraldb_lease): keep acquisition errors and wrap failed reopens
eywalker 29abfe8
fix(databases): a stored table a lookup cannot read fails the run; li…
eywalker 33afff0
fix(spiraldb): review round 1 for the store switch-on (ITL-1844)
eywalker 2bbaa67
Merge commit '8c10bd571' into eywalker/itl-1844-spiraldb-store-stage-…
eywalker b0484ab
Merge commit '29abfe869' into eywalker/itl-1844-spiraldb-store-stage-…
eywalker 26a0faa
test(spiraldb): stage B's read-failure test lets the job take its lea…
eywalker 291798d
perf(spiraldb): a run walks for store leases only when a store connec…
eywalker edc3071
fix(spiraldb): finding a stored table is a read; a changed identity r…
eywalker dc4accf
fix(spiraldb_lease): clear only the newest generation; dry run refuse…
eywalker 0a71291
fix(spiraldb): review of 291798da3 for the store switch-on (ITL-1844)
eywalker 8a4bab6
Merge commit 'edc30710d' into eywalker/itl-1844-spiraldb-store-stage-…
eywalker 686421e
Merge commit 'dc4accfe8' into eywalker/itl-1844-spiraldb-store-stage-…
eywalker 9bdd523
docs(spiraldb): clear() names the project and dataset of the lease (I…
eywalker f8399f7
docs(changelog): limit the ITL-1838 known limitation to tables with a…
eywalker e1581af
fix(spiraldb): a shared copy has its own store tables; a let-go is co…
eywalker c232f82
Merge commit 'f8399f75b' into eywalker/itl-1844-spiraldb-store-stage-…
eywalker c688296
test(spiraldb): a shared copy holds the test's lease on its own store…
eywalker fcf67d5
fix(spiraldb_lease): guard token verification; name both clear prereq…
eywalker d3c64b4
Merge commit 'fcf67d5ee' into eywalker/itl-1844-spiraldb-store-stage-…
eywalker 5514407
fix(spiraldb_lease): reconcile every exit of a claim before it is ret…
eywalker 2919e62
Merge commit '551440700' into eywalker/itl-1844-spiraldb-store-stage-…
eywalker c318d2c
Merge origin/main (store stage B, #692; #694) into the stage C lease …
eywalker 387156f
docs(spiraldb_lease): say which acquire errors propagate; name both c…
eywalker 36b62a2
fix(spiraldb): a lease attached before an interruption is let go of; …
eywalker e76958c
Merge remote-tracking branch 'origin/main' into eywalker/itl-1844-spi…
eywalker 84ce60a
Merge commit '387156f50' into eywalker/itl-1844-spiraldb-store-stage-…
eywalker 6febee7
fix(spiraldb): a lease claim is recorded inside its acquisition; one …
eywalker 6ff94d7
test(spiraldb_lease): check that acquire released the claim before a …
eywalker c788f9c
Merge remote-tracking branch 'origin/main' into eywalker/itl-1844-spi…
eywalker de39bbc
refactor(spiraldb)!: rename the SpiralDB store to the writable Spiral…
eywalker 047dbe2
fix(spiraldb): review of de39bbc4c: lease refusal keeps the save stat…
eywalker 637fc85
fix(spiraldb): delta review of 047dbe290: earlier key is another form…
eywalker 55f7c71
fix(spiraldb): delta review 2 of 637fc8551: non-bool writable message…
eywalker 90ae28d
Merge remote-tracking branch 'origin/main' into eywalker/itl-1844-spi…
eywalker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,6 @@ | ||
| ### Known limitations | ||
|
|
||
| - Orcapod still cannot use SpiralDB as a job's database: a `SpiralDBConnector` refuses | ||
| every write. An internal store mode now writes and reads every stored table kind | ||
| through `ConnectorArrowDatabase` (one table per path, its identity and manifest in the | ||
| table's metadata), but nothing opens it publicly, it is not saved with a job, and its | ||
| format stays provisional, outside the 0.4.0 freeze. (ITL-1840) | ||
| - A writable SpiralDB database (`SpiralDBConnector(..., writable=True)`, ITL-1844) keeps every stored | ||
| table kind through `ConnectorArrowDatabase`: one table per path, its identity and | ||
| manifest in the table's metadata. Its format is provisional, outside the 0.4.0 freeze. | ||
| (ITL-1840) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| ### Added | ||
|
|
||
| - A SpiralDB dataset can be a job's database: a writable SpiralDB database, | ||
| `SpiralDBConnector(project_id, dataset, writable=True)` under `ConnectorArrowDatabase`, stores every table a job writes (function results and | ||
| pipeline records, operator caches, cached sources, side-effect logs), also as a separate | ||
| result database. Provisional in 0.4.0: the database's table format and its writer lease may | ||
| change in a later version, which may not read tables written now. Nothing of the | ||
| database enters a hash. See "SpiralDB as a Job's Database" in the concepts. | ||
| - One writer per writable SpiralDB database: `job.run()`, `job.run_async()` and a job node's `run()` | ||
| take the dataset's writer lease before checking a source or writing anything, and release | ||
| it when they end, also when they fail. A second writer is refused then with | ||
| `LeaseBusyError`, before anything of its run happens. A stale lease is cleared by its | ||
| project, dataset and table id with | ||
| `spiraldb_lease.clear(client, project_id, dataset, table_id, confirm_writer_stopped=True)`. | ||
| - A job saved on a writable SpiralDB database records `writable: true` and no credential; `PipelineJob.load` | ||
| takes the connector again and refuses a SpiralDB connector of the other kind. | ||
|
|
||
| ### Known limitations | ||
|
|
||
| - Only a job run writes a writable SpiralDB database, through the writable connectors it | ||
| holds the lease with: a write through any other writable connector (a cached source read outside a run, a | ||
| `ConnectorArrowDatabase` over a connector of its own flushed directly) raises | ||
| `SpiralDBLeaseRequiredError`, also while a run holds the lease. A write through a | ||
| running job's own databases from outside the run is not told apart from the run's own. | ||
| A way to hold the lease outside a run is later work (ITL-1849). | ||
| - The writer lease is refuse-only: no waiting, no takeover, no expiry. Each run leaves one | ||
| small lease table in the dataset, which is kept. | ||
| - A writable SpiralDB database reads a table's whole key column to tell which rows it holds, and whole tables | ||
| to read stored rows, so a run's cost grows with the tables' history. | ||
| - The database does not take over tables it did not write, and status and logging observers | ||
| still refuse a SpiralDB database. |
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,147 @@ | ||
| # SpiralDB as a Job's Database | ||
|
|
||
| A job can keep everything it stores in a SpiralDB dataset: function results, pipeline | ||
| records, operator caches, cached sources and side-effect logs. Open the dataset as a | ||
| **writable SpiralDB database** and give it to the job as any other database. | ||
|
|
||
| !!! warning "Provisional in 0.4.0" | ||
| The writable SpiralDB database is provisional. The format of its tables (how a table is named, | ||
| what its metadata records, how values are encoded) and its writer lease may change in | ||
| a later version, and a later version may not read tables written now. Nothing of the | ||
| database enters a hash: a job's hashes, ids and stored paths are the same on SpiralDB as | ||
| on Delta. | ||
|
|
||
| ## Opening the SpiralDB database | ||
|
|
||
| `SpiralDBConnector(project_id, dataset, writable=True)` opens one dataset as a writable | ||
| SpiralDB database. Wrap it in `ConnectorArrowDatabase` and use it as the job's database, its separate result | ||
| database, or a cached source's database: | ||
|
|
||
| <!-- docs-test: skip --> | ||
| ```python | ||
| from orcapod import PipelineJob | ||
| from orcapod.databases import ConnectorArrowDatabase, SpiralDBConnector | ||
|
|
||
| database = ConnectorArrowDatabase( | ||
| SpiralDBConnector("my-project-123456", "pipeline_results", writable=True) | ||
| ) | ||
| job = PipelineJob(name="experiment", database=database) | ||
| ``` | ||
|
|
||
| Signing in is spiral-sdk's: the `SPIRAL_*` environment variables, or a saved | ||
| `spiral login`. Without `writable=True`, a `SpiralDBConnector` reads existing keyed tables | ||
| (a `SpiralDBTableSource`) and writes nothing. | ||
|
|
||
| Each stored table is one keyed table of the dataset, named from its path (a readable | ||
| part of the path and a digest of all of it). Its metadata records the full path, the | ||
| layout, the data context and the columns, so a table under that name that another | ||
| writer made for something else is refused, never written over. The database reads | ||
| and writes only the tables it made: it does not take over a table it did not write. | ||
|
|
||
| ## One writer at a time | ||
|
|
||
| The SpiralDB database has one writer at a time. Every run of a job (`job.run()`, `job.run_async()`, | ||
| a job node's `run()`, and a load-only run that reads a cached source) takes the | ||
| dataset's **writer lease** before it checks a source, computes or writes anything, and | ||
| releases it when it ends, also when it fails. A run whose database and result database | ||
| are on one dataset takes one lease. | ||
|
|
||
| While one run holds the lease, a second writer, in this process or another, is refused | ||
| when its run starts, with `LeaseBusyError`. Nothing of its run has happened then: no | ||
| source was checked, nothing computed, no data table made. (A run that writes | ||
| several datasets takes their leases one after another, so a dataset whose lease it took | ||
| before the refusal may hold a new lease table, released.) The error names the lease's table | ||
| id and who holds it. The lease is refuse-only: the second writer does not wait and never | ||
| takes the lease over, and a lease does not expire. | ||
|
|
||
| <!-- docs-test: skip --> | ||
| ```python | ||
| from orcapod.databases.spiraldb_lease import LeaseBusyError | ||
|
|
||
| try: | ||
| job.run() | ||
| except LeaseBusyError as refused: | ||
| print(refused) | ||
| # SpiralDB dataset 'pipeline_results' has a conflicting writer lease (owner ..., table ID ...). ... | ||
| ``` | ||
|
|
||
| Only a job run writes the SpiralDB database, through the writable connectors it holds the | ||
| lease with (those of its databases and of the cached sources it reads). A write through | ||
| any other writable connector (a cached source read outside a run, a `ConnectorArrowDatabase` over a | ||
| connector of its own or over a `share_client()` copy, flushed directly) raises `SpiralDBLeaseRequiredError` before | ||
| anything is written, also while a run holds the dataset's lease. A write through a | ||
| running job's own databases from outside the run (another thread, an observer) is not | ||
| told apart from the run's own: do not write through them while the job runs. A | ||
| load-only run of a job writes no node's table, so it takes a lease only for a cached | ||
| source it reads. A run takes one lease per dataset of one service: writable connectors | ||
| whose client reaches the same service share it, whether their address was left to the | ||
| default or given (`overrides={"server.url": ...}`). | ||
|
|
||
| ### A lease left behind | ||
|
|
||
| A process that stops in the middle of a run (killed, or a lost connection) leaves its | ||
| lease held, and every later run is refused. Once you are sure that writer has stopped, | ||
| and every write it sent has settled, clear the lease by the project, dataset and table | ||
| id the refusal named (its message spells out the call): | ||
|
|
||
| <!-- docs-test: skip --> | ||
| ```python | ||
| import spiral | ||
|
|
||
| from orcapod.databases import spiraldb_lease | ||
|
|
||
| spiraldb_lease.clear( | ||
| spiral.Client(), | ||
| "<project>", | ||
| "<dataset>", | ||
| "<table id from the refusal>", | ||
| confirm_writer_stopped=True, | ||
| ) | ||
| ``` | ||
|
|
||
| `spiral.Client()` connects to the default service. When the job's connector was made | ||
| for another service address (`SpiralDBConnector(..., overrides={"server.url": ...})`), | ||
| make the client for that same address, with a sign-in allowed to update the dataset: | ||
| a client of another service does not find the table id. Only the dataset's newest lease | ||
| table can be cleared: any other table id is refused and nothing is written. | ||
|
|
||
| Clearing the lease of a writer that is still running lets a second writer in while the | ||
| first is still writing. Each lease is a small keyed table of the dataset; keep every | ||
| one, also released ones: removing one by hand can let two writers in. | ||
|
|
||
| ## Saving and loading a job | ||
|
|
||
| A job saved on the SpiralDB database records the connector (`connector_type`, project, | ||
| dataset, the service address and `writable: true`), never a credential. A connector is not rebuilt from | ||
| a saved file: give it again when loading, as for every connector database: | ||
|
|
||
| <!-- docs-test: skip --> | ||
| ```python | ||
| loaded = PipelineJob.load( | ||
| "experiment.json", | ||
| database=ConnectorArrowDatabase( | ||
| SpiralDBConnector("my-project-123456", "pipeline_results", writable=True) | ||
| ), | ||
| ) | ||
| ``` | ||
|
|
||
| A job saved on the SpiralDB database is loaded with a writable connector, and one saved | ||
| on a plain | ||
| `SpiralDBConnector` with a plain one: the load refuses the other kind, since the two | ||
| read different tables. | ||
|
|
||
| ## Limits | ||
|
|
||
| - Each check of which rows a table holds reads the table's whole key column, and each | ||
| read of stored rows reads the whole table, so the cost of a run grows with the | ||
| table's history. | ||
| - Only a job run writes the SpiralDB database: a cached source over it is read within a | ||
| run. A | ||
| way to hold the lease outside a run is planned (ITL-1849). | ||
| - Status and logging observers do not write to SpiralDB: they raise | ||
| `SpiralDBObserverNotSupportedError` at setup; give them another database such as | ||
| Delta. | ||
| - The database does not take over tables it did not write. | ||
| - A column the database cannot keep (a null struct, a duration, a nested logical type) is | ||
| refused before anything of its table is written, naming the column. The other databases are compared type by type in | ||
| [Data types per database](../reference/database-types.md). | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.