PostgreSQL failure on test database for Rails application - postgresql

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.

Related

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

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

(Postgres) ERROR: could not access file "$libdir/uuid-ossp": No such file or directory

I installed curl on my machine today by running brew install curl, and it installed curl but also ended up updating a bunch of other packages, including my postgres (I'm using postgresql12)
I end up running any insert statement (which will insert a primary key automatically), and I get this error:
[58P01] ERROR: could not access file "$libdir/uuid-ossp": No such file or directory
When I run select * from pg_extension, I see that I have uuid-ossp installed as an extension, so I do not know why it is not able to find this.
I am using MacOS
This isn't an answer to my question because I went to a last resort, but I ended up just reinstalling postgres: https://bitadj.medium.com/completely-uninstall-and-reinstall-psql-on-osx-551390904b86
I would still like to hear other answers on the matter, as I would not recommend my answer unless absolutely necessary

Error installing PostGIS for PostgreSQL on Mac

I'm trying to install PostgreSQL with its PostGIS extension on Mac. The installation happens in two parts : 1) PostgreSQL and 2) PostGIS through the stack builder. The first phase goes smoothly, but the second phase returns the following error at the beginning of the installation of PostGIS:
I trying installing it with the latest version of PostgreSQL as well (version 12), and I get the same error. Any idea what is happening here?
I have the same issue when I install PostGIS by Stack Builder on MacOS.
After many times trying to install/uninstall PostGIS. Finally, I installed it successfully by manual installation.
I think this issue caused by your MacOS doesn't have or conflict in the default app for extracting .zip file.
I have fixed it by install manually, like the following:
Download PostGIS by Stack Builder as usual
Open the folder where you have downloaded PostGIS (often it is /Users/yourUserName)
Extract the PostGIS zip file (the file name like this: edb_postgis_...)
Install PostGIS app
Finally, everything is done! You have installed it successfully!

Troubleshooting PostgreSQL performance issue

I have a data ware house running on PostgreSQL and I would like to check what all are the missing indices are in my database.
I tried to install the extension pg_qualstats but it is giving the below error.
root#Ubuntu-1604-xenial-64-minimal ~ # sudo pip install pg_qualstats
Collecting pg_qualstats
Could not find a version that satisfies the requirement pg_qualstats (from versions: )
No matching distribution found for pg_qualstats
You are using pip version 18.1, however version 19.2.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
root#Ubuntu-1604-xenial-64-minimal ~ #
So how can i install this extension? I tried the CREATE EXTENSION pg_qualstats but it was giving error.
Also is there any other database maintenance need to be done for the database regularly?
What all parameter I have to check?
Can we automate the maintenance activity?
I was a SQL server DB admin and it was much easier to find out the missing index, understand the execution plan, DB maintenance but I find it hard, when it comes to PostgreSQL.
So any guidance will be of great help.
I am only answering the immediate question regarding the installation of pg_qualstats - the rest of the questions are way too broad for a platform like stackoverflow (or dba.stackexchange).
Many interesting extensions are provided as source code in Postgres (that's one of the reasons why it's highly recommended to run Postgres on Linux, because compiling the extensions is way easier in Linux than it is on Windows, and may extensions are only developed for Linux).
pg_qualstats is no different.
It is provided together with PoWA and the installation of the extension is documented as part of their installation guide
In a nutshell:
Download the source:
wget https://github.com/powa-team/pg_qualstats/archive/1.0.7.tar.gz -O pg_qualstats-1.0.7.tar.gz
tar zxvf pg_qualstats-1.0.7.tar.gz
cd pg_qualstats-1.0.7
the compile it:
make
make install
Register the shared libraries by editing postgresql.conf and after restarting Postgres the extension can be created using CREATE EXTENSION pg_qualstats;

Failed to install PostgreSQL 8.3, failed to run initdb:1?

I am reinstalling PostgreSQL using pgInstaller postgresql-8.3.16-1. An Error occurs in the last step of the install process:
Failed to run initdb:1!
\tmp\initdb.log shows this message:
The application has failed to start because its side-by-side
configuration is incorrect. Please see the application event log or
use the command-line sxstrace.exe tool for more detail.
The message is quite simple but I can't locate the root cause of the install failure.
Any one knows what's the reason?
You probably already have a database cluster installed in the location where your Posgres8.3 install is trying to init a new one. You can't really mix and match versions like that.
If possible, install the old version you had when you created the existing database. Then use pg_dumpall to create a .SQL dump of all of your data. You can then move or delete the old database (usually at /var/lib/pgsql) and install the new version. finally, apply the database dump to get the old data back.
For more details on this, read the Upgrading a PostgreSQL cluster manual page.
If you are installing the same version, there's no need to upgrade the cluster, you can probably safely ignore errors about initdb, so long as everything runs Ok.