HTTP 500 Bad SQL Grammar by SqlScriptRunner during module update on LabKey startup RHEL 7.3

Installation Forum (Inactive)
HTTP 500 Bad SQL Grammar by SqlScriptRunner during module update on LabKey startup RHEL 7.3 Jim Collett  2017-04-07 17:42
Status: Closed
 
Hello,

I seem to have correctly installed LabKey17.1-49816.20-community-bin on Red Hat Linux 7.3, but when I go to the LabKey homepage after Tomcat startup, I get the following HTTP error:

500: Unexpected server error

A failure occurred during LabKey Server startup.

org.labkey.api.data.SqlScriptRunner$SqlScriptException: exp-15.10-15.20.sql : SqlExecutor.execute(); bad SQL grammar []; nested exception is org.postgresql.util.PSQLException: ERROR: column "keyvariable" does not exist
       at org.labkey.api.data.SqlScriptManager.runScript(SqlScriptManager.java:220)
       at org.labkey.api.data.SqlScriptRunner.runScripts(SqlScriptRunner.java:82)
       at org.labkey.api.module.DefaultModule.versionUpdate(DefaultModule.java:332)
       at org.labkey.api.module.ModuleUpgrader.upgrade(ModuleUpgrader.java:82)
       at org.labkey.api.module.ModuleUpgrader.lambda$upgrade$0(ModuleUpgrader.java:94)
       at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.jdbc.BadSqlGrammarException: SqlExecutor.execute(); bad SQL grammar []; nested exception is org.postgresql.util.PSQLException: ERROR: column "keyvariable" does not exist......

Any ideas on how to fix this? The Tomcat default homepage loads fine, and I can see in postgres that the labkey database has been built. A file with the relevant labkey.log and labkey-errors.log entries is attached.
Thanks,
Jim
 
 
Jim Collett responded:  2017-04-07 19:56
Note: The error says "keyvariable", while the SQL statement in exp-15.10-15.20.sql says "KeyVariable"; is difference in capitalization a problem?


Error in labkey.log:

org.labkey.api.data.SqlScriptRunner$SqlScriptException: exp-15.10-15.20.sql : SqlExecutor.execute(); bad SQL grammar []; nested exception is org.postgresql.util.PSQLException: ERROR: column "keyvariable" does not exist


Spelling in /usr/local/labkey/modules/experiment/schemas/dbscripts/postgresql/exp-15.10-15.20.sql:

38     /* exp-15.11-15.12.sql */
39
40     ALTER TABLE exp.PropertyDescriptor RENAME COLUMN KeyVariable TO RecommendedVariable;
 
Jon (LabKey DevOps) responded:  2017-04-07 22:15
Hi Jim,

Unless the fieldname is in quotes, PostgreSQL treats things as case insensitive, so there wouldn't be a difference between keyvariable vs KeyVariable.

Is this a new install of LabKey or is this an upgrade to a previous version of LabKey? If so, what version were you upgrading from?

Was this install or upgrade ever stalled and then restarted mid-installation/mid-upgrade when you were working on it?

Also, can you send us the full labkey.log file that generated so we can see what occurred prior to the error?

Regards,

Jon
 
Jim Collett responded:  2017-04-08 10:27
Hi Jon - thanks for the prompt response!

The whole labkey.log file is attached.

This is a new installation of LabKey.

I don't have any evidence that the current installation was stalled and restarted.

When I first tried to access LabKey after installation, I got an HTTP 404 page not found error due to Tomcat not having proper permission to access the .jar files. I fixed this, and then got the HTTP 500 LabKey server error I previously described.

I had first set up labkey.xml with the db user as "labkey" and a password, and had created a "labkey" postgres role with access only to the labkey database. Thinking that there might be some problem with these limited postgres privileges, I stopped Tomcat, added a "tomcat" role with superuser privileges to postgres, changed the db user in labkey.xml to "tomcat", dropped the existing labkey database and "labkey" role from postgres, and then restarted Tomcat. Upon trying to access the LabKey webapp via HTTP, I wound up with the same HTTP 500 LabKey server error as before. Looking at postgres, I confirmed that the webapp had rebuilt the labkey database.

I had also changed the pg_hba.conf file to require passwords (as shown below) thinking that a script could be expecting postgres to ask for a password, since labkey.xml requires a db pasword. I'm now able to directly log into the labkey database via psql as "tomcat", and am correctly prompted for a password when I do.

pg_hba.conf settings:
# TYPE DATABASE USER ADDRESS METHOD

# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
#host all all 127.0.0.1/32 ident
#host all all 127.0.0.1/32 trust
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 ident
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication postgres peer
#host replication postgres 127.0.0.1/32 ident
#host replication postgres ::1/128 ident


Thanks,

Jim
 
Jon (LabKey DevOps) responded:  2017-04-10 15:22
Hi Jim,

The database user should be an admin or at the very least, have the permissions to:

1. Create a new database
2. Create, Update, and Delete schemas
3. Create, Update, and Delete tables
4. Create, Update, and Delete queries
5. Create, Update, and Delete rows
6. And be able to run a SELECT on everything of course

Looking over the error, it looks like the database was partially created here.

Since this is a new installation, can you delete the LabKey database and then restart Tomcat again? If your database user has been given enough permission, it will automatically create the DB, schema, tables, and everything else that is needed on the DB and we should avoid seeing the error again.

Regards,

Jon
 
Jim Collett responded:  2017-04-11 10:04
Hi Jon,

I followed your instructions, and the LabKey server came up correctly with the initial configuration home page. You can close out this issue.

Thanks!

Jim
 
Jon (LabKey DevOps) responded:  2017-04-11 10:46
Glad to hear your server came up now Jim!

We'll close this out!

Regards,

Jon