UpgradePostgreSqlFlexibleServer fails to update from PostgreSql 14 to 17

Arno Brand 0 Reputation points
2025-09-12T04:26:53.19+00:00

Hi there, I am struggling to upgrade my Azure Database for PostgreSQL flexible server instance from version 14 to 17 using the Azure Upgrade Utility. The prechecks are all passing and the process runs for about 15 mins, then suddenly fails with the following error:

CREATE TABLESPACE "temptblspace" OWNER "azure_pg_admin" LOCATION '/mnt/pg_tmp';
ERROR: could not set permissions on directory "/mnt/pg_tmp": Operation not permitted

I have Owner and User Access Administrator permissions on this instance. How can I fix this permissions issue and get my instance updated?

Azure Database for PostgreSQL
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Deepanshu katara 17,570 Reputation points MVP Moderator
    2025-09-12T05:00:20.0433333+00:00

    Hello , Welcome to MS Q&A

    Azure Database for PostgreSQL flexible server restricts superuser access and filesystem-level operations, which causes the upgrade utility to fail when attempting to create a temporary tablespace. To resolve this, use Azure’s built-in upgrade path, avoid custom tablespaces, and disable incompatible extensions or triggers before upgrading. Be sure to clean up large objects and run ANALYZE post-upgrade to optimize performance.

    Ref links --> https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/concepts-major-version-upgrade

    https://stackoverflow.com/questions/74318794/azure-postgresql-migartion-from-single-server-v11-to-flexible-server-v14-permi

    Pls check and let us know

    thanks

    0 comments No comments

  2. Arno Brand 0 Reputation points
    2025-09-12T06:01:23.0166667+00:00

    It turns out the tablespace "temptblspace" is a user-defined tablespace even if I did not create the tablespace. It seems to have been automatically created by azure at some point. After confirming the tablespace was not linked to any objects I simply dropped the keyspace and reran the upgrade utility. The upgrade succeeded this time.

    For anyone having the same issues, these are the sql commands I used to figure out if I can safely drop this keyspace which was causing the upgrade utility to fail:

    -- Precheck extensions to ensure no unsupported extensions
    SELECT * FROM pg_extension;
    
    -- Check tablespaces and physical locations
    SELECT spcname, pg_tablespace_location(oid) FROM pg_tablespace;
    
    -- Check for user-created tablespaces
    SELECT spcname, spcowner
    FROM pg_tablespace
    WHERE spcname NOT IN ('pg_default', 'pg_global');
    
    -- Check owners of the tablespace
    SELECT t.spcname, r.rolname AS owner
    FROM pg_tablespace t
    JOIN pg_roles r ON t.spcowner = r.oid;
    
    -- Validate no dependant objects on temptblspace
    SELECT relname, relkind
    FROM pg_class
    WHERE reltablespace = (SELECT oid FROM pg_tablespace WHERE spcname = 'temptblspace');
    
    -- DESTRUCTIVE: Drop the tablespace - Only run if absolutely necessary
    -- DROP TABLESPACE temptblspace;
    
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.