Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wX3eN-0031sX-0Q for pgsql-bugs@arkaria.postgresql.org; Tue, 09 Jun 2026 21:06:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wX3eL-008J5y-27 for pgsql-bugs@arkaria.postgresql.org; Tue, 09 Jun 2026 21:06:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wX3eL-008J5q-1A for pgsql-bugs@lists.postgresql.org; Tue, 09 Jun 2026 21:06:17 +0000 Received: from mail-qv1-xf31.google.com ([2607:f8b0:4864:20::f31]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wX3eJ-00000002Dex-0CzY for pgsql-bugs@lists.postgresql.org; Tue, 09 Jun 2026 21:06:17 +0000 Received: by mail-qv1-xf31.google.com with SMTP id 6a1803df08f44-8ce9df4732cso61719066d6.1 for ; Tue, 09 Jun 2026 14:06:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781039173; x=1781643973; darn=lists.postgresql.org; h=in-reply-to:references:to:from:subject:message-id:date:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=TJvRQ6bCHeryf1SF1lDR9WGUSzJwLi47hd+syHx25r8=; b=Fc46EduJj/xhjIa4e1R+nSol4yBSor7Qm4SiAjdjwfIajaZnIl0Fj0jrgZHvNYq9Z0 Us5pLQqYhrh7ygXyWGW0j/5jYj0Nf/mRVThfr63/iRwMEFlno0n+z+OkEYC1dgybJXh1 k/uTuwr4+vukB+ksZXTC5YkTvuZechiVgTZCBwlMoayg4SbHMhf1imxkmcxroMt/HqD4 AqSrjw53GuTKa6xH390rsPCExY+fs0GSpCDl2j2iA9VjaCzcE0QBXsYgKp75paJsRVV5 nxdmegRbTeiJ/MZElI9iQycYSa8MypZyM5QJ6icl6dMI31VknmDo2bgeiIygcVMiaCt8 g3aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781039173; x=1781643973; h=in-reply-to:references:to:from:subject:message-id:date:mime-version :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=TJvRQ6bCHeryf1SF1lDR9WGUSzJwLi47hd+syHx25r8=; b=mb15ZlLM18JKG+ygA5GYZMLjOEhpQeDBdtAAlLuOY3v3Dwqs1RFdbidYjxeoDOlYV2 Wf0f3W0qq1w1nyDTBK50dSRB/SZU+SOAW9ft63gAqOyAdCVOnQfvlBv9WDiYFVU2jpIe cFg2OiRFjxu/0TVTxgT3xfnlomfr/i0ItZ62yLLWfk3ODBM31Y9I8Jil8OOyaqmam3YL nAnQT/TnAUfZcM5VJ7OSHj177va1AyIF+aIs0LbKkWGbdMFbr4rjrtSKk35LSu0XpvC1 OBsSmoAw/Q8+7Vj5l1/TOGEbMAELKqcRNvBlR1odkMsDnF7drktsPHLfGbU+raak+Hhn zCsw== X-Forwarded-Encrypted: i=1; AFNElJ/ssw43/xFQnYocoXS7MNBwySVzx6WvgNoOqn+z5N4guFZnnNSp3lGvuZ+Fm6+RJmUrS1smUerMU835@lists.postgresql.org X-Gm-Message-State: AOJu0YwiVGOIxSeSOT0LPGo8zXuLEbhCd3hLb5vbUzLSDj5Yb9YPYzPX 95g14iDdPb89c5pFgBlsx7uB+dav2ZuMCvx/ymXLk70rb8ZBmiQJFOyZ3o00fg== X-Gm-Gg: Acq92OGX6j4BffGrO3LA/2mz9hofdgW66TYHWShDO/5mjgtexxukzsbgsAiSNqQq1EG wZ4tu9zBKTmoYDlIh9diWCr1KXQ5O7BgQJi05uDdFSD1uBoG5P8k2SPyNjIkcNkds5YFLI6SuyH IkGFMsfj6qMb4xhN9jwXb4XI6oKoY0e+oCF/wOUp3np8DOJDORv9aVb4q/uI8gFGZYzQyB+Aiaa 0Ba7RQFoKbqiLs7alKSfI9uPDfZyg+JIe2Kd3FfBzIB9s6m0pgEISf0aLhtUY7kW02yF1KakMzd qyxOekepK263xVLT01sCvSaWRixIjYVbmVzlskT1jhsev+AT2RNEDkXJW0mXl6VFo58P/HrOO/O BnsurRPyQq5BHcxctEKv5Jn3TgsRKfjuE2/34peBKVtOyel0defroTjviMAi+k57cQ1/pFc1s3o NIoviaW24DnyyJGIqYXDy29gJKK0hOplWxtmQaD94d5NbC92INpvpLwuXR X-Received: by 2002:a0c:e6e9:0:b0:8cc:cdc1:fe97 with SMTP id 6a1803df08f44-8cee5ffe964mr277481866d6.19.1781039172476; Tue, 09 Jun 2026 14:06:12 -0700 (PDT) Received: from localhost ([2804:14d:328a:a59c:6551:f299:454e:9985]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8ceccdb8dadsm214394966d6.12.2026.06.09.14.06.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 09 Jun 2026 14:06:12 -0700 (PDT) Content-Type: multipart/mixed; boundary=a10abe3a9b71d501f39967ebb75d1dba43571e753d9b1cf57a95d87e101a Mime-Version: 1.0 Date: Tue, 09 Jun 2026 18:06:09 -0300 Message-Id: Subject: Re: Autoprewarm workers terminated due to a segmentation fault From: "Matheus Alcantara" To: "Glauber Batista" , X-Mailer: aerc 0.21.0 References: In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --a10abe3a9b71d501f39967ebb75d1dba43571e753d9b1cf57a95d87e101a Content-Type: multipart/alternative; boundary=9a41f06ce25d6b3d60c1164a9575139f2a7e6b9225c1f41c3b431fa53503 --9a41f06ce25d6b3d60c1164a9575139f2a7e6b9225c1f41c3b431fa53503 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Content-Type: text/plain; charset=UTF-8 Hi, On Tue Jun 9, 2026 at 3:37 PM -03, Glauber Batista wrote: > I have an issue with the autoprewarm workers segfaulting during the servi= ce > restart. Sometimes, it successfully restarts after a few tries, but usual= ly > I need to remove the autoprewarm.blocks file. My setup consists of a > primary server with two replicas and all of them present the same issue. = I > have been using this setup for several years with no issues, but since I > upgraded to Postgres 18 I'm having it. This is a production database. > > Details: > > [ ... ]=20 > > All that said, it seems there's a missing guard-clause at line 649. I > didn't spend much time reading the code, but it's clearly accessing a > position in the array that is not allocated. > Thank you for the report! I've managed to reproduce the issue with the following: create table test_warm (id int, data text); -- insert enough rows to generate too many pages on an index insert into test_warm select g, repeat('a', 100) from generate_series(1, 50= 00000) g; create index warm_idx on test_warm(id); -- force read the index entirely into shared_buffers select count(*) from test_warm where id > 0; Then pg_ctl stop and pg_ctl start will start failing with the following log= s: 2026-06-09 17:47:40.924 -03 [23025] LOG: shutting down 2026-06-09 17:47:40.925 -03 [23025] LOG: checkpoint starting: shutdown fas= t 2026-06-09 17:47:41.033 -03 [23022] LOG: database system is shut down 2026-06-09 17:47:49.830 -03 [23172] LOG: starting PostgreSQL 19beta1 on aa= rch64-darwin, compiled by clang-17.0.0, 64-bit 2026-06-09 17:47:49.842 -03 [23172] LOG: database system is ready to accep= t connections 2026-06-09 17:47:49.917 -03 [23172] LOG: background worker "autoprewarm wo= rker" (PID 23182) was terminated by signal 11: Segmentation fault: 11 2026-06-09 17:47:49.917 -03 [23172] LOG: terminating any other active serv= er processes 2026-06-09 17:47:49.918 -03 [23172] LOG: all server processes terminated; = reinitializing Wondering if the following would be enough? /* Advance i past all the blocks just prewarmed. */ i =3D p.pos; + if (i >=3D apw_state->prewarm_stop_idx) + break; + blk =3D block_info[i]; With this change on a fresh start I got very similar shared hit buffers on the first and second execution, so I think that the autoprewarm.blocks was reloaded successfully? postgres=3D# explain(analyze, costs off, timing off, summary off) select co= unt(*) from test_warm where id > 0; QUERY PLAN ---------------------------------------------------------------------------= -------- Finalize Aggregate (actual rows=3D1.00 loops=3D1) Buffers: shared hit=3D15965 read=3D70242 -> Gather (actual rows=3D3.00 loops=3D1) Workers Planned: 2 Workers Launched: 2 Buffers: shared hit=3D15965 read=3D70242 -> Partial Aggregate (actual rows=3D1.00 loops=3D3) Buffers: shared hit=3D15965 read=3D70242 -> Parallel Seq Scan on test_warm (actual rows=3D1666666.67= loops=3D3) Filter: (id > 0) Buffers: shared hit=3D15965 read=3D70242 postgres=3D# explain(analyze, costs off, timing off, summary off) SELECT co= unt(*) FROM test_warm WHERE id > 0; QUERY PLAN ---------------------------------------------------------------------------= -------- Finalize Aggregate (actual rows=3D1.00 loops=3D1) Buffers: shared hit=3D15970 read=3D70237 -> Gather (actual rows=3D3.00 loops=3D1) Workers Planned: 2 Workers Launched: 2 Buffers: shared hit=3D15970 read=3D70237 -> Partial Aggregate (actual rows=3D1.00 loops=3D3) Buffers: shared hit=3D15970 read=3D70237 -> Parallel Seq Scan on test_warm (actual rows=3D1666666.67= loops=3D3) Filter: (id > 0) Buffers: shared hit=3D15970 read=3D70237 Thoughts? -- Matheus Alcantara EDB: https://www.enterprisedb.com --9a41f06ce25d6b3d60c1164a9575139f2a7e6b9225c1f41c3b431fa53503-- --a10abe3a9b71d501f39967ebb75d1dba43571e753d9b1cf57a95d87e101a Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename=0001-Fix-out-of-bounds-access-in-autoprewarm-worker.patch Content-Type: text/plain; charset=utf-8; name=0001-Fix-out-of-bounds-access-in-autoprewarm-worker.patch RnJvbSA2YTNlM2UyNmMwMzI4ZTE1ZmM0NzA5MTY4NDE0M2RjNWJiOGVmNmZjIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBNYXRoZXVzIEFsY2FudGFyYSA8bXRocy5kZXZAcG0ubWU+CkRh dGU6IFR1ZSwgOSBKdW4gMjAyNiAxNzo1OToyMC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