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 1uZv7t-00AGW6-I3 for pgsql-hackers@arkaria.postgresql.org; Thu, 10 Jul 2025 17:32:05 +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 1uZv7r-00FJcP-5W for pgsql-hackers@arkaria.postgresql.org; Thu, 10 Jul 2025 17:32:03 +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 1uZv7q-00FJcG-RM for pgsql-hackers@lists.postgresql.org; Thu, 10 Jul 2025 17:32:03 +0000 Received: from mail-il1-x12a.google.com ([2607:f8b0:4864:20::12a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uZv7o-006sXV-2m for pgsql-hackers@lists.postgresql.org; Thu, 10 Jul 2025 17:32:03 +0000 Received: by mail-il1-x12a.google.com with SMTP id e9e14a558f8ab-3d948ce7d9dso7197185ab.2 for ; Thu, 10 Jul 2025 10:32:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752168718; x=1752773518; darn=lists.postgresql.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=77wzi+kIW5YMT1T4prkkKG1fOldMXRvjcu2u+BzlQ9c=; b=gW38AzZSyxSEnUR3XgJNPOhU0SwTb73xBScFge1PnwyMek/kgFQ8XfGGXVCfCqD7lX ojiDnpgZPYe1FWpA78YjvMao1eCNsUMSbmKxhbcCrN6fD3mpyeObJ96M3k/ZYbUP0Aaz eru9nboG+f0whnLT9g30AbiOnWEVy6chFjy4umYuLtl1nc/0c+9x0OHiEDzV+FS5wwmU U05A64o1wDKpYLAzTjqtWYLlRauoPkAGW7C2LGzvv9H82Ku5c90fhV6B9hYTCgYJjLQ2 ija5Qb1hrn10tygDmudc96Yu9VQu+bDXdJ8PXeRaNPSSWzqdPUUzo4lk4j5K/v2nqol5 Jn7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752168718; x=1752773518; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=77wzi+kIW5YMT1T4prkkKG1fOldMXRvjcu2u+BzlQ9c=; b=JJ5O5GPQWtdeaLnVikesIY8gJrbnzlJ/ZdWtMZaZc2YSYB07kPrIuGF06DmkuoGr22 kgUctiVG8Bk3DAJMKzxDDSDiRi5gw6PXE2eVSQjbZwcdRCnlunmgQf+6IwsGYm/+1wn/ hpnwvg+aRSBVgE6nyyiKIGJyDyogafbLU31GzA7E2TrWrNclK41D1pZxWXQn7RdlEDAf 4+j8tLAaDoN+l4Z3u6LTJtFZMCzwMbCT4LYO4WoR2LhKkWFhVTwHsP2xBsssPl6hXV/v qCjlEPFw5ZnS0u56axKcVxQUFj5u+l10EsDNxag8R078QTmTzV4ClKrzfSuRIKhnpFTu Sc4g== X-Forwarded-Encrypted: i=1; AJvYcCVNsejP5MJpOEkPHk/BXk9kky0A6GULrJtoW4bIjq6s9ajiCWspBqy2scih4StWoZQm/q1uUdXC0S4Z5vTe@lists.postgresql.org X-Gm-Message-State: AOJu0Yy3RwAmI2jZhHviKZ6R1zRQJ6tJAP+s9HvZVhKlCCWfYlwauQKL m+mHyocUJMcS5uOjNlzHTKYBNQxigfQl7zUXjIxIiG4x5HjQv51BI3BX X-Gm-Gg: ASbGnctZXbqRfWTuSpvnMXU0jTSI40tWvV1N1jkwikpVVkKBYXx1DQugoquk3urWDyx lzZJaA9lH4VueCxB5J5ivqWyDcqVeBKtCxj8CYJoC7Ag6lXKPyjfK7q6uu68IN8+/p+7J7j9G0U aew2bKzjwSr4r7JRj5yL42xBOECAXTj5k/wc5ewbQG2pzoki8FuyX4RJOACY85+pRptipdK/Ayi 5W+eBGmSLPRgUuUWqkD1140GIkU2DsXi6ewsSX0E/iAf5J+TLUscW4pkMBWjjaz10lIWq2CEMXw 1yYQfKeHm2HBbfxGI7r2k70b3SQo2TNW1zDtVIGILpxgC2WpgdI667fPZRvn7iHzjUI+M8QvYR4 V+gHJOCa+7G68WYoyXmW2uRbLXiTxA47bOwZKDS79hdySP3tjfTA1 X-Google-Smtp-Source: AGHT+IHITWhQXHCm2yswRwRpnwwvcvGx79sZcuJ041bUjfRO8AnEPMSe16ltEO8EolcGsbGQWYeHjQ== X-Received: by 2002:a05:6e02:3499:b0:3dd:b4b5:5c9f with SMTP id e9e14a558f8ab-3e2533618d7mr3123435ab.19.1752168718323; Thu, 10 Jul 2025 10:31:58 -0700 (PDT) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-50556b2a205sm418619173.134.2025.07.10.10.31.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Jul 2025 10:31:57 -0700 (PDT) Date: Thu, 10 Jul 2025 12:31:56 -0500 From: Nathan Bossart To: Nitin Motiani Cc: Hannu Krosing , Tom Lane , PostgreSQL Hackers Subject: pg_dump sort priority mismatch for large objects Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk (moving to a new thread) On Thu, Jul 10, 2025 at 06:05:26PM +0530, Nitin Motiani wrote: >> There might be an existing issue here, because dbObjectTypePriorities >> has the following comment: >> >> * NOTE: object-type priorities must match the section assignments made in >> * pg_dump.c; that is, PRE_DATA objects must sort before DO_PRE_DATA_BOUNDARY, >> * POST_DATA objects must sort after DO_POST_DATA_BOUNDARY, and DATA objects >> * must sort between them. >> >> But dumpLO() puts large objects in SECTION_DATA, and PRIO_LARGE_OBJECT >> is before PRIO_PRE_DATA_BOUNDARY. I admittedly haven't spent too much >> time investigating this, though. > > I looked through the history of this to see how this happened and if it > could be an existing issue. Prior to a45c78e3284b, dumpLO used to put large > objects in SECTION_PRE_DATA. That commit changed dumpLO and also changed > addBoundaryDependencies to move DO_LARGE_OBJECT from pre-data to data > section. Seems like since then this has been inconsistent with > pg_dump_sort.c. I think the change in pg_dump_sort.c should be backported > to PG17 & 18 independent of the state of the larger patch. Thanks for doing the archaeology! > But even with the inconsistency, it doesn't look like there is an existing > issue. As the dependencies were changed in addBoundaryDependencies, that > should take precedence over the order in pg_dump_sort.c. The > dbObjectTypePriorities are used by sortDumpableObjectsByTypeName. But right > after that sortDumpableObjects sorts the objects based on dependencies > therefore the change in boundary dependencies should ensure that this is > working as intended. Still I think dbObjectTypePriorities should be made > consistent with the rest. +1, if for no other reason than we'll need it to be below PRIO_TABLE_DATA for the speed-up-pg_upgrade-with-many-LOs patch [0]. Does anyone see any problems with applying something like the following down to v17? diff --git a/src/bin/pg_dump/pg_dump_sort.c b/src/bin/pg_dump/pg_dump_sort.c index 0b0977788f1..538e7dcb493 100644 --- a/src/bin/pg_dump/pg_dump_sort.c +++ b/src/bin/pg_dump/pg_dump_sort.c @@ -76,10 +76,10 @@ enum dbObjectTypePriorities PRIO_TABLE_ATTACH, PRIO_DUMMY_TYPE, PRIO_ATTRDEF, - PRIO_LARGE_OBJECT, PRIO_PRE_DATA_BOUNDARY, /* boundary! */ PRIO_TABLE_DATA, PRIO_SEQUENCE_SET, + PRIO_LARGE_OBJECT, PRIO_LARGE_OBJECT_DATA, PRIO_STATISTICS_DATA_DATA, PRIO_POST_DATA_BOUNDARY, /* boundary! */ [0] https://postgr.es/m/aBkQLSkx1zUJ-LwJ%40nathan -- nathan