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 1pN4kx-00018i-0E for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Feb 2023 04:29:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pN4ku-00053Q-Pz for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Feb 2023 04:29: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 1pN4ku-00053H-Ch for pgsql-hackers@lists.postgresql.org; Wed, 01 Feb 2023 04:29:56 +0000 Received: from mail-il1-x12a.google.com ([2607:f8b0:4864:20::12a]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pN4kq-0006Bq-K3 for pgsql-hackers@lists.postgresql.org; Wed, 01 Feb 2023 04:29:55 +0000 Received: by mail-il1-x12a.google.com with SMTP id k12so2414138ilv.10 for ; Tue, 31 Jan 2023 20:29:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20210112.gappssmtp.com; s=20210112; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=v6tzHjHnZmxd9U+nx4SWrLO8DnLiihgvJm68X9sh0EY=; b=zDys7Z2tSNMxJBRrsMa+oQlVKydWLEshcZklHjxg1VBHiYfiA165N5SgZ5tgLcyLoN 5m8JXimBPkv4oBbcRpZAI0bVkbJOqgwJrcNAt5CEDgnN3C8/oHE9oqszXLY7EOAW9z7B VqVpsVdNkJcxYKweYEZQoJy+G8tnhenX3jfE9R14BIf7760b7DzBEN52PysWGQKJ2u6y cyZgXbkIx6GtAVr+n9W0aXzawdn2Jm/TmV9ou5x/d7VI5uULuS33nbGS078vMZneeK4z wVFjfMKcjausTIlnUdigXs8vELnTtYH29bE7Vy1DNzzEa9jzokruyNxL8FmtISnJOnMf NcNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=user-agent:in-reply-to:content-transfer-encoding :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=v6tzHjHnZmxd9U+nx4SWrLO8DnLiihgvJm68X9sh0EY=; b=RNpcJB5lSwzvKtVRdAWrbATl4MjaFxFVrvNih8oil8bDfb9QuY1Q90Wvw24cjYTELi dBUjzb1pw9Xe8pemkXR5Jo+JHDmYJ6U8cxEOkxQtQ+67O0FBISyWlP6lRU6dakwTAmfz tFJMrymTp1PgwxwXmfQOdkOMPjij3qcxtdEaTeoLfvAb4mC5PrBbnCFHvV2vKmahJYqq rmGuGseX3u6OaT/fe0VcuLpizc/wgJ5r+VejWu7azudgTojqDo0hq3sQShTLTRYH21Fw qq1VTDa1TGjrpXIlPKeVZKv8YpNjXZ34zFnhtGe9jOPpzCs//0/OqYU5rCvdzNGpBA6A WSJg== X-Gm-Message-State: AO0yUKV5Ia7oE00JFGzNsiWic1Wn4UzFp7OL1JWHg29ywol2ABosoHGH SeIf5tCumHnxbT1WyH4dZBLh3w== X-Google-Smtp-Source: AK7set81FS44M1DaDZekOx18LGIxmMqGs2KQNBabzrEk61tDcp6FU6Sqp9wQsRMOmlPF9V2+QGVYqw== X-Received: by 2002:a05:6e02:1746:b0:310:fbaa:192b with SMTP id y6-20020a056e02174600b00310fbaa192bmr754603ill.30.1675225791755; Tue, 31 Jan 2023 20:29:51 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id b3-20020a92c563000000b0030ef5881a51sm2925846ilj.34.2023.01.31.20.29.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 20:29:51 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 696C0800983; Tue, 31 Jan 2023 22:29:49 -0600 (CST) Date: Tue, 31 Jan 2023 22:29:49 -0600 From: Justin Pryzby To: Ilya Gladyshev Cc: Tomas Vondra , pgsql-hackers@lists.postgresql.org Subject: Re: Progress report of CREATE INDEX for nested partitioned tables Message-ID: <20230201042949.GQ22427@telsasoft.com> References: <039564d234fc3d014c555a7ee98be69a9e724836.camel@gmail.com> <20221217143002.GR1153@telsasoft.com> <20230108164849.GA21731@telsasoft.com> <865a4ff239b6824fd5bbdd4a972390d1e95144b4.camel@gmail.com> <31ee17da-8705-9afc-9451-5374a5e51aff@enterprisedb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Jan 31, 2023 at 07:32:20PM +0400, Ilya Gladyshev wrote: > > 17 янв. 2023 г., в 23:44, Tomas Vondra написал(а): > > Do we actually need the new parts_done field? I mean, we already do > > track the value - at PROGRESS_CREATEIDX_PARTITIONS_DONE index in the > > st_progress_param array. Can't we simply read it from there? Then we > > would not have ABI issues with the new field added to IndexStmt. > > I think it’s a good approach and it could be useful outside of scope of this patch too. So I have attached a patch, that introduces pgstat_progress_incr_param function for this purpose. There’s one thing I am not sure about, IIUC, we can assume that the only process that can write into MyBEEntry of the current backend is the current backend itself, therefore looping to get consistent reads from this array is not required. Please correct me, if I am wrong here. Thanks for the updated patch. I think you're right - pgstat_begin_read_activity() is used for cases involving other backends. It ought to be safe for a process to read its own status bits, since we know they're not also being written. You changed DefineIndex() to update progress for the leaf indexes' when called recursively. The caller updates the progress for "attached" indexes, but not created ones. That allows providing fine-granularity progress updates when using intermediate partitions, right ? (Rather than updating the progress by more than one at a time in the case of intermediate partitioning). If my understanding is right, that's subtle, and adds a bit of complexity to the current code, so could use careful commentary. I suggest: * If the index was attached, update progress for all its direct and * indirect leaf indexes all at once. If the index was built by calling * DefineIndex() recursively, the called function is responsible for * updating the progress report for built indexes. ... * If this is the top-level index, we're done. When called recursively * for child tables, the done partition counter is incremented now, * rather than in the caller. I guess you know that there were compiler warnings (related to your question). https://cirrus-ci.com/task/6571212386598912 pgstat_progress_incr_param() could call pgstat_progress_update_param() rather than using its own Assert() and WRITE_ACTIVITY calls. I'm not sure which I prefer, though. Also, there are whitespace/tab/style issues in pgstat_progress_incr_param(). -- Justin