0

I did use pg_upgrade.

I had a cluster of Postgresql with version 9.6 on my machine, and then I did start another cluster with version of v12. Each of them had separate data directories, in a directory scheme like this:

./postgresql/
├── 12
│   └── main
└── 9.6
    └── main

Then I turned off the 9.6 cluster and started using the v12 one. But now, by accident, I found out that some of the files in the base directory of the v12 cluster are not files, but symlinks to files in base directory of the 9.6 one; For example:

./postgresql/12/main/base/16401/35093 -> ./postgresql/9.6/main/base/16402/35093

Why is it so? And, more importantly, how is it so?! I mean, I thought that the files inside base directory are so internal to each DB that this could not be possible at all.

And, can I do something to disable using symlinks?

3
  • 1
    Urgh. Danger Will Robinson! Mar 30, 2021 at 18:49
  • did you run any pg_upgrade ?
    – channa
    Mar 30, 2021 at 19:45
  • @ShiwanginiShishulkar yes I did use pg_upgrade.
    – sazary
    Mar 31, 2021 at 14:38

1 Answer 1

1

This is the result of a pg_upgrade with the -k option, and these are not symbolic links, but hard links.

If you didn't manage to start the old cluster after pg_upgrade everything is fine. You just forgot to remove the old cluster after upgrading. Do that right now:

rm -rf /var/lib/postgresql/9.6/main

If you use -k, the upgrade process doesn't copy, but link the files. That makes the upgrade much faster, but renders the old cluster unusable.

4
  • I did use pg_upgrade and the older cluster isn't running, but anyway I don't like it the way it is! Isn't there any other option than dumping and init again? Because it's a large DB
    – sazary
    Mar 31, 2021 at 14:39
  • and, If it so bad that I should dump & init again, why the hell does pg_upgrade does that?!
    – sazary
    Mar 31, 2021 at 14:44
  • the old cluster isn't running after the upgrade, but I still don't understand: the only option to turn those hard links to normal files is to delete the source of links?
    – sazary
    Mar 31, 2021 at 14:58
  • 1
    Ok, if you never started the cluster, there is no problem. Remove the old data directory as my updated answer says. Mar 31, 2021 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.