Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1moIlq-00063K-Q2 for pgsql-hackers@arkaria.postgresql.org; Sat, 20 Nov 2021 05:18:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1moIlp-0003uP-08 for pgsql-hackers@arkaria.postgresql.org; Sat, 20 Nov 2021 05:18:37 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1moIlo-0003uF-Fq for pgsql-hackers@lists.postgresql.org; Sat, 20 Nov 2021 05:18:36 +0000 Received: from mail-oi1-x232.google.com ([2607:f8b0:4864:20::232]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1moIlg-0007Ry-Im for pgsql-hackers@postgresql.org; Sat, 20 Nov 2021 05:18:35 +0000 Received: by mail-oi1-x232.google.com with SMTP id bf8so25922457oib.6 for ; Fri, 19 Nov 2021 21:18:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=FR7F/LRFYE1gYPLTNJuU+9biQMItcusxI5aaFP7nz/s=; b=Ftgdhn1jelENeSyQzV5OAgnh5J4oEga84iLtjCVhCmZgwzSJRZI13vxCqIH2cl6IQn +RzG+Vblcjt5KHnnTUZ6I+MVCQCmZxfJiLMLC4SH8grEx867ns+rij3xM/bejRDgd3D5 TAEPcEcRdzbAs5c0eWxnoyZukRVvasMjuArzw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=FR7F/LRFYE1gYPLTNJuU+9biQMItcusxI5aaFP7nz/s=; b=smAHX8LFhLHAV9HE4SOyAfnRTBzWI+qjGXTWbmtK7Cp3InGTPubn5kAM+ZOsTWgb3/ lC/RbCfFl+nyVGJTBH58ttukq4QN6nmhe9xSUm8bPkO2ZTXxTOYwm6KdmPdI+3aaSUk9 8Y1OOuk4yrlbcmYOhmh13BBYKuTj22SWBeU+lxxHQELi3a39j08/1zmBIxFjLZA1L5+N K6ro0wlA56VtATPEaZmfSQc40EBCDJSbsN0MULSqVipwRSSW1ym3RvgRDYFPwsdAIf+X wVXMauRAsV24zfXXqJbyPMFisWM7L7rwCXTAoiB+mVd0SP/TBOjJYBDm/tYhH3SW+O7I obNQ== X-Gm-Message-State: AOAM532ATHdbDVXfQ5wGfaz2ZxG5t0BJZJXKKQZ+feoNpxQ8lqydsTow Jp5gAkmcy858vagn7A1jDuyjig== X-Google-Smtp-Source: ABdhPJxxrSmU1vOhe8IZrAG7tBpQCVafGF4Bh0uOfAJYVSzdDY1IaxCwSiriUd7WouiRbL5AkOXFqg== X-Received: by 2002:aca:c647:: with SMTP id w68mr5023380oif.79.1637385506553; Fri, 19 Nov 2021 21:18:26 -0800 (PST) Received: from rfd.leadboat.com ([2600:1702:a20:5750::46]) by smtp.gmail.com with ESMTPSA id o10sm374882oom.32.2021.11.19.21.18.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Nov 2021 21:18:25 -0800 (PST) Date: Fri, 19 Nov 2021 21:18:23 -0800 From: Noah Misch To: pgbf@twiska.com Cc: Tom Lane , Michael Paquier , pgsql-hackers@postgresql.org Subject: Re: XLogReadRecord() error in XlogReadTwoPhaseData() Message-ID: <20211120051823.GA1367142@rfd.leadboat.com> References: <20211107013157.GB790288@rfd.leadboat.com> <20211112012234.GA1020314@rfd.leadboat.com> <2782601.1637189230@sss.pgh.pa.us> <20211118070506.GA1294133@rfd.leadboat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211118070506.GA1294133@rfd.leadboat.com> User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Nov 17, 2021 at 11:05:06PM -0800, Noah Misch wrote: > On Wed, Nov 17, 2021 at 05:47:10PM -0500, Tom Lane wrote: > > Noah Misch writes: > > > Each of the three failures happened on a sparc64 Debian+gcc machine. I had > > > tried ~8000 iterations on thorntail, another sparc64 Debian+gcc animal, > > > without reproducing this. > > > # 'pgbench: error: client 0 script 1 aborted in command 4 query 0: ERROR: could not read two-phase state from WAL at 0/159EF88: unexpected pageaddr 0/0 in log segment 000000010000000000000001, offset 5890048 > > [1] https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=tadarida&dt=2021-11-17%2013%3A01%3A24 > > Two others: > ERROR: could not read two-phase state from WAL at 0/16F1850: invalid record length at 0/16F1850: wanted 24, got 0 > -- https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=tadarida&dt=2021-11-12%2013%3A01%3A15 > ERROR: could not read two-phase state from WAL at 0/1668020: incorrect resource manager data checksum in record at 0/1668020 > -- https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=kittiwake&dt=2021-11-16%2015%3A00%3A52 > > > I suppose "unexpected pageaddr 0/0" is most easily explained by supposing > > that XlogReadTwoPhaseData tried to read a WAL page that hadn't been > > written out yet. Have we got any synchronization around that? > > If the WAL address isn't on disk, that error doesn't happen. Instead, > read_local_xlog_page() blocks waiting for the WAL to become available. It's > still possible that we make the WAL region exist, but it somehow doesn't > contain the right data until shortly later. FinishPreparedTransaction() takes > TwoPhaseStateLock and looks for an entry having gxact->valid. EndPrepare() > fills gxact->prepare_end_lsn, then calls MarkAsPrepared() to set gxact->valid > under TwoPhaseStateLock. All freelist (freeGXacts) interaction holds > TwoPhaseStateLock. I'm not seeing a gap in that synchronization. > > I don't have a great theory, but here are candidates to examine next: > > - Run with wal_debug=on to confirm logged write location matches read location. > - Run "PGDATA=contrib/amcheck/tmp_check/t_003_cic_2pc_CIC_2PC_test_data/pgdata > pg_waldump -s 0/01000000" at the end of the test. > - Dump WAL page binary image at the point of failure. > - Log which branches in XLogReadRecord() are taken. Tom Turelinckx, are you able to provide remote access to kittiwake or tadarida? I'd use it to attempt the above things. All else being equal, kittiwake is more relevant since it's still supported upstream. The setup of your buildfarm animals provides a clue. I understand kittiwake is the same as ibisbill except for build options, and tadarida is the same as mussurana except for build options. ibisbill and mussurana haven't failed, so one of these is likely needed to reproduce: absence of --enable-cassert CFLAGS='-g -O2 -fstack-protector -Wformat -Werror=format-security ' CPPFLAGS='-Wdate-time -D_FORTIFY_SOURCE=2' LDFLAGS='-Wl,-z,relro -Wl,-z,now' However, I can't reproduce this on thorntail, even if I use tadarida's ./configure options, CFLAGS, CPPFLAGS, and LDFLAGS.