Skip to content

[Bug]: Conflicting NULL row not refused with NULLS NOT DISTINCT and bloom filters in compressed DMLย #10579

Closed

Description

@antekresic

What type of bug is this?

Data corruption

What subsystems and features are affected?

Compression

What happened?

NULL check issues combined with bloom sparse indexing

TimescaleDB version affected

main

PostgreSQL version used

18.6

What operating system did you use?

arch

What installation method did you use?

Source

What platform did you run on?

On prem/Self-hosted

Relevant log output and stack trace

How can we reproduce the bug?

-- On a compressed hypertable with a NULLS NOT DISTINCT unique constraint,
  -- INSERT ... ON CONFLICT DO NOTHING inserts a duplicate NULL row when a
  -- single-column bloom sparse index on the conflict column prunes the
  -- conflict-check scan.

  create table sensor_log(
      recorded_at timestamptz not null,
      sensor_id int,
      reading int,
      unique nulls not distinct (sensor_id, recorded_at)
  );
  select create_hypertable('sensor_log', 'recorded_at');
  alter table sensor_log set (timescaledb.enable_columnstore = true,
                              timescaledb.orderby = 'recorded_at',
                              timescaledb.sparse_index = 'bloom(sensor_id)');

  insert into sensor_log values ('2026-01-10 00:50', 1, 1);
  insert into sensor_log values ('2026-01-10 00:51', null, 1);
  select compress_chunk(show_chunks('sensor_log'));

  -- baseline: without bloom pruning the conflict is found and nothing is inserted
  set timescaledb.enable_sparse_index_bloom = off;
  insert into sensor_log values ('2026-01-10 00:51', null, 2)
  on conflict (sensor_id, recorded_at) do nothing;

  -- the same insert with the default setting
  reset timescaledb.enable_sparse_index_bloom;
  insert into sensor_log values ('2026-01-10 00:51', null, 2)
  on conflict (sensor_id, recorded_at) do nothing;  -- INSERT 0 1, expected INSERT 0 0

  select * from sensor_log where sensor_id is null;  -- two rows for the same key

Activity

  1. self-assigned this
    on Sep 10, 2026
  2. added
    Columnstore
    on Sep 10, 2026
  3. added theissue type on Sep 10, 2026
  4. added this to the v2.30.1 milestone on Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Columnstorebugconstraint-violation

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions