"Server closed the connection unexpectedly" when installing PostGis on OS X with M1 chip - postgresql

I am attempting to install Postgis on my newly created Postgresql DB and am running into issues doing so.
Environment
OS X (Big Sur, 11.2.3 with a M1 chip)
Postgresql version: stable 14.3, installed with homebrew (more precisely, with the following syntax: arch -arm64 brew install postgresql)
Postgis version: stable 3.2.1, installed with homebrew (same)
What I'm trying to do
I want to install postgis on my postgresql database as such.
Christophers-MacBook-Air:postgres root# psql -U chrisneve -d mydbname
psql (14.3)
Type "help" for help.
mydbname=# create extension postgis;
The problem
The above snippet generates this error.
mydbname=# create extension postgis;
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
!?>
Before trying with psql directly, I executed the same command using DataGrip, which generated this error. (I also tried with the "cascade" mode: create extension postgis cascade, which generated the same result).
mydbname.public> create extension postgis
[2022-05-28 10:55:30] An I/O error occurred while sending to the backend.
[2022-05-28 10:55:30] Unrecoverable error received, the connection is spoiled
DataGrip also displayed a popup-style error saying this.
Error [57P03]: FATAL: the database system is in recovery mode
What I tried
I initially didn't know exactly where the error lied, so I started by asserting that the problem wasn't with the creation of extensions (for whatever reason).
select * from mydbname.pg_catalog.pg_extension
drop extension plpgsql
create extension plpgsql
This worked just fine; other extensions load fine.
Realising the issue seemed to come from Postgis, I tried removing and reinstalling Postgis, and even Postgresql, with homebrew, multiple times. It changed nothing.
I then wanted to install Postgis from a different location of https://postgis.net/install/#binary-installers for OS X, but all other install mechanisms (other than homebrew) told me not to mix with other installations, so I didn't try them.
FWIW, I installed Postgis in the past on an identical DB on a Windows machine, so although I'm no Postgis expert I do know the install process.
It would be much appreciated if a Postgis maintainer could help me out with this. Is this a new bug with the M1 chips? I can provide logs if it helps.
Many thanks,
Chris

Related

Postgres extension missing after upgrade

I have just upgraded my development postgres cluster from postgreSQL 9.6 to 11. Everything went fine except that I got an error around the pgtap extension that I use for unit testing.
Now when I try to restore a database I'm getting an error
"ERROR: could not open extension control file "/usr/share/postgresql/11/extension/pgtap.control"
When I look in the file system I can see all the pgtap files are still in /usr/share/postgresql/9.6/extension.
I tried uninstalling pgtap running sudo apt-get purge --auto-remove pgtap and then re-installing but this hasn't worked, all the files are still in the 9.6 directory.
pgTAP is a third-party extension, you won't find anything about it in the PostgreSQL manual.
You will have to install it separately in your v11 PostgreSQL installation. See the installation instructions for pgTAP.

Upgrading postgresql on redhat failing "version"

I'm new to postgres, and the environment started with the redhat 64bit default install of 9.2. Postgres quickly shot from a proof of concept to everyone wanting a db, and I'm trying to get up to speed with 9.6.
When I run the upgrade, it errors with the following:
-bash-4.2$ /usr/pgsql-9.6/bin/pg_upgrade -b /bin -B /usr/pgsql-9.6/bin -d /var/lib/pgsql/9.2.old/data -D /var/lib/pgsql/9.6/data
Performing Consistency Checks
-----------------------------
Checking cluster versions
This utility can only upgrade to PostgreSQL version 9.6.
Failure, exiting
I'm ensuring that I'm calling the pg_upgrade in the new binary location. --read that in one article.
I have spent the better part of the morning searching google, and searching here...trying this and that. It's been an interesting, yet ridiculous worm hole.
I'm not using home brew or anything like that. I am just doing a yum install.
Can someone tell me, or point me to a good document that works around the glitches? The postgres manual document states that the pg_upgrade is valid from versions 8.4 up.
Any suggestions would be greatly appreciated.

How to install Postgis to a Keg installation of Postgres#9.6 using Homebrew?

I have installed Postgresql#9.6 and Postgis via Homebrew. However, installing Postgis via Homebrew installs the latest version of Postgresql at 10 as dependency and pinning Postgresql at 9.6.5 blocks the install of Postgis via Homebrew.
Performing 'CREATE EXTENSION postgis;' returns:
ERROR: could not open extension control file "/usr/local/Cellar/postgresql#9.6/9.6.5/share/postgresql#9.6/extension/postgis.control": No such file or directory
I've also tried uninstalling the Postgresql (at 10) and editing the Postgis formula to depend on Postgres#9.6 instead of Postgresql.
This is similar to How to install Postgis to a Keg installation of Postgres#9.5 using Homebrew? but with a later keg formula
I managed to do it after many combinations.
In a nutshell, solution is to install the old version of the original package postgres, switch to it, and install the old version of postgis.
Install postgres
1/ Install the current version of postgres (10.1 as speaking)
brew install postgres
2/ Install the old version of postgres using its old formula. Proper link can be found using github or git log on the Tap repo (/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/).
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/d014fa223f77bee4b4097c5e80faa0954e28182f/Formula/postgresql.rb
This will install the version 9.6.5 (last one before 10.x series).
3/ Switch to it so links are defaulted to postgres 9.6
brew switch postgres 9.6.5
Install postgis
4/ Install old version of postgis (2.3). This is using the same sha version of the Formula so everything is linked correctly (using the current postgis will expect postgresql 10, so it will end up to a version mismatch when initializing extension).
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/d014fa223f77bee4b4097c5e80faa0954e28182f/Formula/postgis.rb
Use them
5/ If required initialise the DB
initdb /usr/local/var/postgres
6/ Create and use your DB
createdb mydb
psql mydb
mydb=# CREATE EXTENSION postgis;
Installing PEX, a package manager for Postgresql allowed me to install Postgis for the keg version of Postgresql#9.6 and use CREATE EXTENSION postgis;
This isn't a Homebrew solution but after a lot of searching, it finally allowed me to use Postgis.
HelloI ran into this same problem of multiple implementation of pgsql versions including legacy ones. So after a bit of research I would like to share my solution.
Problem:
I am working on a macbook pro 2013 with 10.11 el capitan. I am GIS developer and extensive user of homebrew. I didn't pin the postgresql package for compatibility reasons. Thus, the package got updated to postgresql version 10.5 along other packages. This caused me to be unable to use postgresql version 9.4. The cleverest solution would have been to use a brew switch postgresql 9.4.19. Except that when compiling postgis 2.5.0 from osgeo/osgeo4mac it defautls (looks for) the postgresql binary folder to install the symlinked (or not) extensions. Here again another compatibility problem. One could tinker a bit with homebrew files and transfer files manually. That's ill advice...the package manager (homebrew) needs to stay a coherent ecosystem to provide for a stable workspace.
Proposed Solution:
Go here BigSQL and download the dmg of your chosen version
install the software where you want in your filesystem
within the installation folder you'll find a directory named pg9x ; x being the version number (e.g pg95 for postgresql 9.5 and so on...
in this folder you'll find a file named pg9x.env
source this file to your .profile with source /your/path/pg9x/pg9x.env line
in the main installation folder, for instance /your/path/pg9x/, you'll finde a python script called pgc, alias it to your .profile with alias pgc="your/path/pgc"
save your .profile and refresh your environment variable with source .profile on the command prompt
still within the command prompt, type pgc list, you'll get a list of installed packages. You'll see the version of postgesql you've downloaded
to install another version of postgresql, say 9.6, type pgc install pg96
to install postgis for pg95 type pgc install postgis22-pg95
to install postgis for pg96 type pgc install postgis23-pg96
now, after installation you'll need to initialize the downloaded component with pgc init pg96 or pgc init postgis23-pg96 etc...
to check if your daemon is running correctly type pgc status
to start a version daemon of your choice type for example pgc start pg95
to stop a version daemon of your choice type pgc stop pg95
the installation also comes with an LTS release of pgadmin3 that works fine with all versions (not the case of brew version of pgadmin3), this is very convenient
type pgc help for more options
Let the elephant dance^^
Hope this helps.
Spicy.
I faced a similar issue and what worked for me was to follow the instructions at https://github.com/CloverHealth/homebrew-tap, which seem similar in spirit to #Antwan's solution but with a few more clean up steps, also it gets slightly later versions: postgresql 9.6.10 and postgis 2.5.
My steps differed slightly from those at CloverHealth: My brew version no longer supports brew switch postgresql 9.6.10 and I tried first brew link postgresql#9.6.10 and then brew link postgresql#9.6 but both gave
Error: no such keg
Trying brew search postgresql showed a little green checkmark next to the cloverhealth Formulae, so I tried brew link cloverhealth/tap/postgresql and got
Warning: Already linked: /usr/local/Cellar/postgresql/9.6.10
So, ok it was already linked. Other than that my steps were the same as described at the CloverHealth page, and now I'm up and running again.

install pljava on Windows 7 with Postgres 9.6

I am struggling to install pljava on Windows 7 Sp1 with Postgres 9.6.
When I run the following command:
CREATE FUNCTION sqlj.java_call_handler()
RETURNS language_handler AS 'pljava'
LANGUAGE C;
I receive the following error:
ERROR: could not load library "C:/Program Files/PostgreSQL/9.6/lib/pljava.dll": The specified procedure could not be found.
It shouldn't be necessary at all to create the java_call_handler manually and such. The installation procedure changed with PL/Java 1.5.0 so you simply get a self-extracting jar that you run (with java -jarjarname) and then in psql you say CREATE EXTENSION pljava; and it's ready to use. (You may have to set one variable to the location of your Java runtime. Details in the installation docs.)
That said, PostgreSQL 9.6 has some problems with PL/Java 1.5.0 (9.5 works fine). PL/Java 1.5.1 will do 9.6, but it's not quite out yet. You can build from the tip of the REL1_5_STABLE branch if you do such things.

PostgreSQL failure on test database for Rails application

Upon running rake db:test:prepare my test database was dropped, but failed to be rebuilt. After researching the errors, I simply attempted to load the database with rake db:test:load to repopulate based on the schema.rb file. That call resulted in the following message
PG::Error: ERROR: could not open extension control file "/usr/pgsql-9.1/share/extension/postgis.control": No such file or directory
I've spent the day reinstalling postgresql-9.1 and postGIS 1.5.3 on a test server in every way I can find on the internet, and none of those installations produce the ever-elusive postgis.control file. Is there a special install I need to run on a CentOS6 machine to produce the binary? Or is there another way to run the rake tasks to test the psql database?
This message is shown for CREATE EXTENSION postgis; however the newer extension method was introduced for PostGIS 2.0. The version that you have installed does not support this method.
Either upgrade to PostGIS 2.0 (excellent RPMs for YUM here), or spatially enable a PostGIS 1.5 database using either a template or using enabler scripts. Details here.