I don’t understand why you are using an older version of PostgreSQL than would have been installed or upgraded for [v1.9.0.beta17 +38]
Did you install by some method other than the official Discourse install method? See the official install method at discourse/docs/INSTALL.md at main · discourse/discourse · GitHub
Whatever you do make sure that you have a backup.
Check that you have enough disk space for the PostgreSQL upgrade. They say you need free space twice the size of the database:
The other two topics I posted previously may also help but I’m not sure of the source of your problem.