Hi,

while doing some weekend hacking & testing on the BRIN patches I posted
recently, I ran into PANICs in VACUUM, when it summarizes data inserted
concurrently (in another session):

    PANIC:  invalid index offnum: 186

Initially I thought it's a bug in my patches, but apparently it's not
and I can reproduce it easily on current master (846fcc8516).

I'm not sure if/how this is related to the BRIN autosummarization issue
reported by Justin Pryzby about two weeks ago (thread [1]), but I don't
see any segfaults and the messages are always exactly the same.

[1]
https://www.postgresql.org/message-id/flat/20171014035732.GB31726%40telsasoft.com

Reproducing the issue is simple:

    create table brin_test (a int, b bigint, c float,
                            d double precision, e uuid);
    create index on brin_test using brin (a);
    create index on brin_test using brin (b);
    create index on brin_test using brin (c);
    create index on brin_test using brin (d);
    create index on brin_test using brin (e);

and then run

    insert into brin_test select
         mod(i,100000)/25,
         mod(i,100000)/25,
         mod(i,100000)/25,
         mod(i,100000)/25,
        md5((mod(i,100000)/25)::text)::uuid
    from generate_series(1,100000) s(i) \watch 0.1

    vacuum brin_test \watch 1

And sooner or later (for me it only takes a minute or two in most cases)
the VACUUM session should fail with the PANIC message mentioned above.
It always fails with the message, only the value (offset) changes.

The stack trace always looks exactly the same - see the attachment.

At first it seemed the idxrel is always the index on 'e' (i.e. the UUID
column), but it seems I also got failures on the other indexes.

regards

-- 
Tomas Vondra                  http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Core was generated by `postgres: postgres test [local] VACUUM                   
 '.
Program terminated with signal SIGABRT, Aborted.
#0  0x00007fcadc413167 in raise () from /lib64/libc.so.6
(gdb) bt
#0  0x00007fcadc413167 in raise () from /lib64/libc.so.6
#1  0x00007fcadc4145ea in abort () from /lib64/libc.so.6
#2  0x0000000000a2409f in errfinish (dummy=0) at elog.c:557
#3  0x0000000000a26734 in elog_finish (elevel=20, fmt=0xc2ee3d "invalid index 
offnum: %u") at elog.c:1378
#4  0x00000000008a4e86 in PageIndexTupleDeleteNoCompact (page=0x7fcad4595080 
"\004", offnum=292) at bufpage.c:982
#5  0x0000000000476b0c in brin_doupdate (idxrel=0x7fcad33700d8, 
pagesPerRange=128, revmap=0x21657f0, heapBlk=1676160, oldbuf=1442, oldoff=292, 
origtup=0x2169518, origsz=8, newtup=0x2165dc0, newsz=24, samepage=0 '\000') at 
brin_pageops.c:246
#6  0x0000000000475b34 in summarize_range (indexInfo=0x2165940, 
state=0x21673d0, heapRel=0x7fcad336f050, heapBlk=1676160, heapNumBlks=1676189) 
at brin.c:1199
#7  0x0000000000475ddd in brinsummarize (index=0x7fcad33700d8, 
heapRel=0x7fcad336f050, pageRange=4294967295, numSummarized=0x2166e20, 
numExisting=0x2166e20) at brin.c:1306
#8  0x0000000000474e7d in brinvacuumcleanup (info=0x7ffdf5c28d70, 
stats=0x2166e10) at brin.c:794
#9  0x00000000004f85d2 in index_vacuum_cleanup (info=0x7ffdf5c28d70, stats=0x0) 
at indexam.c:772
#10 0x00000000006c59c1 in lazy_cleanup_index (indrel=0x7fcad33700d8, stats=0x0, 
vacrelstats=0x21656c0) at vacuumlazy.c:1651
#11 0x00000000006c48f7 in lazy_scan_heap (onerel=0x7fcad336f050, options=1, 
vacrelstats=0x21656c0, Irel=0x2165550, nindexes=5, aggressive=0 '\000') at 
vacuumlazy.c:1334
#12 0x00000000006c286e in lazy_vacuum_rel (onerel=0x7fcad336f050, options=1, 
params=0x7ffdf5c29450, bstrategy=0x218c710) at vacuumlazy.c:258
#13 0x00000000006c2326 in vacuum_rel (relid=16385, relation=0x209ecd0, 
options=1, params=0x7ffdf5c29450) at vacuum.c:1543
#14 0x00000000006c0942 in vacuum (options=1, relations=0x218c888, 
params=0x7ffdf5c29450, bstrategy=0x218c710, isTopLevel=1 '\001') at vacuum.c:340
#15 0x00000000006c0455 in ExecVacuum (vacstmt=0x209edc0, isTopLevel=1 '\001') 
at vacuum.c:141
#16 0x00000000008b4cb3 in standard_ProcessUtility (pstmt=0x209f110, 
queryString=0x209e2b0 "vacuum brin_test ", context=PROCESS_UTILITY_TOPLEVEL, 
params=0x0, queryEnv=0x0, dest=0x209f208, completionTag=0x7ffdf5c298d0 "") at 
utility.c:675
#17 0x00000000008b4413 in ProcessUtility (pstmt=0x209f110, 
queryString=0x209e2b0 "vacuum brin_test ", context=PROCESS_UTILITY_TOPLEVEL, 
params=0x0, queryEnv=0x0, dest=0x209f208, completionTag=0x7ffdf5c298d0 "") at 
utility.c:357
#18 0x00000000008b33b4 in PortalRunUtility (portal=0x211b9f0, pstmt=0x209f110, 
isTopLevel=1 '\001', setHoldSnapshot=0 '\000', dest=0x209f208, 
completionTag=0x7ffdf5c298d0 "") at pquery.c:1178
#19 0x00000000008b35cc in PortalRunMulti (portal=0x211b9f0, isTopLevel=1 
'\001', setHoldSnapshot=0 '\000', dest=0x209f208, altdest=0x209f208, 
completionTag=0x7ffdf5c298d0 "") at pquery.c:1324
#20 0x00000000008b2a96 in PortalRun (portal=0x211b9f0, 
count=9223372036854775807, isTopLevel=1 '\001', run_once=1 '\001', 
dest=0x209f208, altdest=0x209f208, completionTag=0x7ffdf5c298d0 "") at 
pquery.c:799
#21 0x00000000008ac506 in exec_simple_query (query_string=0x209e2b0 "vacuum 
brin_test ") at postgres.c:1120
#22 0x00000000008b0ab0 in PostgresMain (argc=1, argv=0x20ac000, 
dbname=0x20abe68 "test", username=0x2080e00 "postgres") at postgres.c:4139
#23 0x000000000080c24a in BackendRun (port=0x20a4090) at postmaster.c:4364
#24 0x000000000080b941 in BackendStartup (port=0x20a4090) at postmaster.c:4036
#25 0x0000000000807e7f in ServerLoop () at postmaster.c:1755
#26 0x0000000000807410 in PostmasterMain (argc=3, argv=0x207ec80) at 
postmaster.c:1363
#27 0x000000000073b1de in main (argc=3, argv=0x207ec80) at main.c:228
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to