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.94.2) (envelope-from ) id 1rINtl-008EB0-11 for pgsql-bugs@arkaria.postgresql.org; Wed, 27 Dec 2023 07:00:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rINtj-002UZQ-Hp for pgsql-bugs@arkaria.postgresql.org; Wed, 27 Dec 2023 07:00:11 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rINtj-002UZH-4h for pgsql-bugs@lists.postgresql.org; Wed, 27 Dec 2023 07:00:11 +0000 Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rINtd-00CP4B-I2 for pgsql-bugs@lists.postgresql.org; Wed, 27 Dec 2023 07:00:09 +0000 Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-50e7d6565b5so1504319e87.0 for ; Tue, 26 Dec 2023 23:00:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703660404; x=1704265204; darn=lists.postgresql.org; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to; bh=9FdnLeA2uootLXSU0Jxg6pBFHZ6d2l6ty+EovCzhRKY=; b=klJWst4BlLkNryHsl60nQLidpQEDhAQPMNXGP+96Y40cokUVso0SobUXZFUdI6slKT vhkREkKfSRNY61GTR7sa8Z1KJGqE9lC7pG7h0GmuD7GqFOlSN1+9StMHTNvdbtKMqZ9q X6j6fkNrLkmg92awk5tax4r+a1MpaIOKoD+MDzV42plYutyBQ8IpJiK35OxHeMbT4KgP f0uhww6BYBKXzEoxDC2hxuZhv/YMXwJMnJFhEOxseYu81UX8qsG+RFO5qb+BIhW0rIEb QHOchR2HpKc2rFf2GNN/j0WYhV42pLj7gniBm9FQ9xUV8/XPFl0gbFY7JSnT1l9ObwzZ phDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703660404; x=1704265204; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=9FdnLeA2uootLXSU0Jxg6pBFHZ6d2l6ty+EovCzhRKY=; b=bS0vvxp819k5UQ1x/UJQDyB06emhO0qV2xPqhtOHWvT7YAamYXj+cOvm+mbbxkn+F1 tUj3Httv6WTznRmRn+r1ujLg37jY4buNbbuadZpCmFTfpCSk1mfHZ/ngD57I/eFdXa/Z rF+ERORrTHcOje3cvlK50u/0bd3+oaf9mgNPYYEkvhrU6SPJGgxJiNKWLUhpsK2BC6By BPKwKTyMyhN7pMSb2g6+Ay9Hh5HyH3ZTG0hhlZewhAwUfsKCTHPYN4YJSg2bOTp84tTV Agz5zUepAO13btIcsLsumXhiI7zaoQ4WcXf/wKM2Okv1NGgMotlaZsHziSOBt69XnCg/ JaTA== X-Gm-Message-State: AOJu0Yzn4vX+1NvV1U+fFFYCiUtlJ8pggNwGHf4fWGnDt9uoMCV4NDju YPSqUUNk+hF4M9ICwrCMv+I= X-Google-Smtp-Source: AGHT+IEXTnEHWxIIE8bnjDd16q7CObLhw61/XpjjFi29giobTVJAJMUAslht4l3umDiUtKD00wS/pw== X-Received: by 2002:a05:6512:398a:b0:50e:7ab3:6b00 with SMTP id j10-20020a056512398a00b0050e7ab36b00mr1755001lfu.112.1703660403366; Tue, 26 Dec 2023 23:00:03 -0800 (PST) Received: from [1.0.0.7] ([178.155.19.179]) by smtp.gmail.com with ESMTPSA id o10-20020ac24bca000000b0050e7687ee2dsm1157231lfq.65.2023.12.26.23.00.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 26 Dec 2023 23:00:02 -0800 (PST) Content-Type: multipart/alternative; boundary="------------vC4nwfYQCCgAkNe7Spcn0JjI" Message-ID: <09677462-ed4c-2b2c-7918-8a3961dc772a@gmail.com> Date: Wed, 27 Dec 2023 10:00:00 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: BUG #18259: Assertion in ExtendBufferedRelLocal() fails after no-space-left condition Content-Language: en-US To: tender wang , pgsql-bugs@lists.postgresql.org, Andres Freund References: <18259-6e256429825dd435@postgresql.org> From: Alexander Lakhin In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------vC4nwfYQCCgAkNe7Spcn0JjI Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hello tender wang, 26.12.2023 19:55, tender wang write: > I tried to analyze the issue, and I found that it might be caused by this commit: > commit dad50f677c42de207168a3f08982ba23c9fc6720 >        bufmgr: Acquire and clean victim buffer separately > Thanks for looking into it! > ... > > With debug logging added in this code within ExtendBufferedRelLocal(): >         if (found) >         { >             BufferDesc *existing_hdr = > GetLocalBufferDescriptor(hresult->id); >             uint32      buf_state; > > UnpinLocalBuffer(BufferDescriptorGetBuffer(victim_buf_hdr)); > >             existing_hdr = GetLocalBufferDescriptor(hresult->id); >             PinLocalBuffer(existing_hdr, false); >             buffers[i] = BufferDescriptorGetBuffer(existing_hdr); > >             buf_state = pg_atomic_read_u32(&existing_hdr->state); >             Assert(buf_state & BM_TAG_VALID); >             Assert(!(buf_state & BM_DIRTY)); >             buf_state &= BM_VALID; > pg_atomic_unlocked_write_u32(&existing_hdr->state, buf_state); > ... > I see that it reached for the second INSERT (and NOSPC error) with > existing_hdr->state == 0x2040000, but for the third INSERT I observe > state == 0x0. > I wonder, if "buf_state &= BM_VALID" is a typo here, maybe it supposed to be "buf_state &= ~BM_VALID" as in ExtendBufferedRelShared()... Best regards, Alexander --------------vC4nwfYQCCgAkNe7Spcn0JjI Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
Hello tender wang,

26.12.2023 19:55, tender wang write:
I tried to analyze the issue, and I found that it might be caused by this commit:
commit dad50f677c42de207168a3f08982ba23c9fc6720
       bufmgr: Acquire and clean victim buffer separately


Thanks for looking into it!

...

With debug logging added in this code within ExtendBufferedRelLocal():
        if (found)
        {
            BufferDesc *existing_hdr =
GetLocalBufferDescriptor(hresult->id);
            uint32      buf_state;

            UnpinLocalBuffer(BufferDescriptorGetBuffer(victim_buf_hdr));

            existing_hdr = GetLocalBufferDescriptor(hresult->id);
            PinLocalBuffer(existing_hdr, false);
            buffers[i] = BufferDescriptorGetBuffer(existing_hdr);

            buf_state = pg_atomic_read_u32(&existing_hdr->state);
            Assert(buf_state & BM_TAG_VALID);
            Assert(!(buf_state & BM_DIRTY));
            buf_state &= BM_VALID;
            pg_atomic_unlocked_write_u32(&existing_hdr->state, buf_state);
...
I see that it reached for the second INSERT (and NOSPC error) with
existing_hdr->state == 0x2040000, but for the third INSERT I observe
state == 0x0.


I wonder, if "buf_state &= BM_VALID" is a typo here, maybe it supposed to be
"buf_state &= ~BM_VALID" as in ExtendBufferedRelShared()...

Best regards,
Alexander
--------------vC4nwfYQCCgAkNe7Spcn0JjI--