[ZBXNEXT-2254] error after sucessfull zabbix_server upgrade - wrong sql command on postgres Created: 2014 Feb 12 Updated: 2014 Jun 19 Resolved: 2014 Jun 16 |
|
Status: | Closed |
Project: | ZABBIX FEATURE REQUESTS |
Component/s: | Proxy (P), Server (S) |
Affects Version/s: | 2.2.1 |
Fix Version/s: | 2.3.1, 2.3.2 |
Type: | New Feature Request | Priority: | Blocker |
Reporter: | Tomas Pipo | Assignee: | Krists Krigers (Inactive) |
Resolution: | Fixed | Votes: | 1 |
Labels: | dbpatches, postgresql, sql | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified | ||
Environment: |
Red Hat Enterprise Linux Server release 6.3 - 64 bit, Postgresql 9.2.4, Zabbix 2.2.1, php 5.3.3, repozitory EPEL - http://dl.fedoraproject.org/pub/epel/6/x86_64/ |
Attachments: | zabbix-2.2.2-sql_schema.diff |
Description |
I upgraded zabbix installation from 2.0.9 to 2.2.1. I executed new zabbix_server binary for the first time and database tables were upgraded successfully. Then I tried to restart zabbix server and in zabbix log appeared: After successfull upgrade zabbix_server run this sql command: Unfortunately, this sql command will always return zero, because all zabbix tables belongs to schema named zabbixp in my case. There is no default public schema because of security reasons. First solution: Second solution: select 1 from information_schema.tables where table_name='dbversion'; Thank you |
Comments |
Comment by Tomas Pipo [ 2014 Feb 14 ] |
The schema name 'public' is also in php frontend file include/classes/db/PostgresqlDbBackend.php. Setting frontend parametr $DB["SCHEMA"] in zabbix.conf.php has no effect and is applicable for DB2 only. Is possible allow usage of this parametr for postgresql too? |
Comment by Tomas Pipo [ 2014 Feb 20 ] |
I think more approach could be useful if you want to reproduce the error. Let's assume that I need new fresh installation of zabbix server 2.2.x. 1. connect to postgresql by superuser 'postgres' and create db user zabbix_tester - CREATE ROLE zabbix_tester WITH NOSUPERUSER; ALTER ROLE zabbix_tester WITH LOGIN;\password zabbix_tester Starting Zabbix server: [ OK ] Explicit searching for tables in schema 'public' will fail immediatelly. |
Comment by dakol [ 2014 Feb 25 ] |
Got same issue, here a patch which adds Schema support for PostgreSQL in
|
Comment by Tomas Pipo [ 2014 Feb 27 ] |
Dakol, thanks for your effort and this enablement patch. This is really issue and is necessary either to solve it or leave usage of postgresql for zabbix 2.2.x. I'll try your patch ASAP. |
Comment by Tomas Pipo [ 2014 Mar 17 ] |
This issue will always arise for zabbix 2.2.x, either for new installation or upgrade existing one. |
Comment by dakol [ 2014 Mar 25 ] |
@Tomas Pipo: is my patch working for you ? |
Comment by Tomas Pipo [ 2014 Mar 26 ] |
Yes!, thank you for this diff. I hope, that it'll be included in next versions soon. |
Comment by Juris Miščenko (Inactive) [ 2014 Apr 11 ] |
Implemented in svn://svn.zabbix.com/branches/dev/ZBX-7794 The DBSchema parameter in server and proxy configurations now applies to PostgreSQL databases as well as IBM DB2. |
Comment by Juris Miščenko (Inactive) [ 2014 Apr 11 ] |
(1) Frontend code must be adjusted accordingly. kristsk RESOLVED in r45953, branch svn://svn.zabbix.com/branches/dev/ZBXNEXT-2254. oleg.egorov CLOSED |
Comment by Tomas Pipo [ 2014 Apr 14 ] |
Thank you very much for such fast implementation. |
Comment by Andris Zeila [ 2014 Apr 30 ] |
(2) It would be better not forcing CONFIG_SCHEMA to "public" by default to keep the changes to minimum jurism Instead of settings a default value upon detecting an empty parameter it is supplied during checking for the existence of a table. RESOLVED. wiper CLOSED |
Comment by Andris Zeila [ 2014 Apr 30 ] |
(3) SQL statements must be written in lowercase jurism Corrected. RESOLVED. wiper CLOSED |
Comment by Juris Miščenko (Inactive) [ 2014 May 06 ] |
The development branch of this issue is now at svn://svn.zabbix.com/branches/dev/ZBXNEXT-2254 |
Comment by Andris Zeila [ 2014 May 21 ] |
(4) DBfield_exists() also should check for schema name when working with postgresql databases. jurism Filter added. RESOLVED. wiper CLOSED, please review my changes in r45894 |
Comment by Andris Zeila [ 2014 May 27 ] |
Successfully tested |
Comment by Juris Miščenko (Inactive) [ 2014 May 27 ] |
Fix merged in 2.3.1 (trunk) r45899 |
Comment by Krists Krigers (Inactive) [ 2014 May 29 ] |
(5) Documentation should be updated to show that in case PostgreSQL is used and $DB['SCHEMA'] in zabbix.conf.php is '' (empty string) default value 'public' is used for schema. Also commands to make psql use specific schema when creating database schema and loading initial data are: cat database/postgresql/schema.sql | PGOPTIONS='-c search_path=some_custom_schema' psql -d zabbix_database_name -h postgresql.server.host -U postgres_user cat database/postgresql/images.sql | PGOPTIONS='-c search_path=some_custom_schema' psql -d zabbix_database_name -h postgresql.server.host -U postgres_user cat database/postgresql/data.sql | PGOPTIONS='-c search_path=some_custom_schema' psql -d zabbix_database_name -h postgresql.server.host -U postgres_user |
Comment by Aleksandrs Saveljevs [ 2014 May 30 ] |
(6) Compiler gives a warning when server is compiled with MySQL:
db.c: In function ‘zbx_db_connect’:
db.c:212:6: warning: unused variable ‘rc’ [-Wunused-variable]
int rc, ret = ZBX_DB_OK;
^
jurism Variable moved to the correct part of code. Fixed in 2.3.1 (trunk) r45998. asaveljevs Looks good. CLOSED. |
Comment by Krists Krigers (Inactive) [ 2014 Jun 02 ] |
subissue (1) should be tested. |
Comment by Oleg Egorov (Inactive) [ 2014 Jun 13 ] |
(7) Coding styles:
kristsk RESOLVED in r46513. oleg.egorov CLOSED |
Comment by Oleg Egorov (Inactive) [ 2014 Jun 16 ] |
(8) Error message displaying in incorrect db schema pg_query() [<a href='function.pg-query'>function.pg-query</a>]: Query failed: ERROR: schema "public2" does not exist [setup.php:94 → CSetupWizard->__construct() → CSetupWizard->eventHandler() → CSetupWizard->checkConnection() → DBconnect() → DBexecute() → pg_query() in /var/www/oleg/ZBXNEXT-2254/frontends/php/include/db.inc.php:513] In frontend: kristsk RESOLVED in r46513. oleg.egorov CLOSED |
Comment by Oleg Egorov (Inactive) [ 2014 Jun 17 ] |
TESTED (FRONTEND) |
Comment by Krists Krigers (Inactive) [ 2014 Jun 19 ] |
Implemented frontend and merged to 2.3.2 (trunk) in r46700. |