Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8182455

Browse files
committed
Keep the decompressed filter in brin_bloom_union
The brin_bloom_union() function combines two BRIN summaries, by mergingone filter into the other. With bloom, we have to decompress the filtersfirst, but the function failed to update the summary to store the mergedfilter. As a consequence, the index may be missing some of the data, andreturn false negatives.This issue exists since BRIN bloom indexes were introduced in Postgres14, but at that point the union function was called only when twosessions happened to summarize a range concurrently, which is rare. Itgot much easier to hit in 17, as parallel builds use the union functionto merge summaries built by workers.Fixed by storing a pointer to the decompressed filter, and freeing theoriginal one. Free the second filter too, if it was decompressed. Thefreeing is not strictly necessary, because the union is called inshort-lived contexts, but it's tidy.Backpatch to 14, where BRIN bloom indexes were introduced.Reported by Arseniy Mukhin, investigation and fix by me.Reported-by: Arseniy MukhinDiscussion:https://postgr.es/m/18855-1cf1c8bcc22150e6%40postgresql.orgBackpatch-through: 14
1 parent5552736 commit8182455

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

‎src/backend/access/brin/brin_bloom.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,17 @@ brin_bloom_union(PG_FUNCTION_ARGS)
692692
/* update the number of bits set in the filter */
693693
filter_a->nbits_set=pg_popcount((constchar*)filter_a->data,nbytes);
694694

695+
/* if we decompressed filter_a, update the summary */
696+
if (PointerGetDatum(filter_a)!=col_a->bv_values[0])
697+
{
698+
pfree(DatumGetPointer(col_a->bv_values[0]));
699+
col_a->bv_values[0]=PointerGetDatum(filter_a);
700+
}
701+
702+
/* also free filter_b, if it was decompressed */
703+
if (PointerGetDatum(filter_b)!=col_b->bv_values[0])
704+
pfree(filter_b);
705+
695706
PG_RETURN_VOID();
696707
}
697708

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp