Re: Amcheck verification of GiST and GIN
Kirill Reshke <reshkekirill@gmail.com>
Attachments
- v28-0014-Fix-memory-leak-in-gist_check_page.patch (application/octet-stream) patch v28-0014
Hi!
On Mon, 5 Aug 2024 at 20:05, Tomas Vondra <tomas@vondra.me> wrote:
>
> Hi,
>
> I've spent a bit more time looking at the GiST part as part of my
> "parallel GiST build" patch nearby, and I think there's some sort of
> memory leak.
>
> Consider this:
>
> create table t (a text);
>
> insert into t select md5(i::text)
> from generate_series(1,25000000) s(i);
>
> create index on t using gist (a gist_trgm_ops);
>
> select gist_index_check('t_a_idx', true);
>
> This creates a ~4GB GiST trigram index, and then checks it. But that
> gets killed, because of OOM killer. On my test machine it consumes
> ~6.5GB of memory before OOM intervenes.
>
> The memory context stats look like this:
>
> TopPortalContext: 8192 total in 1 blocks; 7680 free (0 chunks); 512 used
> PortalContext: 1024 total in 1 blocks; 616 free (0 chunks); 408
> used: <unnamed>
> ExecutorState: 8192 total in 1 blocks; 4024 free (4 chunks); 4168 used
> printtup: 8192 total in 1 blocks; 7952 free (0 chunks); 240 used
> ExprContext: 8192 total in 1 blocks; 7224 free (10 chunks); 968 used
> amcheck context: 3128950872 total in 376 blocks; 219392 free
> (1044 chunks); 3128731480 used
> ExecutorState: 8192 total in 1 blocks; 7200 free (0 chunks);
> 992 used
> ExprContext: 8192 total in 1 blocks; 7952 free (0 chunks);
> 240 used
> GiST scan context: 22248 total in 2 blocks; 7808 free (8
> chunks); 14440 used
>
> This is from before the OOM kill, but it shows there's ~3GB of memory is
> the amcheck context.
>
> Seems like a memory leak to me - I didn't look at which place leaks.
+ 1, there is a memory leak.
>
>
> regards
>
> --
> Tomas Vondra
>
>
So, I did some testing, and it seems that the tuple returned by
`gistgetadjusted` inside `gist_check_page` is not being freed.
Trivial fix attached.
--
Best regards,
Kirill Reshke
Commits
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
amcheck: Fix posting tree checks in gin_index_check()
- 0cf205e122ae 18.0 landed
-
amcheck: Fix parent key check in gin_index_check()
- cdd1a431f21d 18.0 landed
-
amcheck: Fix checks of entry order for GIN indexes
- 0b54b392334b 18.0 landed
-
amcheck: Remove unused GinScanItem->parentlsn field
- 8dd41c0bff5b 18.0 landed
-
amcheck: Test gin_index_check on a multicolumn index
- c89d6b889ce9 18.0 landed
-
Remove incidental md5() function use from test
- 49b82522f13f 18.0 landed
-
amcheck: Add a GIN index to the CREATE INDEX CONCURRENTLY tests
- 68f97aeadb8e 18.0 landed
-
amcheck: Add a test with GIN index on JSONB data
- ca738bdc4c9d 18.0 landed
-
amcheck: Fix indentation in verify_gin.c
- ec4327d106be 18.0 landed
-
amcheck: Add gin_index_check() to verify GIN index
- 14ffaece0fb5 18.0 landed
-
amcheck: Move common routines into a separate module
- d70b17636ddf 18.0 landed
-
Fix grammar in GIN README
- fb9dff76635d 18.0 landed
-
Avoid amcheck inline compression false positives.
- eba775345d23 12.0 cited