6.0.0-git
2021-01-18

[#8435] lots of "DB Error: unknown error: INSERT INTO" when Horde_Cache is enabled
Summary lots of "DB Error: unknown error: INSERT INTO" when Horde_Cache is enabled
Queue Horde Base
Queue Version 3.2.2
Type Bug
State Resolved
Priority 1. Low
Owners jan (at) horde (dot) org
Requester tek (at) dgap (dot) mipt (dot) ru
Created 2009-07-15 (4205 days ago)
Due
Updated 2009-08-14 (4175 days ago)
Assigned 2009-07-20 (4200 days ago)
Resolved 2009-08-14 (4175 days ago)
Milestone
Patch No

History
2009-08-14 21:42:52 Jan Schneider Comment #5
Assigned to Jan Schneider
State ⇒ Resolved
Reply to this comment
Fixed in CVS.
2009-08-11 23:50:35 tek (at) dgap (dot) mipt (dot) ru Comment #3 Reply to this comment
If we change Horde_Cache_sql->set() method to get backtrace:



horde/lib/Horde/Cache/sql.php



   function set($key, $data, $lifetime = null)

     {

                ...

                $result = $this->_write_db->query($query, $values);

         if (is_a($result, 'PEAR_Error')) {

         // debug

                 debug_print_backtrace();

                 print "<br>\n********$data#######<br>\n";

         //debug

             Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);

             return false;

         }



         return true;

     }



we'll find for these type of errors:



[imp] DB Error: unknown error:

INSERT INTO horde_cache (cache_id, cache_timestamp, cache_expiration, 
cache_data)

VALUES ('8c2efd26a50e2900dc587d3922519a65', 1249954083, 1250040483, FALSE)

[nativecode=ERROR:  column "cache_data" is of type text but expression 
is of type boolean HINT:  You will need to rewrite or cast the 
expression.]

[pid 4142 on line 226 of 
"/var/www/localhost/htdocs/horde/lib/Horde/Cache/sql.php"]



backtraces like these:



#0 Horde_Cache_sql->set(perm_exists_imp:create_folders, ) called at 
[/var/www/horde_test/htdocs/horde/lib/Horde/Perms/datatree.php:202]

#1 Perms_datatree->exists(imp:create_folders) called at 
[/var/www/horde_test/htdocs/horde/imp/lib/IMP.php:876]

#2 IMP::hasPermission(create_folders) called at 
[/var/www/horde_test/htdocs/horde/imp/lib/IMP.php:588]

#3 IMP::flistSelect(Messages to, 1, Array (), , 1, 1, , 1) called at 
[/var/www/horde_test/htdocs/horde/imp/mailbox.php:304]

  ********#######

  #0 Horde_Cache_sql->set(perm_exists_imp:max_folders, ) called at 
[/var/www/horde_test/htdocs/horde/lib/Horde/Perms/datatree.php:202]

#1 Perms_datatree->exists(imp:max_folders) called at 
[/var/www/horde_test/htdocs/horde/imp/lib/IMP.php:876]

#2 IMP::hasPermission(max_folders) called at 
[/var/www/horde_test/htdocs/horde/imp/lib/IMP.php:589]

#3 IMP::flistSelect(Messages to, 1, Array (), , 1, 1, , 1) called at 
[/var/www/horde_test/htdocs/horde/imp/mailbox.php:304]

  ********#######



There are two ways to storage permissions: datatree and sql.

If we change backend for permissions to sql, then errors will disappear.



If we compare code for "Perms_[datatree/sql]->set()":



horde/lib/Horde/Perms/sql.php

------------------

     function exists($permission)

     {

         $key = 'perm_exists_' . $permission;

         $exists = $this->_cache->get($key, 
$GLOBALS['conf']['cache']['default_lifetime']);

         if ($exists === false) {

             $this->_connect();

             $query = 'SELECT COUNT(*) FROM horde_perms WHERE perm_name = ?';

             $exists = $this->_db->getOne($query, array($permission));

             if (is_a($exists, 'PEAR_Error')) {

                 return $exists;

             }



             $this->_cache->set($key, $exists);

         }



         return (bool)$exists;

     }



horde/lib/Horde/Perms/datatree.php

-------------------

    function exists($permission)

     {

         $key = 'perm_exists_' . $permission;

         $exists = $this->_cache->get($key, 
$GLOBALS['conf']['cache']['default_lifetime']);

         if ($exists === false) {

             $exists = $this->_datatree->exists($permission);

             $this->_cache->set($key, $exists);

         }



         return (bool)$exists;

     }



It seems that reason for errors is lack of return value check in 
horde/lib/Horde/Perms/datatree.php

after "$exists = $this->_datatree->exists($permission)" call before 
"_cache->set()" like in Perms/sql.php backend.



Simple workaround.

Change backend for permission from datatree to SQL , login to the 
horde to create entries for create_folders, max_folders, change driver 
back to datatree.
2009-08-03 15:19:23 Jan Schneider State ⇒ No Feedback
 
2009-07-20 15:36:55 Jan Schneider Comment #2
State ⇒ Feedback
Reply to this comment
There have been several fixes for PostgreSQL since then, please try a 
more recent version first.
2009-07-15 15:56:46 tek (at) dgap (dot) mipt (dot) ru Comment #1
Type ⇒ Bug
State ⇒ Unconfirmed
Priority ⇒ 1. Low
Summary ⇒ lots of "DB Error: unknown error: INSERT INTO" when Horde_Cache is enabled
Queue ⇒ Horde Base
Milestone ⇒
Patch ⇒ No
Reply to this comment
I have just upgraded to Horde 3.2.2 and IMP 4.1.6 and get them working 
with PostgreSQL backend. Everything seems to be working just fine, but 
in logs, i got a lot of error messages on horde_cache tables:



[horde] DB Error: unknown error: INSERT INTO horde_cache (cache_id, 
cache_timestamp, cache_expiration, cache_data) VALUES 
('6ce9d5bdf7e6e1eee4e790cbd156b7af', 1247666680, 1247753080, FALSE) 
[nativecode=ERROR:  column "cache_data" is of type text but expression 
is of type boolean HINT:  You will need to rewrite or cast the 
expression.] [pid 32594 on line 226 of 
"/var/www/localhost/htdocs/horde/lib/Horde/Cache/sql.php"]

...

[imp] DB Error: unknown error: INSERT INTO horde_cache (cache_id, 
cache_timestamp, cache_expiration, cache_data) VALUES 
('e629f174ffe682593097290b886eaae2', 1247672866, 1247759266, FALSE) 
[nativecode=ERROR:  column "cache_data" is of type text but expression 
is of type boolean HINT:  You will need to rewrite or cast the 
expression.] [pid 3025 on line 226 of 
"/var/www/localhost/htdocs/horde/lib/Horde/Cache/sql.php"]



What other info is needed to fix this problem?

Saved Queries