Skip to content

fix: stream ndjson imports, remove per-line size limit - #342

Open
robc-vulncheck wants to merge 1 commit into
mainfrom
fix/stream-ndjson-import
Open

robc-vulncheck wants to merge 1 commit into
mainfrom
fix/stream-ndjson-import

Conversation

@robc-vulncheck

Copy link
Copy Markdown
Collaborator

What

Replaces the bufio.Scanner with bufio.Reader.ReadBytes and flushes batches. No record size can now truncate or fail an index import.

Why?

The scanner was capped at 4MB and osv's largest record is ~19MB. ReadBytes grows to fit the record, so there is no ceiling to raise again.

Notes/Testing

Inserts into the DB are still controlled. There is a 25MB flush size and a max document size of 1GB (these are existing limits and unchanged). Tested locally by syncing ~30GB of data to offline db.

Blank lines are now skipped rather than raising errors.

Adds three cases to import_test.go
go test ./... green, vet and gofmt clean

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