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 1tQTYJ-002qSd-1F for pgsql-bugs@arkaria.postgresql.org; Wed, 25 Dec 2024 15:44:03 +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 1tQTYI-00ECvt-3p for pgsql-bugs@arkaria.postgresql.org; Wed, 25 Dec 2024 15:44:01 +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 1tQTYH-00ECvl-RX for pgsql-bugs@lists.postgresql.org; Wed, 25 Dec 2024 15:44:01 +0000 Received: from relay4-d.mail.gandi.net ([2001:4b98:dc4:8::224]) by makus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tQTYF-000WO5-1D for pgsql-bugs@lists.postgresql.org; Wed, 25 Dec 2024 15:44:00 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 9A368E0004; Wed, 25 Dec 2024 15:43:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vondra.me; s=gm1; t=1735141435; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1dfHGOHgWUY/GWE15keUzrKOWUmVqpPmiaaic+DZGw4=; b=A02pwM0FfMqXtBx0yideDboKN3SBuGcu8FkOJJw5k++vZhiltW2Wbf2XDtX04CNjvOifPW qJ4AL0KOpj9zKbQ6GuyJYKgeZYAzFNgvxPCxzW0hbAWnNgJlM7r+XpXseEANK8wIEbdG7L 0GYt4pp/TY5Dr0bgM5WYvwGrz6DCLkiKmNE9zkbOPICixbPe8xFRMm1EDwFtoGxQ53eAcW AYTJwsWy6urBlT1G1PoCByBLRpdj7m8BQVzc3AQOYddF8/rTdNSoZPWRMOE9KnHwWgWYSu e7n8AdRqgXJAgENdn8d4AKO9LbOWak0HGYZtCTHruU6jFR//jPOnLRsB5cH4Yg== Message-ID: <500cd0ea-8bbf-469d-a2cf-265350191129@vondra.me> Date: Wed, 25 Dec 2024 16:43:53 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Corrupt index lead to skipped autovacuum To: =?UTF-8?B?6auY5YGJ6Yie?= , pgsql-bugs@lists.postgresql.org References: Content-Language: en-US From: Tomas Vondra In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-GND-Sasl: tomas@vondra.me List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 12/24/24 06:43, 高偉鈞 wrote: > Postgres version: postgres (PostgreSQL) 16.3 (Ubuntu > 16.3-1.pgdg20.04+1) Related extension: vector | 0.6.2 | > public | vector data type and ivfflat and hnsw access methods > > We have a database running with vector extension and somehow one of > the index is corrupted. During autovacuum the following message > shows up: > > different vector dimensions 256 and 0 while vacuuming index > "ai_user_embedding_idx" of relation "public.ma_ai_aiuser" automatic > vacuum of table "analytics_vector.public.ma_ai_aiuser" > > The problem is that after this error, the autovacuum process seems > to stop here. All other tables and indexes are left unvacuumed even > if they already exceed emergency vacuum threshold. Once we reindex > the index, autovacuum starts to work properly. > > We will expect the autovacuum will continue to vacuum other tables/ > indexes and maybe mark the index as invalid? We don't have such logic to automatically disable corrupted indexes (or suspected to be). I don't know how feasible such behavior is - it may seem simple, but in my experience there often are many corner cases that make it unexpectedly tricky. E.g. it might be a bad idea to disable indexes supporting constraints, because that would cause a complete outage (while now the impact is limited to the corrupted pages). For now, the best thing you can do is to monitor the system for unexpected ERRORs and vacuum performing cleanup as needed, and if the autovacuum fails (which should be very rare) either rebuild the index or do vacuum with index_cleanup OFF. > Skip vacuum for all other indexes / tables can be quite dangerous if > un-noticed. > If you don't notice failing vacuum / ERRORs about data corruption and that vacuum is falling behing, why would you notice some indexes got disabled? Surely corrupted indexes can lead to all kinds of serious problems ... regards -- Tomas Vondra