I have Drupal 7.21 installation based on 2 web servers (Red Hat Linux, Apache, PHP, MySQL, APC). Servers have same configuration, code base and work with same database. I get this error from time to time on one (not both) server at the same time:
[Thu Jun 20 13:18:48 2013] [error] [client XXX.XX.XX.XX] PHP Fatal error: Call to a member function getKey() on a non-object in /web/20130607-0825/includes/database/query.inc on line 341
Investigation lead me to this part of code:
<?php
public function __construct(DatabaseConnection $connection, $options) {
$this->uniqueIdentifier = uniqid('', TRUE);
$this->connection = $connection;
$this->connectionKey = $this->connection->getKey();
$this->connectionTarget = $this->connection->getTarget();
$this->queryOptions = $options;
}
?>
where $connection is NULL for some reason. I can't debug since it is production, but i have printed stack trace - and i see that error happens during bootstrap of variables, db_insert while setting lock in semaphore table.
This problem bothers me for about 2-3 weeks and i have no idea how to debug/investigate it. It is flexible, i can't reproduce it on demand. It stops when i restart httpd service. I tried to disable APC cache, but problem stays. I can connect to database via mysql client normally when errors appear.
How this could happen on servers with same config and code? I will appreciate any help.