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 1qEC6g-00047A-FO for pgsql-bugs@arkaria.postgresql.org; Tue, 27 Jun 2023 17:03:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1qEC6e-0000xo-CX for pgsql-bugs@arkaria.postgresql.org; Tue, 27 Jun 2023 17:03:56 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qEC6e-0000xd-1V for pgsql-bugs@lists.postgresql.org; Tue, 27 Jun 2023 17:03:56 +0000 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qEC6a-000lif-Gn for pgsql-bugs@lists.postgresql.org; Tue, 27 Jun 2023 17:03:54 +0000 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1b80512a7f2so16147775ad.3 for ; Tue, 27 Jun 2023 10:03:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687885431; x=1690477431; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=DcYAM7Dcieeg3wDYF7B7Z1needPu5Ha8QUHqDIgdXaw=; b=JwFDqCzqwfGG0z0rKuSJbN5MT3lQXp76x5/lG/IGbyF3kkqIJJdqDDPCInW4d6nhPw veZ0VYo9XONxrXbq2av7Gb31w71xcoWl6vyk+dkCbZgb2B3l3GSahCGP8PBnyElqtyFA 9Pg5OFmPdaWOyTqTXfCVH3vOuU1rdrMfOYDCyLRPac6F4k0lASog0fHV25ckiBpvctaF xcj4HhNkkG4oIHp+V6150iijOIh3MHnKE88pMRWUsJxXeDOnLGHdQlbAQDGkxBBa2C7U jsK0cXLG3XYJQANPqZE7xJTCJgXZBpXotqSXeho4N2izIHrWi4m4UHnrD8G9xbguk+Z8 NUNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687885431; x=1690477431; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=DcYAM7Dcieeg3wDYF7B7Z1needPu5Ha8QUHqDIgdXaw=; b=EGvHxBjSHMVBbROs0NJe4P++W1FhDlT1RdeeK5RZ016S8wOKkLh2n6TQz5j1LRhgYF UQ23VzcOvOpGb1HZQRZcnqaKfBmtg40jT0qYd52l5xAZLeu1hIGmlFwDIf0Wz8KJGN9Y uMCZ5Vzf5P9cylPuMvd4z9Rtx5MVxKOfvNlrtq2gc/vzNyzzsq6m6bQOq2e7TQ10neZi g5oaM3XR6VXZwxWIS7GUtu1FYRoMEiPmoxIifF95XctJtyaaFo88oVM4Ws8DuoDOyOu9 uJ1BSN/Q4xZpPkTA51RZ+/f9S8ZWftT+FHtUQMRzz8Cu1UMmdXDk3puwxmHSxkrFNdWo RwDg== X-Gm-Message-State: AC+VfDyRE2EGiYgVZgvxaN8XKkBcu/roTHGrzPsQWGV7EQ3Kd4MLlFcO XW46Ej2LBxdM0qTuCoBIbfs= X-Google-Smtp-Source: ACHHUZ4ckaOl8X41TJMvYiTr5NEnzxuFtEvJ5e3yISlhhlVDxTrQ2HgD9GwXqahuhQFV120IhsOu3w== X-Received: by 2002:a17:902:ce90:b0:1b2:48c:4db with SMTP id f16-20020a170902ce9000b001b2048c04dbmr9536067plg.38.1687885431372; Tue, 27 Jun 2023 10:03:51 -0700 (PDT) Received: from nathanxps13 ([50.47.162.83]) by smtp.gmail.com with ESMTPSA id j18-20020a170902da9200b001b03a1a3151sm6215996plx.70.2023.06.27.10.03.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 10:03:50 -0700 (PDT) Date: Tue, 27 Jun 2023 10:03:48 -0700 From: Nathan Bossart To: Michael Paquier Cc: exclusion@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18000: Access method used by matview can be dropped leaving broken matview Message-ID: <20230627170348.GA1461334@nathanxps13> References: <18000-9145c25b1af475ca@postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Jun 27, 2023 at 01:50:15PM +0900, Michael Paquier wrote: > In order to do something about that, I think that we should just do > something similar to schema changes where we switch the dependency > with a changeDependencyFor(), and that the best spot is > swap_relation_files(), where the pg_class tuple of the old relation > has its persistence, tablespace and AM updated according to the > rewrite. One reason is that there were discussions where it could > make sense to update a table AM on CLUSTER or VACUUM, for example, so > that would cover this spot, but that's only hypothetical currently. Agreed. > The path of a relation rewrite cares also about tablespaces, however > only shared dependency entries for relations without storage matter, > so as a tablespace is not dropped when it should not. That's where > SetRelationTableSpace() does this work. I looked into the tablespace path, too. Since materialized views have storage, we don't have to worry about ALTER MATERIALIZED VIEW SET TABLESPACE losing the dependency records (that IIUC won't exist anyway), as dropping the tablespace will fail because it won't be empty. This feels kind of fragile, but I don't have a better proposal at the moment. > (Note that a patch has been recently proposed to add AMs to > partitioned tables, which I think is also impacted by the same issue, > and we would need to be more careful in this second case, but that's > work for 17~). I haven't looked at the patch, but assuming it's not calling finish_heap_swap(), it might be okay. But it does seem prudent to check that the dependency records are handled correctly. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com