• Errors install:

    PHP Warning:  file_put_contents(/var/www/wordpress/wp-content/database/debug.txt): failed to open stream: Too many open files in /var/www/wordpress/wp-content/plugins/sqlite-integration/pdoengine.class.php on line 1136
    [Tue Sep 23 11:47:03 2014] PHP Fatal error:  Call to a member function prepare() on a non-object in /var/www/wordpress/wp-content/plugins/sqlite-integration/pdoengine.class.php on line 615

    Configuration:
    Mac OS X 10.8.1, php 5.5, with start builtin web-server:
    php -S 0.0.0.0:80 -t /var/www/wordpress

    Found problem: too many pdo sqlite db connect (WTF?)
    Solved solution: make one global pdo object and reuse.
    Patch:

    diff -ur /Users/User/Projects.files/tests/wordpress/sqlite-integration/pdoengine.class.php sqlite-integration/pdoengine.class.php
    --- /Users/User/Projects.files/tests/wordpress/sqlite-integration/pdoengine.class.php	2014-09-04 21:18:50.000000000 +0400
    +++ sqlite-integration/pdoengine.class.php	2014-09-23 14:05:51.000000000 +0400
    @@ -213,13 +213,14 @@
     			do {
     				try {
     					if ($locked) $locked = false;
    -					$this->pdo = new PDO(
    +					$this->pdo = empty($GLOBALS['PDO_SQLite']) ? new PDO(
     						$dsn,  // data source name
     						null,  // user name
     						null,  // user password
     						array( // PDO options
     							PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
    -							));
    +							)) : $GLOBALS['PDO_SQLite'];
    +					$GLOBALS['PDO_SQLite'] = $this->pdo;
     					$statement        = $this->pdo->query("SELECT COUNT(*) FROM sqlite_master WHERE type='table'");
     					$number_of_tables = $statement->fetchColumn(0);
     					$statement        = null;
    @@ -254,6 +255,7 @@
     				$this->set_error(__LINE__, __FUNCTION__, $message);
     				return false;
     			}
    +			$GLOBALS['PDO_SQLite'] = $this->pdo;
     			$this->make_sqlite_tables();
     		}
     	}

    https://www.ads-software.com/plugins/sqlite-integration/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author kjmtsh

    (@kjmtsh)

    Thank you for reporting and trying the plugin, igk1972.

    I don’t have a machine running OS X, so I can’t test on that environment. I’ve been testing the plugin on Debian, FreeBSD and Windows, but I’ve never had that error or warning.

    Found problem: too many pdo sqlite db connect (WTF?)

    How did you know that ‘db connect’ is too many not that ‘open files’ are too many? The former would be a PDO library problem and the latter would be an available resource problem.

    I wrote the test code and checked on my environments.

    <?php
    class Test extends PDO {
        public $pdo;
        function __construct() {
            $counter = 0;
            while (true) {
                $this->pdo = new PDO('sqlite:test.db', null, null, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
                $this->pdo->query("SELECT COUNT(*) FROM sqlite_master WHERE type='table'");
                echo $counter++ . ' ';
                if ($counter > 10000) break;
            }
        }
    }
    $test = new Test();
    ?>

    No problem. Even ten times 10000, no problem. This is because a referecne to PDO instance is not a file descriptor.

    I’m afraid your problem comes not from the number of the references PHP uses but from server resources. The available resources of Apache built in OS X seems to be more restricted than other server oriented OS. I hear OS X’s ulimit is set to 256 by default (is it true? I’m not sure). How about the max open files of Apache?

    $cat /proc/`pidof -s apache2`/limits | grep 'open files'
    Max open files              8192              8192             files

    This is my Debian box’s default value per process. TCP sockets are included in that value. You might succeed in installing with more resources to Apache.

    Hope this will help. Thanks.

    Thread Starter igk1972

    (@igk1972)

    Hi!
    You dont understand me (((

    No apache. No mod_php. No php-fpm.

    This is ultra developer mode on my Mac in travel.

    Install php 5.4 (and higher), instal WP 4.0 to folder ‘wordpress’, install plugin sqlite-integration, and run in terminal:
    $php -S 0.0.0.0:8000 -t wordpres
    Open browser https://localhost:8000/ and try install WP

    Function db_conect call many times (((( I log this calls.

    After my patch – db_connect one call, and WP install successfull.

    Thread Starter igk1972

    (@igk1972)

    I know about OS X’s ulimit 256 by default – this is true.

    But many times calls db_connect – no right way.

    Plugin Author kjmtsh

    (@kjmtsh)

    I tried installing with PHP built in server, but couldn’t reproduce any problems. Anyway, I include your patch a little modified for the possible problem on OS X. I already committed the change. Will you check the developer version? If you have time, of course.

    Thanks.

    Thread Starter igk1972

    (@igk1972)

    Greate! Work fine on Mac 10.9.

    But development version have little type error in line 173:
    $dsn = ‘sqlite’ . FQDB;
    right
    $dsn = ‘sqlite:‘ . FQDB;
    missed “:” (colon).

    Plugin Author kjmtsh

    (@kjmtsh)

    Ooops! I fixed the typo and committed. Thank you again.

    If you find other problems, let me know.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Too many open files – Too many PDO connect’ is closed to new replies.