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 1kahQs-0000N4-V5 for pgsql-novice@arkaria.postgresql.org; Thu, 05 Nov 2020 15:44:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kahQr-0002sW-Sz for pgsql-novice@arkaria.postgresql.org; Thu, 05 Nov 2020 15:44:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kahQr-0002sO-IA for pgsql-novice@lists.postgresql.org; Thu, 05 Nov 2020 15:44:13 +0000 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kahQo-0007FA-Ur for pgsql-novice@postgresql.org; Thu, 05 Nov 2020 15:44:13 +0000 Received: by mail-wr1-x42b.google.com with SMTP id w1so2312883wrm.4 for ; Thu, 05 Nov 2020 07:44:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:date:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=U9OGOjSgK7sfw4Jyvj2Avy7xSwGDNPBvIfUrfyyfpds=; b=g/DrItRSEbplzr0PrSMyZQX+wX4d20yWnFcvl48qgt3iA8JlfKXpXuZfkVtnj2CWMd 0bItPmGu4hUupUG3YbrWE9VadB5PVTpu2mKTXHTs90UCXjQUaNsFJUhygGqQr76IfJMz KaJ2tVLKoDS3szuDID994kdN+NWWZE1kyiTX+YNC90WDsFVZDEAsqHQePYcU7OL9VxLb 9dPUs5qVkXzpSBmc42MmyfoAXEiL8+GUPxUmi/z7v0YpJ6HnLQOLYZaBYHoPR82Q+918 WBTfwfVbj+QZzSbB5EERfR1nvThsS3uvObp5q4u5eIKnWAAt5UVWFuQsjneCSAFGelv8 cEiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=U9OGOjSgK7sfw4Jyvj2Avy7xSwGDNPBvIfUrfyyfpds=; b=IXtt9R3fZwdLP6tKzUo9gbsV1ngCzmz1dCUYmXI3hZBp9EJfOrlDuJqFMfXLRVySCj vliYWBQJDmLi1FmSXWFyxrWSXDNnW3IHcaWW3O6SMH/pUVefObvV5QdRx0CdU/uhw0uW bK/xvpYpnWu9dRab9gMe9T8+9H1JQifl5T6HabNaxL7+1srUjVMre7SE74UG2mCymbne XCiQnSOFsTROEuFj5gKfd8OGN2ZSqlWazS2oU0YIz3wgun2WDlz154PzOwyKuuznN3kC 1WwR+Y8NR010gL2gPA2f6GkGps9cB4GBbStD2Mmida8LyC6e0guFj7a30oay0sKjfgdY RWLw== X-Gm-Message-State: AOAM530MJLIi+R/ELdGuTcmMr6C+nRB8y+JPG6gej4Qb670UyeY723bl aGPuZ895WXCBMS6uSMLQdGcf0A== X-Google-Smtp-Source: ABdhPJyaVXJ8rF/dcJLWmKB/akINVO0zXH6h7/D8dS/OAAYY55ip9a3tISqpZA1TLOB79aPn41bFwQ== X-Received: by 2002:a5d:4448:: with SMTP id x8mr3161231wrr.364.1604591050005; Thu, 05 Nov 2020 07:44:10 -0800 (PST) Received: from localhost.localdomain (217-149-173-73.nat.highway.telekom.at. [217.149.173.73]) by smtp.gmail.com with ESMTPSA id 71sm3497269wrm.20.2020.11.05.07.44.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 07:44:09 -0800 (PST) Message-ID: <092337ddb6c1320edd7ab512bac807f5c0ea259b.camel@cybertec.at> Subject: Re: Permission Denied to Regular Read/Write User to Create New Partitioned Table From: Laurenz Albe To: "Hilbert, Karin" , "pgsql-novice@postgresql.org" Date: Thu, 05 Nov 2020 16:44:08 +0100 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-1.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, 2020-11-05 at 14:25 +0000, Hilbert, Karin wrote: > We normally create our databases & objects with a DB Owner account & the application > connects with a regular user account that has read/write permissions. > For GITLAB, the application updates the database as required during the application upgrade. > We allow the application to connect as the DB Owner account only during those times & > switch back to the regular account when the upgrade is done. > > However, with the latest application upgrade, GITLAB is now using partitioned tables. > When the table reaches a certain size, the application tries to create a new partitioned > table, which errors out for the regular user account: > > 2020-11-03 18:21:31 EST [56435]: [88-1] db=xxxxxx,user=xxxxxx ERROR: permission denied for schema gitlab_partitions_dynamic at character 28 > 2020-11-03 18:21:31 EST [56435]: [89-1] db=xxxxxx,user=xxxxxx STATEMENT: CREATE TABLE IF NOT EXISTS "gitlab_partitions_dynamic"."audit_events_part_5fc467ac26_202105" > > I tried to solve the error by granting the regular user acct "usage, create" on the schema: Yes, granting CREATE on the schema is the proper remedy for that error. > psql -d xxxxxx -U xxxxxxxxxx -c "grant usage, create on schema gitlab_partitions_dynamic to xxxxxx;" > > Now we're getting a "must be owner" error: > > 2020-11-04 12:21:17 EST [28013]: [420-1] db=xxxxxx,user=xxxxxx ERROR: must be owner of table audit_events_part_5fc467ac26 > 2020-11-04 12:21:17 EST [28013]: [421-1] db=xxxxxx,user=xxxxxx STATEMENT: CREATE TABLE IF NOT EXISTS "gitlab_partitions_dynamic"."audit_events_part_5fc467ac26_202105" Seems that the user is trying to create a partition for a table that it doesn't own. You must be the owner of a table to create a new partition for it. If that happens during regular operation, your only choice will be to make the application user the owner of the partitioned table (or a member of the owner). I guess you cannot modify the application code, right? Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com