Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hnotY-0003MN-3W for pgsql-general@arkaria.postgresql.org; Wed, 17 Jul 2019 18:43:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hnotW-0006lf-Ja for pgsql-general@arkaria.postgresql.org; Wed, 17 Jul 2019 18:43:14 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hnotW-0006hx-8p for pgsql-general@lists.postgresql.org; Wed, 17 Jul 2019 18:43:14 +0000 Received: from mail-qk1-x743.google.com ([2607:f8b0:4864:20::743]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hnotS-0004dC-Sh for pgsql-general@postgresql.org; Wed, 17 Jul 2019 18:43:13 +0000 Received: by mail-qk1-x743.google.com with SMTP id t8so18362129qkt.1 for ; Wed, 17 Jul 2019 11:43:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=qokA4fL+om4gwxRi6CY4na9wo1LKUzQT/SFvb6OOD4s=; b=SuremUSett7jG9PA9gAGCGhJGlFigsGnjP2x7pbwv+dG7TODnSXWttjB0PhD3wJO6w YHBr9xw8Sxg0PB2oKkW9XWGlbe95vfCdOyyd+YbcMqrphQJwNRxprnZ0L0gVe5wwIpHH SLPIwqfmqtfwKS9JXA7YkGZttg8V+h6EDpcVRtBzH6GSlrMXVFNjsv73GodIZM72N8RJ sQNJv4IOJHoCK/KqchmN9pt9G/ofQWOexwb6hs1pPJ6IdXlWC/EKKHGq6knA0rkiUtqI Kx6k69Acez/fprB5U7YcusM+bhCX9h9ChzSvDlhbQ/vYF1rAqypYBzf7WxiVPmQdfZOv S7Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=qokA4fL+om4gwxRi6CY4na9wo1LKUzQT/SFvb6OOD4s=; b=k/nNZzVc1e1ePpxkJgGS2LgloA9Ga6XS5kdjZdl9H6k7tPeZYtFxDiaB9haH+bgFx2 EjM57Ddk8VAM64Jyg3z+wG4tcfiefgj7imdVuT0/Uw6YMI+DJ9vNSk5ZXXRiEyhsWB8y yHzSkAWfb6ih4wLV/4loj8ZjDDkbCJSd5woON1eiKEiCJ4kVi2O1hGcLeSIM/GSPsy/B mHKGLpCTyjvGgPZaM8+ktbLxhhjTZjZhpk4v0M/LS/vOzrdZ5/SPYsDmjn8lN/G3XaE+ C/m8xVaqkyIRZjjBvvuWJ2QMUnP+ksccbr7TDpHOgkVA2zA9VbuWdvb70gLeHx8UMpzb OZqQ== X-Gm-Message-State: APjAAAVmnjuHdGsSkcsv/qE5u6FGBZf99I1B6NhLzfSMK19Q+tlptzS+ 86TwP5u8I2+9fic26O28tJSRBQ== X-Google-Smtp-Source: APXvYqw4PHmcx/HtGppOMvrbYzY6TcM5qmwMlT5NsIIPoc1rbii3UcBb5zVtYc5FosIOrL8Llbgczg== X-Received: by 2002:a37:e40a:: with SMTP id y10mr26972484qkf.134.1563388989259; Wed, 17 Jul 2019 11:43:09 -0700 (PDT) Received: from nimloth.alvh.no-ip.org ([177.154.139.198]) by smtp.gmail.com with ESMTPSA id p23sm11750960qke.44.2019.07.17.11.43.08 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 17 Jul 2019 11:43:08 -0700 (PDT) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 8D74F1202CC; Wed, 17 Jul 2019 14:43:05 -0400 (-04) Date: Wed, 17 Jul 2019 14:43:05 -0400 From: Alvaro Herrera To: Tom Lane Cc: Peter Geoghegan , Aaron Pelz , pgsql-general General Subject: Re: Corrupt index stopping autovacuum system wide Message-ID: <20190717184305.GA25848@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <31751.1563388222@sss.pgh.pa.us> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2019-Jul-17, Tom Lane wrote: > Alvaro Herrera writes: > > On 2019-Jul-17, Peter Geoghegan wrote: > >> Maybe nbtree VACUUM should do something more aggressive than give up > >> when there is a "failed to re-find parent key" or similar condition. > >> Perhaps it would make more sense to make the index inactive (for some > >> value of "inactive") instead of just complaining. That might be the > >> least worst option, all things considered. > > > Maybe we can mark an index as unvacuumable in some way? As far as I > > understand, all queries using that index work, as do index updates; it's > > just vacuuming that fails. If we mark the index as unvacuumable, then > > vacuum just skips it (and does not run phase 3 for that table), and > > things can proceed; the table's age can still be advanced. Obviously > > it'll result in more bloat than in normal condition, but it shouldn't > > cause the whole cluster to go down. > > If an index is corrupt enough to break vacuum, I think it takes a rather > large leap of faith to believe that it's not going to cause problems for > inserts or searches. Maybe, but it's what happened in the reported case. (Note Aaron was careful to do the index replacement concurrently -- he wouldn't have done that if the table wasn't in active use.) > I'd go with just marking the index broken and > insisting that it be REINDEX'd before we touch it again. This might make things worse operationally, though. If searches aren't failing but vacuum is, we'd break a production system that currently works. > (a) once the transaction's failed, you can't go making catalog updates; Maybe we can defer the actual update to some other transaction -- say register an autovacuum work-item, which can be executed separately. > (b) even when you know the transaction's failed, blaming it on a > particular index seems a bit chancy; Well, vacuum knows what index is being processed. Maybe you're thinking that autovac can get an out-of-memory condition or something like that; perhaps we can limit the above only when an ERRCODE_DATA_CORRUPTED condition is reported (and make sure all such conditions do that. As far as I remember we have a patch for this particular error to be reported as such.) > (c) automatically disabling constraint indexes seems less than desirable. Disabling them for writes, yeah. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services