1

Topic: Fresh Install of Indicia Warehouse - "Unable to Complete Request"

Hi All,

I've got a very perplexing error that I can't work out the solution to...

I had managed to install the Indicia warehouse on my web server but, for various reasons, I needed to remove it and do a clean install. So I deleted the indicia directory and all its contents and re-uploaded the source files.

Now, when I try to start the configuration process by navigating to mydomain/indicia/ the screen simply says "Unable to Complete Request".

When I check the application/logs file, it contains an error

error: Uncaught ErrorException: mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

This seems odd as a) all the other MySQL-driven applications running on the same server have not failed, so the MySQL service is clearly running, b) this has only started happening after I removed the previous installation and replaced it with a clean install and c) Why would the application be trying to establish a MySQL connection before it can display the configuration pages?

I'm totally scratching my head! Can anyone help me solve this error and achieve a clean installation?

2

Re: Fresh Install of Indicia Warehouse - "Unable to Complete Request"

Hi
I think that error will occur if your login session was still active when you removed and reinstalled the warehouse. You could clear your browser session cookies to fix this.
Cheers
John

John van Breda
Biodiverse IT

3

Re: Fresh Install of Indicia Warehouse - "Unable to Complete Request"

You are a star! Thank you very much! I got so caught up looking for MySQL connection errors that I didn't think to try that.

4 (edited by Ambulare 24-03-2014 17:20:35)

Re: Fresh Install of Indicia Warehouse - "Unable to Complete Request"

Next problem, if anyone can help:

I've successfully installed the warehouse and logged in to the admin control panel.

I got a message saying

your database needs to be upgraded as the application version is 0.9.0 but the database is version 0.8.

When I click "Run Upgrade" I get

"The upgrade failed.

An error occurred during the upgrade.

The error was described as:
There was an SQL error: ERROR: relation "cache_termlists_terms" does not exist LINE 101:"

and the log files show

2014-03-24 17:15:14 +00:00 --- error: Error in file: /var/www/html/indicia/modules/indicia_setup/db/version_0_9_0/201312121216_media_files.sql
2014-03-24 17:15:14 +00:00 --- error: There was an SQL error: ERROR:  relation "cache_termlists_terms" does not exist

Can anyone suggest a way forward?

5

Re: Fresh Install of Indicia Warehouse - "Unable to Complete Request"

Hi

Indicia has a system for applying database updates on the one hand and an extensible architecture on the other. What I observe is that the error is a complaint from an upgrade to the core system due to the absence of a table created by a module.

The core database updates are applied first and then the module database updates. I can see that a new install could well encounter this problem and a fix may be needed.

I haven't experienced this problem because we upgraded from version 8 to version 9 so the cache_termlists_terms table did exist for us when the core update was applied.

As a workaround, what I think you need to achieve is a change in the order with which the updates are applied. You could try the following although I may be being too simplistic.

Find the file modules/cache_builder/db/version_0_1_0/201202090851_cache_termlists_terms.sql and
  -- move it to modules/indicia_setup/db/version_0_9_0,
  -- rename it to 201312120000_cache_termlists_terms.sql
  -- then run the upgrade again.

What I am proposing with this is to move the creation of the cache_termlists_terms table in to the core updates so that it is executed immediately before the media_files.sql. It might just work.

Jim Bacon.

6

Re: Fresh Install of Indicia Warehouse - "Unable to Complete Request"

Thanks Jim,

I've tried that suggestion and I'm now seeing

2014-03-25 10:16:16 +00:00 --- error: Error in file: /var/www/html/indicia/modules/indicia_setup/db/version_0_9_0/201403051014_cascade_on_delete.sql
2014-03-25 10:16:16 +00:00 --- error: There was an SQL error: ERROR:  relation "cache_occurrences" does not exist

7

Re: Fresh Install of Indicia Warehouse - "Unable to Complete Request"

That's good! We made some progress. This error message can be explained in exactly the same way. The core update is trying to reference a module table that has not yet been created.

I suggest the quickest workaround for this one is to edit modules/indicia_setup/db/version_0_9_0/201403051014_cascade_on_delete.sql and delete line 42, the one which reads

DELETE FROM cache_occurrences WHERE sample_id in (select id from samples where deleted=true);

Since this is a fresh install your cache and samples tables are empty so the line is superfluous.

Re-run the upgrade after editing the file and, if we are lucky, it will now run to completion.

Jim Bacon

8

Re: Fresh Install of Indicia Warehouse - "Unable to Complete Request"

Excellent! I think we're getting there. It's now run through the automated scripts without any errors, but the last stage is a manual update to the database.

The following script includes changes which need to be run against the database using the postgres root user account. Please run them manually as the may take a while to run and could cause a timeout if ran through the standard web interface upgrade process.

-- #slow script#

-- create 1km index 

INSERT INTO map_squares (geom, x, y, size)
SELECT DISTINCT on (
      round(st_x(st_centroid(reduce_precision(coalesce(s.geom, l.centroid_geom), o.confidential, 
          GREATEST(o.sensitivity_precision, 1000), coalesce(s.entered_sref_system, l.centroid_sref_system))))),
      round(st_y(st_centroid(reduce_precision(coalesce(s.geom, l.centroid_geom), o.confidential, 
          GREATEST(o.sensitivity_precision, 1000), coalesce(s.entered_sref_system, l.centroid_sref_system))))),
      GREATEST(o.sensitivity_precision, 1000)
  )
  reduce_precision(coalesce(s.geom, l.centroid_geom), o.confidential, 
      GREATEST(o.sensitivity_precision, 1000), coalesce(s.entered_sref_system, l.centroid_sref_system)),
  round(st_x(st_centroid(reduce_precision(coalesce(s.geom, l.centroid_geom), o.confidential, 
      GREATEST(o.sensitivity_precision, 1000), coalesce(s.entered_sref_system, l.centroid_sref_system))))),
  round(st_y(st_centroid(reduce_precision(coalesce(s.geom, l.centroid_geom), o.confidential, 
      GREATEST(o.sensitivity_precision, 1000), coalesce(s.entered_sref_system, l.centroid_sref_system))))),
  GREATEST(o.sensitivity_precision, 1000)
FROM samples s
JOIN occurrences o ON o.sample_id=s.id
LEFT JOIN locations l on l.id=s.location_id AND l.deleted=false
WHERE coalesce(s.geom, l.centroid_geom) IS NOT NULL;
...etc

When I try to run this batch of SQL, I get

ERROR:  relation "map_squares" does not exist

Is there a script I need to run to create this object first?

Thank you.

9

Re: Fresh Install of Indicia Warehouse - "Unable to Complete Request"

I observe that you are being asked to apply the update contained in modules/cache_builder/db/version_0_1_2/201308161718_map_squares_populate.

This should have been preceded by 201308161717_map_squares in the same folder which creates the table.

If we are lucky and your log level is set to debug you could look in application/logs/today's log and see the list of updates that have  been applied.

I have a hope that the map_squares update has been applied and that you could find the table if you were using pgAdmin and were to browse through the list of tables.

If that is the case then my guess would just be that we need to qualify the tables in the query you are trying to apply with the schema name as Postgres is not looking in the right place for them. Better still, set the search path to tell Postgres where to look by executing

SET search_path = indicia, public, pg_catalog;

where I am expecting indicia to be the schema name for your installation. You may even like to alter your user so that you don't need to keep setting the search path.

Jim Bacon.

10

Re: Fresh Install of Indicia Warehouse - "Unable to Complete Request"

Cheers Jim, that seemed to run without errors.

Many thanks for all your help.