Skip to content

fix: deduplicate PostgreSQL latest-file upserts - #104

Merged
digizeph merged 1 commit into
mainfrom
fix/postgres-latest-upsert-deduplication
Aug 12, 2026
Merged

digizeph merged 1 commit into
mainfrom
fix/postgres-latest-upsert-deduplication

Conversation

@digizeph

Copy link
Copy Markdown
Member

Summary

  • retain only the newest item per PostgreSQL (collector_id, data_type) latest-file key before issuing the batched upsert
  • prevent PostgreSQL from rejecting crawler batches that contain multiple observations for the same latest-file key

Failure mode

The PostgreSQL backend used one INSERT ... ON CONFLICT DO UPDATE statement for each 1,000-item batch. A crawl can contain multiple rows with the same (collector_id, data_type), and PostgreSQL rejects an upsert that would update its target row twice in one statement.

Validation

  • cargo build --verbose
  • cargo build --features cli --verbose
  • cargo test --no-default-features --verbose
  • cargo clippy --all-features -- -D warnings
  • live Terrier PostgreSQL-backed Broker updater: initial crawl completed with 8,995 inserts; API health returned OK

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Deduplicates PostgreSQL latest-file upserts to prevent conflicting updates within a batch.

Changes:

  • Groups latest files by collector and data type.
  • Retains only the newest observation before batched upserts.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/db/postgres.rs
@digizeph
digizeph merged commit 0d21c01 into main Aug 12, 2026
2 checks passed
@digizeph
digizeph deleted the fix/postgres-latest-upsert-deduplication branch August 12, 2026 16:56
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.

2 participants