Gin Index Creation Failure

From: Yaser Raja <yrraja(at)gmail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Gin Index Creation Failure
Date: 2017-08-28 15:42:33
Message-ID: CALkbEVnZk6nRXibv+QbcjSfm6dX1Hy5cxjuP=Cv6Yp6NVgpHdg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

While creating a gin index in Postgres 9.5.8 I got the following error
message:

ERROR: invalid memory alloc request size 2013265920

After a number of attempts to independently reproduce this issue, i have
found that this error comes up when the following conditions are met:

- Table contains more than 200M rows
- The maintenance_work_mem is around 1GB or higher

Here is a test run which completes successfully:

postgres=# show maintenance_work_mem ;
maintenance_work_mem
----------------------
64MB
(1 row)
postgres=#
postgres=# CREATE TABLE gin_test (a int, b jsonb);
CREATE TABLE
postgres=# INSERT INTO gin_test (a) VALUES (generate_series(1,200000000,1));
INSERT 0 200000000
postgres=# CREATE INDEX CONCURRENTLY ON gin_test USING gin(b
jsonb_path_ops);
CREATE INDEX
postgres=#

Here is another test run within the same psql session which fails. The only
difference between the two is that maintenance_work_mem is set to 1GB:

postgres=# drop table gin_test ;
DROP TABLE
postgres=# set maintenance_work_mem = '1GB';
SET
postgres=# show maintenance_work_mem ;
maintenance_work_mem
----------------------
1GB
(1 row)
postgres=#
postgres=# CREATE TABLE gin_test (a int, b jsonb);
CREATE TABLE
postgres=# INSERT INTO gin_test (a) VALUES (generate_series(1,200000000,1));
INSERT 0 200000000
postgres=# CREATE INDEX CONCURRENTLY ON gin_test USING gin(b
jsonb_path_ops);
ERROR: invalid memory alloc request size 2013265920
postgres=#

The index creation fails with the same error with and without
"concurrently". Also the issue comes up without "jsonb_path_ops" as well. I
have tested this on Linux and OSX.

I was not able to reproduce this issue in Postgres 9.6.4.

Regards
Yaser

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2017-08-28 16:00:52 Re: Gin Index Creation Failure
Previous Message Tom Lane 2017-08-28 14:47:58 Re: [HACKERS] [postgresql 10 beta3] unrecognized node type: 90