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 1u3F7L-00Cl4A-PC for pgsql-hackers@arkaria.postgresql.org; Fri, 11 Apr 2025 14:12:27 +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 1u3F7J-00AHP9-VN for pgsql-hackers@arkaria.postgresql.org; Fri, 11 Apr 2025 14:12:26 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1u3F7J-00AHNK-JP for pgsql-hackers@lists.postgresql.org; Fri, 11 Apr 2025 14:12:25 +0000 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1u3F7H-004iq9-0v for pgsql-hackers@postgresql.org; Fri, 11 Apr 2025 14:12:25 +0000 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-43d2d952eb1so16251255e9.1 for ; Fri, 11 Apr 2025 07:12:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1744380742; x=1744985542; darn=postgresql.org; h=message-id:date:content-id:mime-version:subject:to:from:from:to:cc :subject:date:message-id:reply-to; bh=k+X2/3CwM8vRzO68pIt1ASYT3E+Jrd/RCigILY3uZzU=; b=aCLzWz13pRS9wxeLPleQqVquwGnenfuJCPsQnu3UH59n4a0+teWPFOLYgWaBHmimV4 CSu9JJ2dYxAg/BwhT5XAKAlPgbWTi6j2U7yml91wJaD2Y8VqiK/dL/PCXQDsAhrNfnLc 1h5kCBPSIDmd8TezATyd/G2k9/i2mrrj/JKuLAzgOCmP2rrdYzIzH/Ol2/crovOlxMPG t5lRXKKJbEtyVSXvgKCI1iXL5NHYijm3uttR1kDYg/MHPfDLbUtrPyxethlOPDkiyOcS /JS614IlE+nt4NPac5R08HxQlVNk1YKz6Od10lOTdLZuBQjTNKaZ2VwAV+C3HLG7PXn4 2TkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744380742; x=1744985542; h=message-id:date:content-id:mime-version:subject:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=k+X2/3CwM8vRzO68pIt1ASYT3E+Jrd/RCigILY3uZzU=; b=onlVLMYmdicjr77isa4a/z4s4r4ICF/RxfhXCWer3tJsaFyuqdEPUJjA4XIXn3Fmap MvsTAPMHwYBVemgXb/+w6wY4MlWzQEkKiRumq6WUT5TSfj7CdqEqlL7Qgc4+QEanVnud E7dQPb1+OFXkW66y4hASASzxeaMTav129TUJcbW0ecE9v7UC4Rhi38Yr5ieGT08eXC4H qDvZepS4nfqyPBta21DzO69swPB7zekw0Oubi2lcLBChqi2KfOzTXCXhMxitGioD0BXu 7FNAOdtSfx8fZW7Vnqm1tgiir0XD16YOrSbZ/I2QYaBSnaNDWJX3yfzh2VfgnudWHqKz GjHA== X-Gm-Message-State: AOJu0YyioK1Td01F19+SN7EPu94gO1VFAu/LK+I5+ovJAnmD6fxQPhKi gA2X2BJNgQc85iVHc5ai8HCAIHjsTRbzdBvv0YbiBBdRWzVUBOaBLw8nPXUnrQIKHoeuLv3FmUP U X-Gm-Gg: ASbGnct2PpbLKbNK2zPkZ/h/qeqnO5HsZiWJD32oVf8UgbhWtbWmE7ocTtkoq9hyLP7 UIPcilfT2IXBsGNBBrBaFteVSjfcUPPqj7XNjMWDNyp+icFHIP4EEVwSmigOXw4hKKzBPkqo91l oNH1Oydd4AtNybxatMoBvsumgXgzTBHtR8cqy6XZQOBqzHA+meOUJMHAKdmfoBStWyERfFlkZTr 8zTrNBfoUAGSHnNlk+LrcKBtEm9YKgmSe2d8NinxjDwfeczEyMmNuYChcsXvEhqpW0B9kxd5qai C9wxSv4HEH6eCjLs7ER9OUfimcItpLEvt8jS4jcv7tZxNIRqK2dxyZt9PxrKw+s= X-Google-Smtp-Source: AGHT+IHPH+VcvzMPWD8ur9HhCP2YiCZrB5VQ/VRbtIe83uhK/huHXcZrbJjbi0sLQXLbSvYDKMMP6Q== X-Received: by 2002:a05:600c:5008:b0:43c:ec28:d301 with SMTP id 5b1f17b1804b1-43f3a9aaf7fmr23737225e9.26.1744380741238; Fri, 11 Apr 2025 07:12:21 -0700 (PDT) Received: from localhost (109-81-174-36.rct.o2.cz. [109.81.174.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43f233a2a13sm83924835e9.10.2025.04.11.07.12.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Apr 2025 07:12:20 -0700 (PDT) From: Antonin Houska To: pgsql-hackers@postgresql.org Subject: Conflicting updates of command progress X-Mailer: MH-E 8.6+git; nmh 1.8; GNU Emacs 28.3 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <117146.1744380740.1@localhost> Date: Fri, 11 Apr 2025 16:12:20 +0200 Message-ID: <117147.1744380740@localhost> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk While working on [1] I realized that some field of pg_stat_progress_cluste has weird value. On closer look I found out that cluster_rel() indirectly calls index_build() and that overwrites the progress parameter. Following are the parameter values in the master branch: /* Phases of cluster (as advertised via PROGRESS_CLUSTER_PHASE) */ #define PROGRESS_CLUSTER_PHASE_SEQ_SCAN_HEAP 1 #define PROGRESS_CLUSTER_PHASE_INDEX_SCAN_HEAP 2 #define PROGRESS_CLUSTER_PHASE_SORT_TUPLES 3 #define PROGRESS_CLUSTER_PHASE_WRITE_NEW_HEAP 4 #define PROGRESS_CLUSTER_PHASE_SWAP_REL_FILES 5 #define PROGRESS_CLUSTER_PHASE_REBUILD_INDEX 6 #define PROGRESS_CLUSTER_PHASE_FINAL_CLEANUP 7 /* Progress parameters for CREATE INDEX */ /* 3, 4 and 5 reserved for "waitfor" metrics */ #define PROGRESS_CREATEIDX_COMMAND 0 #define PROGRESS_CREATEIDX_INDEX_OID 6 #define PROGRESS_CREATEIDX_ACCESS_METHOD_OID 8 #define PROGRESS_CREATEIDX_PHASE 9 /* AM-agnostic phase # */ #define PROGRESS_CREATEIDX_SUBPHASE 10 /* phase # filled by AM */ #define PROGRESS_CREATEIDX_TUPLES_TOTAL 11 #define PROGRESS_CREATEIDX_TUPLES_DONE 12 #define PROGRESS_CREATEIDX_PARTITIONS_TOTAL 13 #define PROGRESS_CREATEIDX_PARTITIONS_DONE 14 /* 15 and 16 reserved for "block number" metrics */ The only conflicting parameters I see here are PROGRESS_CLUSTER_PHASE_REBUILD_INDEX vs PROGRESS_CREATEIDX_INDEX_OID (number 6). Fortunately, index_build() does not set PROGRESS_CREATEIDX_INDEX_OID so there's no live bug. However [1] adds some PROGRESS_CLUSTER_ parameters, thus making conflicts realistic. AFAICS the current design does not consider that one progress-reporting command can be called by another one. Not sure what the correct fix is. We can either ignore update requests from the "nested" commands, or display the progress of both. The latter approach is probably more invasive - is that worth the effort? [1] https://commitfest.postgresql.org/patch/5117/ -- Antonin Houska Web: https://www.cybertec-postgresql.com