Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Complete PostgreSQL Concurrent Upsert Support for All Primary Key Types

Abierto
#3,796 0 comentarios 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@aaronburtle ya está trabajando en esto.

Desde el 1/9/2026.

Evaluación

Este issue todavía no se ha evaluado.

Descripción

pgsql

Extend PostgreSQL concurrent PUT/PATCH upsert handling to cover every primary-key type supported by DAB, including composite keys and values with multiple database-equivalent representations. Ensure requests targeting the same logical key acquire the same transaction-scoped lock, use PostgreSQL-native comparison semantics, and complete without duplicate-key conflicts or lost updates. Add focused unit and PostgreSQL integration coverage for the supported type matrix, verifying that one concurrent request inserts while subsequent requests update successfully.

PostgreSQL normally protects existing rows with row-level locks. That is insufficient for an upsert race because, when two requests check for a missing key, there is no row to lock. Both requests can conclude that an insert is required, and one then fails against the unique constraint.

DAB uses transaction-scoped PostgreSQL advisory locks to serialize that sequence:

Derive a deterministic lock identity from the entity and primary key.
Acquire pg_advisory_xact_lock(...).
Recheck whether the row exists.
Insert or update as appropriate.
Release the lock automatically when the transaction commits or rolls back.
Requests for the same logical key must derive the same advisory lock, while requests for different keys should ideally continue concurrently.

The complication is that PostgreSQL equality is type-specific. Different request values can represent the same database key, for example:

character(n) values that differ only by trailing spaces
Numerically equivalent representations such as 1, 1.0, or 1.00
UUIDs with different casing or formatting
Timestamps representing the same instant with different offsets
Composite keys containing any combination of these types
If DAB hashes the raw request text, two database-equal values may acquire different locks. They can then race despite advisory locking. Parameter typing also matters: sending a fixed-width character key as PostgreSQL text can cause an existence predicate to use text equality instead of the column’s native character(n) semantics.

This work is needed to ensure lock identities and post-lock comparisons follow PostgreSQL’s native type semantics for every supported primary-key type. A coarse source-level lock is a safe fallback but serializes unrelated rows; type-aware, key-scoped locks preserve correctness with better concurrency.

Lenguaje dominante
C#
Estrellas
1.5k
Forks
371
Merge medio
7 d 5 h
PR fusionados (30 d)
8

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Azure/data-api-builder

Todos los issues de Azure/data-api-builder

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.