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 1h3KFN-0003Es-D6 for pgsql-hackers@arkaria.postgresql.org; Mon, 11 Mar 2019 12:41:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h3KFL-0001gQ-Jc for pgsql-hackers@arkaria.postgresql.org; Mon, 11 Mar 2019 12:41:35 +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 1h3KFL-0001bl-Ba for pgsql-hackers@lists.postgresql.org; Mon, 11 Mar 2019 12:41:35 +0000 Received: from mail-qt1-x842.google.com ([2607:f8b0:4864:20::842]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h3KFE-0003Kx-9a for pgsql-hackers@lists.postgresql.org; Mon, 11 Mar 2019 12:41:34 +0000 Received: by mail-qt1-x842.google.com with SMTP id v20so1478388qtv.12 for ; Mon, 11 Mar 2019 05:41:27 -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=k8CKGxAGdPerkB4w1q2vbYG0hLOux1z5h+xDpkUqWCQ=; b=12hzmsFs1v3gKgsdKIAgjARiVkAMchJszvxU26n/D7KKY9fvPKiKfMv6X/bHQ2es1V bVXa4Gp0gux7OZqJUVd52QF2fVhMpfV/7j89YfMef1Mrg80hBO1QpZ7DefRPLeb7HJXg 8ZSZWDra6Oe3gOOqzBEOXdM/oIoePt/RjGaGWJmHl9skkuM86ZHScwCiAmNdnxs9Ok/W SDy0hnmSRFTXcsa7bGLTXWf7AFo4YE6z1Dr/jZ5CBwrIUBMvlX5lyoukqHb/Ts2SdOF9 6hx1dCdk6B1ZJ7wwEP3hQ1fyoB2qKMhB8sdLNUkKGXf+PlxLtB3pmw4/ZFDb2RB3r8OJ tEEA== 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=k8CKGxAGdPerkB4w1q2vbYG0hLOux1z5h+xDpkUqWCQ=; b=dIAAPEBR14fBuyfqn+54FxLweSlgX0v0HEkR+CpwMq1+YsN4MQLGG9VqkoPHBm5DKa 1DqnG+MdxPSa1dZgEpyauGVGyJn9PnFjFZ2gnZQM7L7MFYZEFlfqdJ62fkCND/Crg669 wVhJkWDvXO9pjloFuAprhkWj11PnjBH36/snPsDO7j5KdUcjvAd+0og5daaqa+OtAaDU y+9tgx38w5N3j2UjRf81ODqNM9hhLQGGQHS0evMK5Z/trdyBRZs+uKYdgSfsBsyk8jc6 gV87QhkSHQbROVURp9zRRHVX3eKRJXJahZIVBvHY1nxF80RGlY1xyAf/MYt0gxF5fdEJ ZZQQ== X-Gm-Message-State: APjAAAV8fkZ++QUUy6H9Uu7MTMT1xXy5vAibPopmTE9eBaRzkgJwZ7LT i0qMMFHC3CSQr0iohJPak2zXgg== X-Google-Smtp-Source: APXvYqy2ckQhumUCO1xuTy1ndTPk640XXrZ96z+xhFuLhD0Uo1NL2DHG0Pb00cN1jgrN2z5prE6+yQ== X-Received: by 2002:a0c:b597:: with SMTP id g23mr25469761qve.142.1552308086227; Mon, 11 Mar 2019 05:41:26 -0700 (PDT) Received: from nimloth.alvh.no-ip.org ([190.121.29.3]) by smtp.gmail.com with ESMTPSA id s186sm1205835qkb.57.2019.03.11.05.41.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Mar 2019 05:41:25 -0700 (PDT) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 5753E121DF3; Mon, 11 Mar 2019 09:41:23 -0300 (-03) Date: Mon, 11 Mar 2019 09:41:23 -0300 From: Alvaro Herrera To: Rahila Syed Cc: pgsql-hackers@lists.postgresql.org Subject: Re: monitoring CREATE INDEX [CONCURRENTLY] Message-ID: <20190311124123.GA7486@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 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: Precedence: bulk Hi Rahila On 2019-Mar-11, Rahila Syed wrote: > On Tue, 5 Mar 2019 at 08:32, Alvaro Herrera > wrote: > > +extern char *btbuildphasename(int64 phasenum); > > 1. I think int64 is too large a datatype for phasenum. > Also int32 is used for phasenum in pg_indexam_progress_phasename(). > Can we have it as int8? It does look strange, I agree, and the first code I wrote had it using a smaller type. However, I later realized that since the value comes directly from pg_stat_get_progress_info(), which returns int8 values, it was pointless to only accept a small fraction of the possible values for no good reason, so I widened it to int64 as you see now. > 2. > . In validate_index_heapscan, we dont calculate blocks_done similar to > IndexBuildHeapScan i.e > block_done += scan->rs_cblock - previous_blkno which IMO is more accurate. > Reporting scan->rs_cblock as blocks_done might give slightly inaccurate > results as we are > still processing that block. Thanks for pointing out that there's an off-by-one bug there (should be cblock-1). However, IndexBuildHeapScan uses more complicated code because it needs to cover for two additional things that validate_index_heapscan doesn't: parallel heapscans and synchronized seqscans. We could do that, I just saw no point in it. > 3. There is no if(progress) check in validate_index()/ > validate_index_heapscan() code. Wont it be a problem if it is called from > other index methods which dont support reporting progress at the > moment? Good question. I'll have a look. Most likely, I'll end up having things so that building an index using an unsupported index AM reports progress based on IndexBuildHeapScan / validate_index / validate_index_heapscan ... which might mean I should remove the 'progress' parameter from there and have them report unconditionally. > 4. Just to clarify my understanding can you please see below comment > > Quoting your following comment in cluster command progress monitor thread > while referring to progress reporting from IndexBuildHeapScan, > > "One, err, small issue with that idea is that we need the param numbers > not to conflict for any "progress update providers" that are to be used > simultaneously by any command." > > Does that mean that we can't have any other INDEX progress monitoring, use > PROGRESS_SCAN_BLOCKS_TOTAL and PROGRESS_SCAN_BLOCKS_DONE > parameter numbers to report anything but the metrics they report now. What I mean is that the literal parameter numbers defined as PROGRESS_SCAN_BLOCKS_DONE/TOTAL may not be used for other parameters by commands that call IndexBuildHeapScan, if those other parameters are used by the same commands simultaneously with IndexBuildHeapScan. So those parameter numbers become "reserved". > 5. > > > 15:56:44.682 | building index (3 of 8): initializing (1/5) | > > 442478 | 442399 | 0 | 0 | 0 | > > I wonder how is the phase 'building index(3 of 8): initializing(1/5)' when > the blocks_done count is increasing. Shouldn't it have > changed to reflect PROGRESS_BTREE_PHASE_INDEXBUILD_HEAPSCAN as building > index(3 of 8): table scan(2/5) ? > Although I think it has been rectified in the latest patch as I now get > 'table scan' phase in output as I do CREATE INDEX on table with 1000000 > records Yeah, this was a bug that I fixed in v5. (It was a misunderstanding about how parallel scanning is set up, IIRC). For v5, I tested both parallel and non-parallel builds, with and without sync seqscans, and everything seemed to behave correctly. Thanks for looking! I intend to post a new version later this week. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services