How does PostgreSQL decide what to name its tablespace directories?
I look at the source code of postgres9.6.

/* tablespace.c */

create_tablespace_directories(const char *location, const Oid tablespaceoid)
{
    ....
    location_with_version_dir = psprintf("%s/%s", location,TABLESPACE_VERSION_DIRECTORY);
    ....
    if (mkdir(location_with_version_dir, S_IRWXU) &lt; 0)
    {
        ....
    }
}

/* catalog.h */

#define TABLESPACE_VERSION_DIRECTORY    "PG_" PG_MAJORVERSION"_" \
                                CppAsString2(CATALOG_VERSION_NO)

/* catversion.h */

#define CATALOG_VERSION_NO  201608131


I found PG_9.6_201608131 is made up of three parts.


  'PG_'  +  PG_MAJORVERSION  + '_' + CATALOG_VERSION_NO


In PostgreSQL9.6 

PG_MAJORVERSION is 9.6

CATALOG_VERSION_NO is 201608131

PG_MAJORVERSION and CATALOG_VERSION_NO both are macro definition in c, it won't change.