Re: BUG #17969: Assert failed in bloom_init() when false_positive_rate = 0.25

From: Alexander Lakhin <exclusion(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Subject: Re: BUG #17969: Assert failed in bloom_init() when false_positive_rate = 0.25
Date: 2023-09-26 07:00:00
Message-ID: 5540898f-706c-f399-2797-9e8fa58a5d81@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

16.06.2023 05:23, Tom Lane wrote:
> Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> writes:
>> It seems that the minimum false positive rate also doesn't work:
>> postgres(1:3419179)=# create table t (a int);
>> CREATE TABLE
>> postgres(1:3419179)=# create index t_idx on t using brin (a
>> int4_bloom_ops (false_positive_rate = 0.0001));
>> CREATE INDEX
>> postgres(1:3419179)=# insert into t values (1);
>> 2023-06-16 11:14:01.349 JST [3419179] ERROR: the bloom filter is too
>> large (8924 > 8144)
>> 2023-06-16 11:14:01.349 JST [3419179] STATEMENT: insert into t values (1);
>> ERROR: the bloom filter is too large (8924 > 8144)
> Hmm, but it would work with a larger page size, right? If so
> I'm disinclined to move the minimum. What I don't like about
> the above is that the failure doesn't occur until you actually
> insert an index entry. Is there a way to check for this at
> CREATE INDEX time?

With a larger page size, say, 32 kB, you'll get the similar error:
ERROR:  the bloom filter is too large (35856 > 32720)

but, if you define also a smaller n_distinct_per_range value explicitly. e. g.:
CREATE INDEX idx ON tbl USING brin (i int4_bloom_ops(false_positive_rate = 0.00010, n_distinct_per_range = 100));
false_positive_rate = 0.00010 will do.

So I see an issue only with false_positive_rate.
And I think the assertion that false_positive_rate is a valid probability
would be good.
The patch is attached.

Tomas, I saw that you refactored that place (introduced bloom_filter_size())
in 2b8b2852b, could you also consider checking for invalid parameter values
at CREATE INDEX time, as Tom suggested above?

Best regards,
Alexander

Attachment Content-Type Size
v1-01-fix-assert-in-brin-bloom.patch text/x-patch 655 bytes
v1-01-fix-assert-in-brin-bloom.backpatch14-16 text/plain 682 bytes

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Alexander Lakhin 2023-09-26 08:08:08 Re: BUG #18129: GiST index produces incorrect query results
Previous Message PG Bug reporting form 2023-09-26 01:26:14 BUG #18134: ROW_COUNT do not set to 0 when psql's \gset command get no rows returned