pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feed From: Alexander Lakhin <exclusion@gmail.com>
To: Peter Geoghegan <pg@bowt.ie>
To: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Subject: Re: BUG #15217: Valgrind - writing uninitialised byte(s) in FileWrite
Date: Fri, 1 Jun 2018 23:00:20 +0300
Message-ID: <29aaaee6-c0f7-0fa1-e0c8-c72403c3bb7f@gmail.com> (raw )
In-Reply-To: <63d8e998-d7ea-77d2-67ff-364e21909dc2@gmail.com >
References: <152765297018.1287.16667772151157129465@wrigleys.postgresql.org >
<CAH2-Wzk-=Omu4eoTYeYV42uRx+Y6DBjE84=G-fMBkHHVf6wVPw@mail.gmail.com >
<63d8e998-d7ea-77d2-67ff-364e21909dc2@gmail.com >
30.05.2018 09:35, Alexander Lakhin wrote:
> 30.05.2018 08:54, Peter Geoghegan wrote:
>> This looks like the same harmless warning that we suppressed for
>> parallel sort in Postgres 11 (see commits 9fafa413ac6 and
>> de6428afe13). This happens to be a serial sort in Postgres 10, but the
>> fact that it's still possible there isn't surprising.
>>
>> What's your work_mem setting? Can you show EXPLAIN ANALYZE output for the query?
>
> Thanks for the answer!
>
> The work_mem setting is 4MB. To get EXPLAIN ANALYZE is rather
> difficult as I get these errors while running pg_tcpds for hours, but
> I'll try to catch the query. I will also try to play with work_mem and
> to apply the aforementioned patches to REL_10_STABLE.
>
I've managed to reproduce this warning with pg_tpch.
The "problematic" query:
https://github.com/tvondra/pg_tpch/blob/master/dss/templates/10.sql
EXPLAIN ANALYZE:
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=178881.96..178882.01 rows=20 width=202) (actual
time=41708.427..41708.994 rows=20 loops=1)
-> Sort (cost=178881.96..179020.08 rows=55249 width=202) (actual
time=41706.775..41706.828 rows=20 loops=1)
Sort Key: (sum((lineitem.l_extendedprice * ('1'::numeric -
lineitem.l_discount)))) DESC
Sort Method: top-N heapsort Memory: 34kB
-> Finalize GroupAggregate (cost=170313.58..177411.81
rows=55249 width=202) (actual time=27586.165..40109.437 rows=37948 loops=1)
Group Key: customer.c_custkey, nation.n_name
-> Gather Merge (cost=170313.58..176260.79 rows=46040
width=202) (actual time=27570.718..33645.648 rows=37948 loops=1)
Workers Planned: 2
Workers Launched: 2
-> Partial GroupAggregate
(cost=169313.56..169946.61 rows=23020 width=202) (actual
time=26845.343..34327.273 rows=12649 loops=3)
Group Key: customer.c_custkey, nation.n_name
-> Sort (cost=169313.56..169371.11
rows=23020 width=182) (actual time=26801.917..27406.584 rows=38258 loops=3)
Sort Key: customer.c_custkey,
nation.n_name
Sort Method: external sort Disk: 7016kB
-> Hash Join
(cost=35074.91..165598.19 rows=23020 width=182) (actual
time=8882.471..24071.174 rows=38258 loops=3)
Hash Cond: (customer.c_nationkey
= nation.n_nationkey)
-> Nested Loop
(cost=35073.35..165314.18 rows=23020 width=164) (actual
time=8833.355..23146.172 rows=38258 loops=3)
-> Merge Join
(cost=35072.92..42628.04 rows=23461 width=156) (actual
time=8823.262..13619.941 rows=19073 loops=3)
Merge Cond:
(customer.c_custkey = orders.o_custkey)
-> Parallel Index
Scan using customer_pkey on customer (cost=0.42..6742.42 rows=62500
width=152) (actual time=13.463..1101.789 rows=50000 loops=3)
-> Materialize
(cost=35072.48..35354.01 rows=56306 width=12) (actual
time=8795.265..10510.505 rows=57105 loops=3)
-> Sort (cost=35072.48..35213.24 rows=56306 width=12) (actual
time=8790.529..9667.322 rows=57105 loops=3)
Sort Key: orders.o_custkey
Sort Method: external merge Disk: 1256kB
-> Bitmap Heap Scan on orders (cost=1197.56..29667.15 rows=56306
width=12) (actual time=273.899..6733.885 rows=57218 loops=3)
Recheck Cond: ((o_orderdate >= '1993-07-01'::date) AND (o_orderdate <
'1993-10-01 00:00:00'::timestamp without time zone))
Rows Removed by Index Recheck: 430095
Heap Blocks: exact=15937 lossy=8327
-> Bitmap Index Scan on idx_orders_orderdate (cost=0.00..1183.49
rows=56306 width=0) (actual time=225.114..225.114 rows=57218 loops=3)
Index Cond: ((o_orderdate >= '1993-07-01'::date) AND (o_orderdate <
'1993-10-01 00:00:00'::timestamp without time zone))
-> Index Scan using
idx_lineitem_orderkey on lineitem (cost=0.43..5.19 rows=4 width=20)
(actual time=0.372..0.448 rows=2 loops=57218)
Index Cond:
(l_orderkey = orders.o_orderkey)
Filter:
(l_returnflag = 'R'::bpchar)
Rows Removed by
Filter: 2
-> Hash (cost=1.25..1.25
rows=25 width=30) (actual time=31.890..31.890 rows=25 loops=3)
Buckets: 1024 Batches: 1
Memory Usage: 10kB
-> Seq Scan on nation
(cost=0.00..1.25 rows=25 width=30) (actual time=6.582..8.616 rows=25
loops=3)
Planning time: 689.897 ms
Execution time: 41835.301 ms
(39 rows)
(The work_mem setting was decreased to 1MB.)
Valgrind logs of the three backends affected are attached.
After applying the changes from 9fafa413ac6 and de6428afe13 I don't see
this warning.
Best regards,
------
Alexander Lakhin
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
Attachments:
postmaster-86.log (text/x-log, 3.9K) download
==00:00:05:02.191 86== Memcheck, a memory error detector
==00:00:05:02.191 86== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==00:00:05:02.191 86== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==00:00:05:02.191 86== Command: /usr/local/pgsql/bin/../obin/postmaster -D /var/lib/postgresql/main -c config_file=/var/lib/postgresql/main/postgresql.conf
==00:00:05:02.191 86== Parent PID: 14
==00:00:05:02.191 86==
==00:00:05:13.235 86== Syscall param write(buf) points to uninitialised byte(s)
==00:00:05:13.235 86== at 0x4E4D281: write (write.c:27)
==00:00:05:13.235 86== by 0x487ACF: FileWrite (fd.c:1773)
==00:00:05:13.235 86== by 0x489CB1: BufFileDumpBuffer (buffile.c:324)
==00:00:05:13.235 86== by 0x48A164: BufFileFlush (buffile.c:466)
==00:00:05:13.235 86== by 0x48A164: BufFileRead (buffile.c:372)
==00:00:05:13.235 86== by 0x5FAC68: ltsReadBlock (logtape.c:248)
==00:00:05:13.235 86== by 0x5FAD4C: ltsReadFillBuffer (logtape.c:275)
==00:00:05:13.235 86== by 0x60337D: mergeruns (tuplesort.c:2683)
==00:00:05:13.235 86== by 0x60337D: tuplesort_performsort (tuplesort.c:1823)
==00:00:05:13.235 86== by 0x395B42: ExecSort (nodeSort.c:117)
==00:00:05:13.235 86== by 0x375407: ExecProcNodeInstr (execProcnode.c:446)
==00:00:05:13.235 86== by 0x38D8D3: ExecProcNode (executor.h:250)
==00:00:05:13.235 86== by 0x38D8D3: ExecMaterial (nodeMaterial.c:134)
==00:00:05:13.235 86== by 0x375407: ExecProcNodeInstr (execProcnode.c:446)
==00:00:05:13.235 86== by 0x38EC87: ExecProcNode (executor.h:250)
==00:00:05:13.235 86== by 0x38EC87: ExecMergeJoin (nodeMergejoin.c:704)
==00:00:05:13.235 86== Address 0xf3a7928 is 2,840 bytes inside a block of size 8,256 client-defined
==00:00:05:13.235 86== at 0x5F5B50: palloc (mcxt.c:872)
==00:00:05:13.235 86== by 0x489EBF: makeBufFile (buffile.c:107)
==00:00:05:13.235 86== by 0x489EBF: BufFileCreateTemp (buffile.c:175)
==00:00:05:13.235 86== by 0x5FAE24: LogicalTapeSetCreate (logtape.c:390)
==00:00:05:13.235 86== by 0x6019AC: inittapes (tuplesort.c:2410)
==00:00:05:13.235 86== by 0x6019AC: puttuple_common (tuplesort.c:1622)
==00:00:05:13.235 86== by 0x602CA3: tuplesort_puttupleslot (tuplesort.c:1375)
==00:00:05:13.235 86== by 0x395B20: ExecSort (nodeSort.c:111)
==00:00:05:13.235 86== by 0x375407: ExecProcNodeInstr (execProcnode.c:446)
==00:00:05:13.235 86== by 0x38D8D3: ExecProcNode (executor.h:250)
==00:00:05:13.235 86== by 0x38D8D3: ExecMaterial (nodeMaterial.c:134)
==00:00:05:13.235 86== by 0x375407: ExecProcNodeInstr (execProcnode.c:446)
==00:00:05:13.235 86== by 0x38EC87: ExecProcNode (executor.h:250)
==00:00:05:13.235 86== by 0x38EC87: ExecMergeJoin (nodeMergejoin.c:704)
==00:00:05:13.235 86== by 0x375407: ExecProcNodeInstr (execProcnode.c:446)
==00:00:05:13.235 86== by 0x392D0E: ExecProcNode (executor.h:250)
==00:00:05:13.235 86== by 0x392D0E: ExecNestLoop (nodeNestloop.c:109)
==00:00:05:13.235 86==
{
<insert_a_suppression_name_here>
Memcheck:Param
write(buf)
fun:write
fun:FileWrite
fun:BufFileDumpBuffer
fun:BufFileFlush
fun:BufFileRead
fun:ltsReadBlock
fun:ltsReadFillBuffer
fun:mergeruns
fun:tuplesort_performsort
fun:ExecSort
fun:ExecProcNodeInstr
fun:ExecProcNode
fun:ExecMaterial
fun:ExecProcNodeInstr
fun:ExecProcNode
fun:ExecMergeJoin
}
==00:00:05:45.715 86==
==00:00:05:45.715 86== HEAP SUMMARY:
==00:00:05:45.715 86== in use at exit: 1,773,479 bytes in 323 blocks
==00:00:05:45.715 86== total heap usage: 1,313,446 allocs, 798 frees, 156,993,525 bytes allocated
==00:00:05:45.715 86==
==00:00:05:45.715 86== For a detailed leak analysis, rerun with: --leak-check=full
==00:00:05:45.715 86==
==00:00:05:45.715 86== For counts of detected and suppressed errors, rerun with: -v
==00:00:05:45.715 86== Use --track-origins=yes to see where uninitialised values come from
==00:00:05:45.715 86== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 16 from 6)
postmaster-88.log (text/x-log, 3.9K) download
==00:00:05:03.891 88== Memcheck, a memory error detector
==00:00:05:03.891 88== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==00:00:05:03.891 88== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==00:00:05:03.891 88== Command: /usr/local/pgsql/bin/../obin/postmaster -D /var/lib/postgresql/main -c config_file=/var/lib/postgresql/main/postgresql.conf
==00:00:05:03.891 88== Parent PID: 14
==00:00:05:03.891 88==
==00:00:05:13.231 88== Syscall param write(buf) points to uninitialised byte(s)
==00:00:05:13.231 88== at 0x4E4D281: write (write.c:27)
==00:00:05:13.231 88== by 0x487ACF: FileWrite (fd.c:1773)
==00:00:05:13.231 88== by 0x489CB1: BufFileDumpBuffer (buffile.c:324)
==00:00:05:13.231 88== by 0x48A164: BufFileFlush (buffile.c:466)
==00:00:05:13.231 88== by 0x48A164: BufFileRead (buffile.c:372)
==00:00:05:13.231 88== by 0x5FAC68: ltsReadBlock (logtape.c:248)
==00:00:05:13.231 88== by 0x5FAD4C: ltsReadFillBuffer (logtape.c:275)
==00:00:05:13.231 88== by 0x60337D: mergeruns (tuplesort.c:2683)
==00:00:05:13.231 88== by 0x60337D: tuplesort_performsort (tuplesort.c:1823)
==00:00:05:13.231 88== by 0x395B42: ExecSort (nodeSort.c:117)
==00:00:05:13.231 88== by 0x375407: ExecProcNodeInstr (execProcnode.c:446)
==00:00:05:13.231 88== by 0x38D8D3: ExecProcNode (executor.h:250)
==00:00:05:13.231 88== by 0x38D8D3: ExecMaterial (nodeMaterial.c:134)
==00:00:05:13.231 88== by 0x375407: ExecProcNodeInstr (execProcnode.c:446)
==00:00:05:13.231 88== by 0x38EC87: ExecProcNode (executor.h:250)
==00:00:05:13.231 88== by 0x38EC87: ExecMergeJoin (nodeMergejoin.c:704)
==00:00:05:13.231 88== Address 0x5fe1da8 is 2,840 bytes inside a block of size 8,256 client-defined
==00:00:05:13.231 88== at 0x5F5B50: palloc (mcxt.c:872)
==00:00:05:13.231 88== by 0x489EBF: makeBufFile (buffile.c:107)
==00:00:05:13.231 88== by 0x489EBF: BufFileCreateTemp (buffile.c:175)
==00:00:05:13.231 88== by 0x5FAE24: LogicalTapeSetCreate (logtape.c:390)
==00:00:05:13.231 88== by 0x6019AC: inittapes (tuplesort.c:2410)
==00:00:05:13.231 88== by 0x6019AC: puttuple_common (tuplesort.c:1622)
==00:00:05:13.231 88== by 0x602CA3: tuplesort_puttupleslot (tuplesort.c:1375)
==00:00:05:13.231 88== by 0x395B20: ExecSort (nodeSort.c:111)
==00:00:05:13.231 88== by 0x375407: ExecProcNodeInstr (execProcnode.c:446)
==00:00:05:13.231 88== by 0x38D8D3: ExecProcNode (executor.h:250)
==00:00:05:13.231 88== by 0x38D8D3: ExecMaterial (nodeMaterial.c:134)
==00:00:05:13.231 88== by 0x375407: ExecProcNodeInstr (execProcnode.c:446)
==00:00:05:13.231 88== by 0x38EC87: ExecProcNode (executor.h:250)
==00:00:05:13.231 88== by 0x38EC87: ExecMergeJoin (nodeMergejoin.c:704)
==00:00:05:13.231 88== by 0x375407: ExecProcNodeInstr (execProcnode.c:446)
==00:00:05:13.231 88== by 0x392D0E: ExecProcNode (executor.h:250)
==00:00:05:13.231 88== by 0x392D0E: ExecNestLoop (nodeNestloop.c:109)
==00:00:05:13.231 88==
{
<insert_a_suppression_name_here>
Memcheck:Param
write(buf)
fun:write
fun:FileWrite
fun:BufFileDumpBuffer
fun:BufFileFlush
fun:BufFileRead
fun:ltsReadBlock
fun:ltsReadFillBuffer
fun:mergeruns
fun:tuplesort_performsort
fun:ExecSort
fun:ExecProcNodeInstr
fun:ExecProcNode
fun:ExecMaterial
fun:ExecProcNodeInstr
fun:ExecProcNode
fun:ExecMergeJoin
}
==00:00:05:45.331 88==
==00:00:05:45.331 88== HEAP SUMMARY:
==00:00:05:45.331 88== in use at exit: 1,007,840 bytes in 209 blocks
==00:00:05:45.331 88== total heap usage: 668,190 allocs, 524 frees, 72,372,249 bytes allocated
==00:00:05:45.331 88==
==00:00:05:45.331 88== For a detailed leak analysis, rerun with: --leak-check=full
==00:00:05:45.331 88==
==00:00:05:45.331 88== For counts of detected and suppressed errors, rerun with: -v
==00:00:05:45.331 88== Use --track-origins=yes to see where uninitialised values come from
==00:00:05:45.331 88== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 11 from 6)
postmaster-89.log (text/x-log, 3.9K) download
==00:00:05:03.907 89== Memcheck, a memory error detector
==00:00:05:03.907 89== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==00:00:05:03.907 89== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==00:00:05:03.907 89== Command: /usr/local/pgsql/bin/../obin/postmaster -D /var/lib/postgresql/main -c config_file=/var/lib/postgresql/main/postgresql.conf
==00:00:05:03.907 89== Parent PID: 14
==00:00:05:03.907 89==
==00:00:05:13.502 89== Syscall param write(buf) points to uninitialised byte(s)
==00:00:05:13.502 89== at 0x4E4D281: write (write.c:27)
==00:00:05:13.502 89== by 0x487ACF: FileWrite (fd.c:1773)
==00:00:05:13.502 89== by 0x489CB1: BufFileDumpBuffer (buffile.c:324)
==00:00:05:13.502 89== by 0x48A164: BufFileFlush (buffile.c:466)
==00:00:05:13.502 89== by 0x48A164: BufFileRead (buffile.c:372)
==00:00:05:13.502 89== by 0x5FAC68: ltsReadBlock (logtape.c:248)
==00:00:05:13.502 89== by 0x5FAD4C: ltsReadFillBuffer (logtape.c:275)
==00:00:05:13.502 89== by 0x60337D: mergeruns (tuplesort.c:2683)
==00:00:05:13.502 89== by 0x60337D: tuplesort_performsort (tuplesort.c:1823)
==00:00:05:13.502 89== by 0x395B42: ExecSort (nodeSort.c:117)
==00:00:05:13.502 89== by 0x375407: ExecProcNodeInstr (execProcnode.c:446)
==00:00:05:13.502 89== by 0x38D8D3: ExecProcNode (executor.h:250)
==00:00:05:13.502 89== by 0x38D8D3: ExecMaterial (nodeMaterial.c:134)
==00:00:05:13.502 89== by 0x375407: ExecProcNodeInstr (execProcnode.c:446)
==00:00:05:13.502 89== by 0x38EC87: ExecProcNode (executor.h:250)
==00:00:05:13.502 89== by 0x38EC87: ExecMergeJoin (nodeMergejoin.c:704)
==00:00:05:13.502 89== Address 0x5fe1e08 is 2,840 bytes inside a block of size 8,256 client-defined
==00:00:05:13.502 89== at 0x5F5B50: palloc (mcxt.c:872)
==00:00:05:13.502 89== by 0x489EBF: makeBufFile (buffile.c:107)
==00:00:05:13.502 89== by 0x489EBF: BufFileCreateTemp (buffile.c:175)
==00:00:05:13.502 89== by 0x5FAE24: LogicalTapeSetCreate (logtape.c:390)
==00:00:05:13.502 89== by 0x6019AC: inittapes (tuplesort.c:2410)
==00:00:05:13.502 89== by 0x6019AC: puttuple_common (tuplesort.c:1622)
==00:00:05:13.502 89== by 0x602CA3: tuplesort_puttupleslot (tuplesort.c:1375)
==00:00:05:13.502 89== by 0x395B20: ExecSort (nodeSort.c:111)
==00:00:05:13.502 89== by 0x375407: ExecProcNodeInstr (execProcnode.c:446)
==00:00:05:13.502 89== by 0x38D8D3: ExecProcNode (executor.h:250)
==00:00:05:13.502 89== by 0x38D8D3: ExecMaterial (nodeMaterial.c:134)
==00:00:05:13.502 89== by 0x375407: ExecProcNodeInstr (execProcnode.c:446)
==00:00:05:13.502 89== by 0x38EC87: ExecProcNode (executor.h:250)
==00:00:05:13.502 89== by 0x38EC87: ExecMergeJoin (nodeMergejoin.c:704)
==00:00:05:13.502 89== by 0x375407: ExecProcNodeInstr (execProcnode.c:446)
==00:00:05:13.502 89== by 0x392D0E: ExecProcNode (executor.h:250)
==00:00:05:13.502 89== by 0x392D0E: ExecNestLoop (nodeNestloop.c:109)
==00:00:05:13.502 89==
{
<insert_a_suppression_name_here>
Memcheck:Param
write(buf)
fun:write
fun:FileWrite
fun:BufFileDumpBuffer
fun:BufFileFlush
fun:BufFileRead
fun:ltsReadBlock
fun:ltsReadFillBuffer
fun:mergeruns
fun:tuplesort_performsort
fun:ExecSort
fun:ExecProcNodeInstr
fun:ExecProcNode
fun:ExecMaterial
fun:ExecProcNodeInstr
fun:ExecProcNode
fun:ExecMergeJoin
}
==00:00:05:45.308 89==
==00:00:05:45.308 89== HEAP SUMMARY:
==00:00:05:45.308 89== in use at exit: 1,008,240 bytes in 209 blocks
==00:00:05:45.308 89== total heap usage: 633,688 allocs, 520 frees, 69,381,867 bytes allocated
==00:00:05:45.308 89==
==00:00:05:45.308 89== For a detailed leak analysis, rerun with: --leak-check=full
==00:00:05:45.308 89==
==00:00:05:45.308 89== For counts of detected and suppressed errors, rerun with: -v
==00:00:05:45.308 89== Use --track-origins=yes to see where uninitialised values come from
==00:00:05:45.308 89== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 11 from 6)
Message-ID: <29aaaee6-c0f7-0fa1-e0c8-c72403c3bb7f@gmail.com>
Permalink: ../29aaaee6-c0f7-0fa1-e0c8-c72403c3bb7f@gmail.com/
Also on: postgresql.org/message-id/29aaaee6-c0f7-0fa1-e0c8-c72403c3bb7f@gmail.com
copy link · copy postgr.es
reply Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: exclusion@gmail.com, pg@bowt.ie
Subject: Re: BUG #15217: Valgrind - writing uninitialised byte(s) in FileWrite
In-Reply-To: <29aaaee6-c0f7-0fa1-e0c8-c72403c3bb7f@gmail.com>
References: <152765297018.1287.16667772151157129465@wrigleys.postgresql.org> <CAH2-Wzk-=Omu4eoTYeYV42uRx+Y6DBjE84=G-fMBkHHVf6wVPw@mail.gmail.com> <63d8e998-d7ea-77d2-67ff-364e21909dc2@gmail.com> <29aaaee6-c0f7-0fa1-e0c8-c72403c3bb7f@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox