fix(infra): handle database deduplication unique constraints in db buffer

- Intercepts psycopg2 UniqueViolation exceptions on the ene_pkg_hash_idx
  unique index constraint.
- Logs duplicate content violations as successful deduplication skips
  instead of triggering transaction retries and fallback logging.

Build: 0 jobs, 0 errors (lake build)
This commit is contained in:
allaun 2026-06-18 23:35:03 -05:00
parent e6bbb612d0
commit 50322c88f9

View file

@ -259,6 +259,10 @@ class AsyncDatabaseBuffer:
self.conn.commit()
except Exception as e:
self.conn.rollback()
# Catch duplicate content hash violations and skip them cleanly as successful dedups
if e.__class__.__name__ == "UniqueViolation" and "ene_pkg_hash_idx" in str(e):
log.info("Deduplication filter triggered: record with identical content_hash already exists. Skipping.")
return
raise e
finally:
cur.close()