Commit d0084de
committed
fix: recover from ontoenv's stale interrupted-mutation marker
A persistent ontology cache could be opened exactly once. The second open
raised CatalogRecoveryError and there is no way back: ontoenv exposes no
recovery API, so the cache was permanently unusable.
Root cause, traced by wrapping each OntoEnv method and watching the marker
file: ontoenv writes .ontoenv/catalog.pending when a batched mutation begins
and removes it only when the batch finishes cleanly (BatchScope::run in
lib/src/api.rs; its Drop impl does not remove it either). An unresolvable
owl:imports makes the batch end in error, so the marker survives.
That is the normal case here, not an edge case. Loading Brick calls
import_dependencies, which raises ValueError("Failed to resolve graph for URI")
for each of eight imports Brick declares and that do not resolve offline --
brickschema 1.3, qudt unit and quantitykind, ashrae bacnet/2020, Brick/ref,
rec/brickpatches, rec/recimports, datashapes dash. Several 404 even online.
BuildingMOTIF tolerates missing imports and swallows those errors, so the load
"succeeds" while the catalog is left marked. An ontology declaring no imports
leaves no marker, which is how this was isolated.
So `connect` now clears a marker it finds and retries once, with a warning
naming the file. This is a workaround for an upstream defect and is marked as
such: it trades away the marker's value after a genuine crash mid-write, which
is the reason it warns rather than doing it silently, and only retries once.
Verified: load Brick into a persistent cache, close, reopen (warns, succeeds,
ontology intact), close, open a third time cleanly.
The principled fix belongs upstream -- a tolerable non-strict import failure
should not leave an interrupted-mutation marker, since non-strict mode is
documented as best-effort. Failing that, ontoenv should expose a recovery call
so consumers do not have to delete files it owns.1 parent 390c0c2 commit d0084de
1 file changed
Lines changed: 46 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
5 | | - | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
57 | 58 | | |
58 | 59 | | |
59 | 60 | | |
60 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
61 | 105 | | |
62 | 106 | | |
63 | 107 | | |
| |||
0 commit comments