You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import_bank_async resolves the target bank's config before the archive's bank row is restored, so entity_labels is always empty for the whole import and every label entity is stored with entity_kind='regular'.
The bank cannot exist at that point: import_bank explicitly refuses to write into an existing bank ("import-bank restores into a fresh bank (it is not a merge)"). So the resolve can only ever see global + tenant config — the bank's own entity_labels, which the archive carries in banks.json, arrives later, when import_bank restores the bank row and then replays the documents through retain Phase 1 with the stale config object.
This contradicts what #3214 assumed: "Bank import needs no changes: transfer archives treat entities as derived data and re-resolve them through the standard retain Phase 1, which now stamps the kind." Phase 1 does stamp the kind — but from getattr(config, "entity_labels", None), which is empty here.
5,374 of those entities are label-shaped, and the only 500 marked label were created by a post-import ingest burst, not by the import. Applying the same classification the migration backfill uses (is_label_entity against the bank's config) marks 5,355 rows as labels.
Measured cost on that bank (identical population, both sides REINDEXed, all other banks dropped so the shared trigram index is not polluted):
as imported
after correcting the kinds
entity-resolution p50 (25 names)
263 ms
37 ms
single fuzzy probe (EXPLAIN ANALYZE)
8.28 ms
0.38 ms
candidates pulled → kept
1,830 → 128
252 → 56
So the defect forfeits roughly 7× of the win #3214 delivers, on the exact bank the feature was built for.
Fix
Re-resolve the config after the bank row is restored, and replay documents with that. import_bank takes a resolve_config callback that import_bank_async supplies; the pre-restore config stays as the value used for everything up to the restore.
Regression test: test_bank_import_classifies_label_entities — configure entity_labels, export, delete, import, assert the label entity comes back as entity_kind='label' and a regular one as 'regular'. It fails on main with 'regular' != 'label'.
Problem
import_bank_asyncresolves the target bank's config before the archive's bank row is restored, soentity_labelsis always empty for the whole import and every label entity is stored withentity_kind='regular'.The bank cannot exist at that point:
import_bankexplicitly refuses to write into an existing bank ("import-bank restores into a fresh bank (it is not a merge)"). So the resolve can only ever see global + tenant config — the bank's ownentity_labels, which the archive carries inbanks.json, arrives later, whenimport_bankrestores the bank row and then replays the documents through retain Phase 1 with the stale config object.This contradicts what #3214 assumed: "Bank import needs no changes: transfer archives treat entities as derived data and re-resolve them through the standard retain Phase 1, which now stamps the kind." Phase 1 does stamp the kind — but from
getattr(config, "entity_labels", None), which is empty here.Impact
entity_kind='regular', so the partial trigram index... WHERE entity_kind != 'label'excludes nothing and every fuzzy probe pays the recheck-discard cost the fix was meant to remove.Evidence
Importing a real 862-document / 38k-fact production export (bank has a free-text
brief_biolabel group) into a fresh instance onmain@ f9fb3e9:5,374 of those entities are label-shaped, and the only 500 marked
labelwere created by a post-import ingest burst, not by the import. Applying the same classification the migration backfill uses (is_label_entityagainst the bank's config) marks 5,355 rows as labels.Measured cost on that bank (identical population, both sides REINDEXed, all other banks dropped so the shared trigram index is not polluted):
EXPLAIN ANALYZE)So the defect forfeits roughly 7× of the win #3214 delivers, on the exact bank the feature was built for.
Fix
Re-resolve the config after the bank row is restored, and replay documents with that.
import_banktakes aresolve_configcallback thatimport_bank_asyncsupplies; the pre-restore config stays as the value used for everything up to the restore.Regression test:
test_bank_import_classifies_label_entities— configureentity_labels, export, delete, import, assert the label entity comes back asentity_kind='label'and a regular one as'regular'. It fails onmainwith'regular' != 'label'.