This discussion is archived
1 2 3 Previous Next 31 Replies Latest reply: Jan 12, 2012 4:51 AM by 737935 RSS

unable to allocate memory for mutex; resize mutex region

560979 Newbie
Currently Being Moderated
Hello

I am run 08.php/09.php/10.php example from 'dbxml-2.5.16/dbxml/examples/php' and get error. How I can fix it?

16:23:26 ws # php 08.php
Create an use a transactional XML Container:
add a document, get the document, display the content of
the document.

EXPECTED RESULT:
book1 = <book><title>Knowledge Discovery in Databases.</title></book>
ACTUAL RESULT:
PHP Warning: xmlmanager::createcontainer(): (null) unable to allocate memory for mutex; resize mutex region
in /usr/local/dbxml/dbxml/examples/php/08.php on line 20
PHP Stack trace:
PHP 1. {main}() /usr/local/dbxml/dbxml/examples/php/08.php:0
PHP 2. xmlmanager->createcontainer() /usr/local/dbxml/dbxml/examples/php/08.php:20
PHP Fatal error: Uncaught exception 'xmlexception' with message 'Error: Cannot allocate memory' in /usr/local/dbxml/dbxml/examples/php/08.php:20
Stack trace:
#0 /usr/local/dbxml/dbxml/examples/php/08.php(20): xmlmanager->createcontainer('test.dbxml')
#1 {main}
thrown in /usr/local/dbxml/dbxml/examples/php/08.php on line 20
Ubuntu 10.10 (maverick)
PHP 5.3.3-1ubuntu9.1 with Suhosin-Patch (cli) (built: Oct 15 2010 14:00:18)
Oracle: Berkeley DB XML 2.5.16: (December 22, 2009)
Berkeley DB 4.8.26: (December 18, 2009)

--
Thanks, for advises
  • 1. Re: unable to allocate memory for mutex; resize mutex region
    637288 Journeyer
    Currently Being Moderated
    Hi,

    the error suggests that you might want to increase the number of mutexes. More info:
    http://www.systomath.eu/doc/BerkeleyDb-4.7/html/api_c/mutex_set_max.html

    Again, you may use a DB_CONFIG file for that.

    Don't forget to recreate your environment so that the changes take effect.

    Vyacheslav
  • 2. Re: unable to allocate memory for mutex; resize mutex region
    560979 Newbie
    Currently Being Moderated
    Vyacheslav, thx for replay.

    Same error.

    File 08.php:
    Create an use a transactional XML Container:
    add a document, get the document, display the content of
    the document.

    EXPECTED RESULT:
    book1 = <book><title>Knowledge Discovery in Databases.</title></book>
    ACTUAL RESULT:
    <?php
    $book_name = 'book1';
    $book_content = '<book><title>Knowledge Discovery in Databases.</title></book>';

    foreach(array_merge(glob("__db*"), glob("log.O"), glob("test*.dbxml")) as $file)
    {
    @unlink($file);
    }

    $env = new Db4Env();
    $env->open();
    $mgr = new XmlManager($env);
    $con = $mgr->createContainer("test.dbxml");
    $con->putDocument($book_name, $book_content);
    $doc = $con->getDocument($book_name);
    $s = $doc->getContentAsString();
    print $doc->getName(). " = $s\n";
    unset($doc);
    unset($con);
    $mgr->removeContainer("test.dbxml");
    $env->close();
    File DB_CONFIG. I am tried value 100, 1000, 1000:
    mutex_set_max 1000
    --
    Vitaliy
  • 3. Re: unable to allocate memory for mutex; resize mutex region
    637288 Journeyer
    Currently Being Moderated
    Hi Vitaly,

    - how did you recreate your environment?
    - try setting this value to 30000 (use the db_stat utility to make sure that changes took effect)
    - try do the same in the dbxml shell, not in PHP. Will you be able to reproduce an error?

    Vyacheslav
  • 4. Re: unable to allocate memory for mutex; resize mutex region
    560979 Newbie
    Currently Being Moderated
    Vyacheslav

    1. Environment is not created. PHP script created env and container.
    -rw-r--r-- 1 root 24576 2010-11-23 22:39 __db.001
    -rw-r--r-- 1 root 4562944 2010-11-23 22:39 __db.002
    -rw-r--r-- 1 root 270336 2010-11-23 22:39 __db.003
    -rw-r--r-- 1 root 163840 2010-11-23 22:39 __db.004
    -rw-r--r-- 1 root 802816 2010-11-23 22:39 __db.005
    -rw-r--r-- 1 root 49152 2010-11-23 22:39 __db.006
    -rw-r--r-- 1 libuuid 20 2010-11-23 22:39 DB_CONFIG
    -rw-r----- 1 root 16384 2010-11-23 22:39 __db.test.dbxml
    db_stat -d __db.test.dbxml
    lt-db_stat: unable to allocate memory for mutex; resize mutex region
    lt-db_stat: DB->open: __db.test.dbxml: Cannot allocate memory
    2. dbxml shell, without DB_CONFIG file.
    dbxml -c

    dbxml> createContainer 2.dbxml
    Creating node storage container

    dbxml>
    -rw-r----- 1 root 24576 2010-11-23 22:34 __db.001
    -rw-r----- 1 root 5939200 2010-11-23 22:34 __db.002
    -rw-r----- 1 root 83894272 2010-11-23 22:35 __db.003
    -rw-r----- 1 root 163840 2010-11-23 22:35 test.dbxml
  • 5. Re: unable to allocate memory for mutex; resize mutex region
    637288 Journeyer
    Currently Being Moderated
    If PHP created this environment, it won't recreate it upon the next startup. You should do it manually. db_recover utility would help you with that.
    I also didn't mean to just create an environment using the dbxml shell, but try to add/query/delete documents using the shell, i.e. repeat those operations that you do from PHP.

    Also what is you cache size? It might be worth increasing it, together with locks, lockers and objects.

    Vyacheslav
  • 6. Re: unable to allocate memory for mutex; resize mutex region
    560979 Newbie
    Currently Being Moderated
    Result of db_recover
    -rw-r----- 1 root 10485760 2010-11-23 22:58 log.0000000001
    For new env, next error:
    dbxml -z 256 -c
    Error opening environment ., error is -30974
  • 7. Re: unable to allocate memory for mutex; resize mutex region
    560979 Newbie
    Currently Being Moderated
    I am embarrassed by what example is not working of the box. When compile php module warnings were issued. Almost in every file.
    /usr/local/dbxml/dbxml/src/php/php_dbxml.cpp: In function ‘void zif_dbxml_version(int, zval*, zval**, zval*, int)’:
    /usr/local/dbxml/dbxml/src/php/php_dbxml.cpp:49: warning: deprecated conversion from string constant to ‘char*’
    /usr/local/dbxml/dbxml/src/php/php_dbxml.cpp: In function ‘void zif_dbxml_set_log_level(int, zval*, zval**, zval*, int)’:
    /usr/local/dbxml/dbxml/src/php/php_dbxml.cpp:69: warning: deprecated conversion from string constant to ‘char*’
    /usr/local/dbxml/dbxml/src/php/php_dbxml.cpp: In function ‘void zif_dbxml_set_log_category(int, zval*, zval**, zval*, int)’:
    /usr/local/dbxml/dbxml/src/php/php_dbxml.cpp:80: warning: deprecated conversion from string constant to ‘char*’
    /usr/local/dbxml/dbxml/src/php/php_dbxml.cpp: In function ‘int zm_startup_dbxml(int, int)’:
    /usr/local/dbxml/dbxml/src/php/php_dbxml.cpp:101: warning: deprecated conversion from string constant to ‘char*’
    /usr/local/dbxml/dbxml/src/php/php_dbxml.cpp:102: warning: deprecated conversion from string constant to ‘char*’
    /usr/local/dbxml/dbxml/src/php/php_dbxml.cpp:103: warning: deprecated conversion from string constant to ‘char*’
    /usr/local/dbxml/dbxml/src/php/php_dbxml.cpp:107: warning: deprecated conversion from string constant to ‘char*’
    /usr/local/dbxml/dbxml/src/php/php_dbxml.cpp:108: warning: deprecated conversion from string constant to ‘char*’
    /usr/local/dbxml/dbxml/src/php/php_dbxml.cpp:109: warning: deprecated conversion from string constant to ‘char*’
    /usr/local/dbxml/dbxml/src/php/php_dbxml.cpp:110: warning: deprecated conversion from string constant to ‘char*’
    /usr/local/dbxml/dbxml/src/php/php_dbxml.cpp:111: warning: deprecated conversion from string constant to ‘char*’
    /usr/local/dbxml/dbxml/src/php/php_dbxml.cpp:112: warning: deprecated conversion from string constant to ‘char*’
    /usr/local/dbxml/dbxml/src/php/php_dbxml.cpp:113: warning: deprecated conversion from string constant to ‘char*’
    /usr/local/dbxml/dbxml/src/php/php_dbxml.cpp:114: warning: deprecated conversion from string constant to ‘char*’
    /usr/local/dbxml/dbxml/src/php/php_dbxml.cpp:115: warning: deprecated conversion from string constant to ‘char*’
    /usr/local/dbxml/dbxml/src/php/php_dbxml.cpp:116: warning: deprecated conversion from string constant to ‘char*’
    /usr/local/dbxml/dbxml/src/php/php_dbxml.cpp:117: warning: deprecated conversion from string constant to ‘char*’
    /usr/local/dbxml/dbxml/src/php/php_dbxml.cpp:118: warning: deprecated conversion from string constant to ‘char*’
    /usr/local/dbxml/dbxml/src/php/php_dbxml.cpp:119: warning: deprecated conversion from string constant to ‘char*’
    /usr/local/dbxml/dbxml/src/php/php_dbxml.cpp:120: warning: deprecated conversion from string constant to ‘char*’
    /usr/local/dbxml/dbxml/src/php/php_dbxml.cpp:121: warning: deprecated conversion from string constant to ‘char*’
    /usr/local/dbxml/dbxml/src/php/php_dbxml.cpp:168: warning: deprecated conversion from string constant to ‘char*’
    /usr/local/dbxml/dbxml/src/php/php_dbxml.cpp:169: warning: deprecated conversion from string constant to ‘char*’
    /usr/local/dbxml/dbxml/src/php/php_dbxml.cpp:170: warning: deprecated conversion from string constant to ‘char*’
    /usr/local/dbxml/dbxml/src/php/php_dbxml.cpp:171: warning: deprecated conversion from string constant to ‘char*’
    /usr/local/dbxml/dbxml/src/php/php_dbxml.cpp:277: warning: format not a string literal and no format arguments
    /usr/local/dbxml/dbxml/src/php/php_dbxml.cpp: At global scope:
    /usr/local/dbxml/dbxml/src/php/php_dbxml.cpp:303: warning: deprecated conversion from string constant to ‘char*’
  • 8. Re: unable to allocate memory for mutex; resize mutex region
    637288 Journeyer
    Currently Being Moderated
    The dbxml utility with the flag -c creates a new environment, however, the environment is not deleted after recovery. You can't create two environments in the same folder

    Vyacheslav
  • 9. Re: unable to allocate memory for mutex; resize mutex region
    gmfeinberg Journeyer
    Currently Being Moderated
    Vitaliy,

    Did you build PHP support for Berkeley DB as well, as indicated by the BDB XML readme file? This has the feel of a mismatch of Berkeley DB libraries. Perhaps your build picked up another version of BDB from the same machine.

    Regards,
    George
  • 10. Re: unable to allocate memory for mutex; resize mutex region
    560979 Newbie
    Currently Being Moderated
    Hello George.

    Yes, as in README file. And patching like Re: Berkeley DB XML and PHP 5.3
    and Re: Berkeley DB XML and PHP 5.3

    On this machine I am tried build dbxml same version, but in diffrent directories. I'll try to do it again.

    --
    Vitaliy
  • 11. Re: unable to allocate memory for mutex; resize mutex region
    560979 Newbie
    Currently Being Moderated
    Hello

    I am make clean install of Ubuntu 10.10 and install dbxml. I am have same error.

    --
    Vitaliy
  • 12. Re: unable to allocate memory for mutex; resize mutex region
    655560 Journeyer
    Currently Being Moderated
    Hi Vitaliy,

    It seems that you tried mutex_set_max = 1000/10000. However, the default initial value of mutex_set_max is 39000+ in general. So please try a larger value.

    If possible, please use DB_ENV->mutex_get_max() to check if the max mutex has been set correctly(http://download.oracle.com/docs/cd/E17076_02/html/api_reference/C/frame_main.html).

    Another suggestion is that please try to split long transactions to small transactions. It can help reduce the mutex requirement.

    Best regards,
    Rucong
    Oracle Berkeley DB XML
  • 13. Re: unable to allocate memory for mutex; resize mutex region
    560979 Newbie
    Currently Being Moderated
    Hi, Rucong.

    Thx, for replay.
    It seems that you tried mutex_set_max = 1000/10000. However, the default initial value of mutex_set_max is 39000+ in general. So please try a larger value.
    I am tried set from 50000 to 300000. Same errors.

    If possible, please use DB_ENV->mutex_get_max() to check if the max mutex has been set correctly(http://download.oracle.com/docs/cd/E17076_02/html/api_reference/C/frame_main.html).
    PHP class DB4Env does not have mutex_get_max() function. So I can not check this.

    Another suggestion is that please try to split long transactions to small transactions. It can help reduce the mutex requirement.
    Hmm. But this example from install package. This example does not have transaction!

    Edited by: Vitaliy Katochka on Dec 20, 2010 5:09 PM
  • 14. Re: unable to allocate memory for mutex; resize mutex region
    655560 Journeyer
    Currently Being Moderated
    Hi Vitaliy,

    The data set of Example 08.php is really small. So the cause might not be resource exhaustion. I guess there are some issue in environment / installation.

    Today I created the PHP environment on my machine and there is no issue with 08.php at all. I list all my install instructions below. Could you please check your installation?
    tar zxf dbxml-2.5.16.tar.gz
    cd dbxml-2.5.16
    ./buildall
    cd db-4.8.24/php_db4
    phpize
    ./configure --with-db4=$PWD/../../install
    make
    sudo make install
    cd ../../dbxml/src/php/
    phpize
    ./configure --with-dbxml=$PWD/../../../install
    make
    sudo make install
    Edit /etc/php5/cli/php.ini to add following two lines after "; extension_dir = "./""
    extension=db4.so
    extension=dbxml.so
    (You may also need to edit /etc/php5/apache2/php.ini and/or /etc/php5/cgi/php.ini if you run php program with Apache/cgi)

    Then execute "php 08.php". Here is the output on my platform:
    Create an use a transactional XML Container:
    add a document, get the document, display the content of
    the document.
    
    EXPECTED RESULT:
    book1 = <book><title>Knowledge Discovery in Databases.</title></book>
    ACTUAL RESULT:
    book1 = <book><title>Knowledge Discovery in Databases.</title></book>
    Best regards,
    Rucong
    Oracle Berkeley DB XML
1 2 3 Previous Next

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points