Repository navigation
Conversation
…ements and reserved code spaces: where OCL stores them Four additive migrations, and the model fields and index they create. Nothing reads or writes them yet: they are used by OpenConceptLab/ocl_issues#3092 and OpenConceptLab/ocl_issues#3093, which come later in the series, under FHIR's rules only. - sources/0053: source_supplements_base, a partial index on the code system a supplement names (its supplements URL without the |version), over supplement sources only, so a code system's supplements are found by its canonical URL - sources/0054: Source.reserved_code_spaces, the code spaces a code system reserves for its users to define codes in ([{pattern, display}], FHIR's codesystem-reservedCodeSpace), copied to new versions - collections/0079: Collection.declared_supplements, the supplements a collection version declares (FHIR's valueset-supplement), copied to new versions; Expansion.supplements_used, what an expansion built under FHIR's rules applied - collections/0080: Expansion.reserved_codes, the codes in reserved code spaces an expansion built under FHIR's rules holds that no concept defines Each column is nullable with a constant default, recorded in the catalog without rewriting the table. None is in the API's serializers. Tests: the migrations reverse and apply again, the index is used, and the copies and defaults. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWapJWFsFc1Xjopf9k
…torage migrations bound their lock waits Each of the four migrations first sets lock_timeout (5s) in its own transaction, both ways. Behind a long transaction on a table it alters (a long expansion build on collection_expansions, say), a migration now fails in seconds and changes nothing, where it would have held its locks, and every query queued behind them (collections reads among them), until that transaction ended. It can be run again once that transaction is over. Test: each migration bounds its lock waits first, applying and reversing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWapJWFsFc1Xjopf9k
…torage migrations bound their lock waits before their first DDL, both ways A migration reversed runs its operations last first, so a timeout set by the first operation's reverse came after the DDL it should bound. Each migration now sets lock_timeout in a forward-only first operation and a reverse-only last one, so both directions set it before any DDL. Test: the first operation sets it applying, the last one reversing, and no other operation is SQL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWapJWFsFc1Xjopf9k
…o fhir-452-c-storage Takes #1090's new head, which brings in master (#1089, #1109 and #1106): REFERENCE_SEARCH_OPTIONS_TOGGLE is on in every environment, as on master. Merged cleanly; no change to this branch's own code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVQviVc1p6MQwqUUed
…nto fhir-452-b-imports Takes #1103's new head, which brings in master (#1089, #1109 and #1106): REFERENCE_SEARCH_OPTIONS_TOGGLE is on in every environment, as on master. The one conflict is the constants import in core/collections/models.py, where both sides add names: all are kept. No change to this branch's own code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVQviVc1p6MQwqUUed
snyaggarwal
left a comment
There was a problem hiding this comment.
Verdict: ready, but not mergeable yet. It's stacked on #1090, which needs one migration fix. Once #1090 merges and this PR is retargeted to master with CI green, it can merge as is.
Merge order: #1087, then #1090, then this PR right after #1090 (as the description asks), then #1091 and the rest.
I reviewed only this PR's own diff against fhir-452-b-apart.
- Migrations:
lock_timeoutis set before the first DDL, applying and reversing.- The new columns are nullable with constant defaults, which PostgreSQL 11 and later add in the catalog only.
- The partial index on
sources(about 4,000 rows, with no supplements today) blocks writes there only briefly. - Each migration reverses, and the tests apply and reverse all four.
- API writes:
fields = '__all__'puts the new fields in the create serializers, butprepare_objectcopies only the attributes it lists, so the API can't write them. The schema and CSV exposure was already accepted in the Codex pass. - Migration numbers:
collections0079/0080 andsources0053/0054 assume nothing else adds a migration to those apps before the stack lands. Runmakemigrations --checkafter the last master merge before merging.
Nothing in this PR crosses into commercial logic.
… PostgreSQL's deadlock check Each lock wait is bounded at 0.3 s instead of 5 s, applied and reversed. 0079 locks collections and then collection_expansions: with 5 s, PostgreSQL could cancel a transaction that had read the second and then read the first. Its two waits now end before that check, so it's the migration that gives up. Reads of a table that 0054, 0079 or 0080 waits for are held up for well under a second, not for 5. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVQviVc1p6MQwqUUed
|
One commit since the review, 87ba778: the four migrations now wait 0.3 s for each lock, not 5 s. While I fixed the migration of #1090, a 5 s bound turned out to have a fault of its own, and this PR's migrations had it too.
The schema is the same, and nothing else in the PR changes. The description says 0.3 s now. |
snyaggarwal
left a comment
There was a problem hiding this comment.
Verdict unchanged: ready, waiting only on #1090.
87ba778 lowers the lock wait of all four migrations from 5 s to 0.3 s, applied and reversed, and the test follows. Nothing else changes. That matches 0078 on #1090 and 0052 on #1087. 0079 waits for two tables, so it can hold reads up for 0.6 s at most, still under deadlock_timeout. CI is green at 87ba778.
Merge order: right after #1090. After you retarget to master, merge master in, then run makemigrations --check and CI before merging.
…nto fhir-452-b-imports Takes #1103's new head. Merged cleanly; no change to this branch's own code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVQviVc1p6MQwqUUed
…nto fhir-452-b-imports Takes #1103's new head. Merged cleanly; no change to this branch's own code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVQviVc1p6MQwqUUed
…nto fhir-452-b-imports Takes #1103's new head. Merged cleanly; no change to this branch's own code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVQviVc1p6MQwqUUed
Branch
fhir-452-c-storage, basefhir-452-b-apart(#1090). The storage of code system supplements (OpenConceptLab/ocl_issues#3092) and reserved code spaces (OpenConceptLab/ocl_issues#3093), for OpenConceptLab/ocl_online#452.Merge it right after #1090, so every migration of the FHIR work reaches staging early. #1091 merges this branch, so the migration graph stays linear.
Size
Three commits, 9 files, +293/−1: 170 lines of code and migrations, 123 of tests.
7336bac3adds the storage;a53b7ff3anda744936bbound the migrations' lock waits (from review).What it adds
Four additive migrations, and the model fields and index they create. Nothing reads or writes them yet. They're used by OpenConceptLab/ocl_issues#3092 and OpenConceptLab/ocl_issues#3093 later in the series (#1104 in OCL's model, #1105 in the FHIR layer), under FHIR's rules only. The API never reads or writes them: as every model field, they show in the create serializers' schema (
fields = '__all__') and in CSV exports (values()), as empty lists.sources/0053_source_supplements_basesource_supplements_baseonsplit_part(supplements, '|', 1), over supplement sources onlysources/0054_source_reserved_code_spacesSource.reserved_code_spaces, as[{pattern, display}]codesystem-reservedCodeSpace)collections/0079_supplementsCollection.declared_supplements,Expansion.supplements_usedvalueset-supplement), and what an expansion built under FHIR's rules appliedcollections/0080_expansion_reserved_codesExpansion.reserved_codesNew source and collection versions copy their HEAD's reserved code spaces and declared supplements.
Each migration sets
lock_timeout(0.3 s) before its first DDL, applying and reversing: behind a long transaction on a table it alters (an expansion build oncollection_expansions, say), it fails within a second and changes nothing, instead of holding its locks and every query queued behind them. Run it again once that transaction is over. The waits of one migration together stay below PostgreSQL'sdeadlock_timeout(1 s), so if it and another transaction wait for each other, it's the migration that gives up.Production
Read-only counts, Dec 1: 3,962 sources (0 supplements), about 25,800 collections and 26,000 expansions. Each new column is nullable with a constant default, which PostgreSQL records in the catalog without rewriting the table. The index holds supplement rows only (none today), and
CREATE INDEXreads the smallsourcestable once.Reading order
core/sources/models.py(supplements_base, the index,reserved_code_spaces), thencore/collections/models.py.core/sources/tests/tests_supplement_storage.py(the migrations reverse and apply again; the index is used), thentests_supplements.pyandtests_reserved_codes.py(copies and defaults; both grow in the core PR).Tests
a744936b, aspr.ymlruns it: pylint 10.00; 4,376 tests OK (2 skipped) and 804 search-index tests OK; coverage 97%.makemigrations --check: no changes forsourcesandcollections.Review
Three Codex defect passes and a simplification review.
a53b7ff3).a744936b). Accepted: the create serializers (fields = '__all__') and the CSV exports (values()) show every model column, these as they do others; nothing reads them.Rollback
manage.py migrate sources 0052andmanage.py migrate collections 0078(after rolling back anything that merged on top), then revert this PR. Nothing reads the columns or the index.🤖 Generated with Claude Code
https://claude.ai/code/session_01AaZ4qWapJWFsFc1Xjopf9k