Skip to content

datastore/postgres: fix iterator exhaustion in alias insertion#89

Open
jvdm wants to merge 1 commit into
crozzy:faster-alias-insertfrom
jvdm:fix-faster-alias-insert
Open

datastore/postgres: fix iterator exhaustion in alias insertion#89
jvdm wants to merge 1 commit into
crozzy:faster-alias-insertfrom
jvdm:fix-faster-alias-insert

Conversation

@jvdm

@jvdm jvdm commented Jul 2, 2026

Copy link
Copy Markdown

This fixes a bug in the faster-alias-insert branch where insertAliases consumes the single-pass vulnIter (backed by jsonblob.RecordIter) before the main vulnerability insertion loop runs, resulting in zero vuln rows being inserted.

The fix removes the separate insertAliases pre-pass and instead collects alias namespaces and aliases during the main vulnIter loop, then bulk-inserts them via a separate connection (outside the transaction) after the loop — preserving the deadlock-avoidance property.

Also adds a test using a sync.Once-guarded single-pass iterator that reproduces the bug.

See test results on quay#1934.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant