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 1gmnqH-00076D-Qv for pgsql-hackers@arkaria.postgresql.org; Thu, 24 Jan 2019 22:51:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gmnqE-0003QU-3c for pgsql-hackers@arkaria.postgresql.org; Thu, 24 Jan 2019 22:51:22 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gmnqD-0003QN-LX for pgsql-hackers@lists.postgresql.org; Thu, 24 Jan 2019 22:51:21 +0000 Received: from mail-qk1-x741.google.com ([2607:f8b0:4864:20::741]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gmnq5-0008S2-Cb for pgsql-hackers@lists.postgresql.org; Thu, 24 Jan 2019 22:51:20 +0000 Received: by mail-qk1-x741.google.com with SMTP id 68so4360946qke.9 for ; Thu, 24 Jan 2019 14:51:12 -0800 (PST) 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=QN9FDoIokGt9PAd2h4aqgmy2ejt5MF4mm18ICYEcD6Q=; b=Rs25m/yRm8yM5MjVR4E5+L0n/aZhPBZ4zM8dvL0GBeCHuxKsBM4KHQPGD1U+/MMh5K aq8X9qzGzVCp6sz6kALr1EKywOMmP4Avnebznyhs7R+xZrKa18qosUAytPta0uPFSmLM DxqcCdbdLs++HVl0jQ4UBF7YRzTwPgkyH946/Lgknv3rw3cixvryLNicDcr2Gphxi60f NSZrXVa1qFVnbxApSSHTyXihklDqEDge2MhLx7LNHZLEd4CKR6eHZzCH5ioP0CQ500fP im5UBNav9RZt3fWCWzgbr2TmsTg80artNa4GNTWbg0jUznGU/5J061MxbDHEOs68jWLG BAzA== 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=QN9FDoIokGt9PAd2h4aqgmy2ejt5MF4mm18ICYEcD6Q=; b=cGAtIje8d+v8VK0j+p9gg3BgBMDEhCGjU9gfegy7TpI3t2tmAz+C72d/AfUaz5vc9o WfbY0faKwCnIQLAFhwa8WERGdqsKNipV5TV6xMl2JtHRE5a503zPzB3CdBUXzkeSfFdh GO2hsatksNkL2Ag0dG/YX4KOXrVaoyArJHxvWsz0SxqA5Ih2LX6X1muTYWUQ7QxqtMSU phnIfkIGe/SJeESFqeK5DYdwMStH2H5zZa14yfNOfiFvbhPshvOCMR5a+2KcAH/4Md0i FGTbsEYhSDDPtFyXeSa/Z/NeoYy3ZbH2IL/OcSHFMHZfrhPNyrpSQxZ0F+12PU+yRiv+ GgJA== X-Gm-Message-State: AJcUukd0X5ONIK8tWAd+PaFXLX/M04cia7jDtpCxrw/rOXIf5zWLyogg WDlzICxy8TO0B7zgM0shQxxg+g== X-Google-Smtp-Source: ALg8bN777VBy8X142yIgNqZZWXFmCrWy2HG7DkwXPbEl04HNsslFLpTPHPo9w6VXQRo9IYU7TUBUUQ== X-Received: by 2002:a37:8cc5:: with SMTP id o188mr7418332qkd.62.1548370271603; Thu, 24 Jan 2019 14:51:11 -0800 (PST) Received: from alvin.alvh.no-ip.org ([190.121.29.3]) by smtp.gmail.com with ESMTPSA id s24sm39331327qkl.48.2019.01.24.14.51.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Jan 2019 14:51:11 -0800 (PST) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id F2C30AB4; Thu, 24 Jan 2019 19:51:08 -0300 (-03) Date: Thu, 24 Jan 2019 19:51:08 -0300 From: Alvaro Herrera To: Pavan Deolasee Cc: Pg Hackers Subject: Re: monitoring CREATE INDEX [CONCURRENTLY] Message-ID: <201901242251.sh36e4poxsek@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: NeoMutt/20180716-1013-2c1e88 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2019-Jan-09, Pavan Deolasee wrote: > Looks like it's missing the validate_index blocks-scanned report, which is > not AM-specific and your original proposal does mention that. True. That phase is actually 3 phases, which would be reported separately: 5. index_bulk_delete() scan 6. performsort 7. validate_index_heapscan > I thought a bit about index_build part. If most AMs follow a somewhat > standard phases while building an index, it might be simpler to define > those phases and have AM agnostic code report those phases. Well, think about btrees. We first scan the whole table putting all tuples in a spool (two spools actually), then we tell the spools to get sorted, then we extract tuples from the spools, and finally we read the spool to produce the leaf pages. If we just report the table scan, the reports gets to 100% complete in that phase and then waits for a very long time during which nothing seems to happen. That's not cool. I'm adding a new AM support routine which turns the subphase number into a textual description, so that we don't have to hardcode phase names in the agnostic code. > Can we have more descriptive text for waiters? Such as "waiting for > existing writers", "waiting for intermediate writers" and "waiting for > old readers". Not sure if I got those correct, something of that sort > will definitely give more insight into what the transaction is waiting > for. Can do. > Can we actually also report the list of transactions the command is waiting > on? > That could be useful to the user if CIC appears to be stuck too long. I'm afraid this is not possible, because the progress report interface doesn't allow for something like that. > IMHO we should just use full term INDEX instead of IDX, such as > PROGRESS_CREATE_INDEX_PARTITIONS_TOTAL. It's already a long name, so couple > of extra characters won't make a difference. Really? I though it was clear enough and it's *three* characters saved even. > I think we should clear the PROGRESS_WAITFOR_TOTAL and PROGRESS_WAITFOR_DONE > when the wait phase is over, to avoid any confusion. For example, I noticed > that the counters from WAIT_1 are reported as-is if WAIT_2 had no lockers. Yes, absolutely. > +GetLockConflicts(const LOCKTAG *locktag, LOCKMODE lockmode, int *ocount) > > Could that out variable be named something differently? "countp" or > something like that. I did not check if there is some practice that we > follow, but I remember suffixing with "p" rather than prefixing with > "o" (for out I assume) Sure. > +/* Progress parameters for CREATE INDEX */ > +#define PROGRESS_CREATEIDX_PHASE 0 > +/* 1 and 2 reserved for "waitfor" metrics */ > +#define PROGRESS_CREATEIDX_PARTITIONS_TOTAL 3 > +#define PROGRESS_CREATEIDX_PARTITIONS_DONE 4 > + > > Is there a reason to leave those reserve placeholders, only to fill them a > few lines down? Yes -- those are going to be used by other reports that also use similar metrics, such as the CLUSTER report. I'm running out of columns to put the numbers into :-( Right now I have 1. phase 2. subphase (for index_build) 3. lockers total (to wait for) 4. lockers done 5. blocks total 6. blocks done 7. tapes total 8. tapes done 9. partitions total 10. partitions done The "tapes total/done" bit is about reporting the performsort steps; I'm not really sure yet it'll be tapes, but I hope it can be done with two numbers. Anyway, in btree build I have these subphases 1. spool heapscan using IndexBuildHeapScan 2. _bt_parallel_heapscan stuff (only one of these in a build) 3. bt_leafbuild, performsort spool 1 4. bt_leafbuild, performsort spool 2 5. bt_load and I don't have columns to put the metrics for the btload thing, assuming I figure out what those are. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services