Forum OpenACS Q&A: Chat moderator error

Collapse
Posted by arief zj on
hello... i'm having problem when accessing chat module as MODERATOR.
Does anybody know what's wrong?? i'm currently using OpenACS 3.2.4.
when i looked at the error log, it says ;

Error: could not allocate 1 handle from pool "main"
could not allocate 1 handle from pool "main"
    while executing
"ns_db gethandle"
    (procedure "chat_get_posts_to_moderate" line 4)
    invoked from within
"chat_get_posts_to_moderate $chat_room_id" ..bla...bla...

anyone know this????

Collapse
Posted by Jerry Asher on
You didn't give quite enough of the error message.

Are you trying to access /chat/moderate.tcl when you see this?

At first glance, I don't see how this could ever have worked (I'm looking at the ACS 3.2.5 version.)  At the time chat_get_posts_to_moderate is called, the tcl page moderate.tcl already has a handle (presumably from main).  If so, then chat_get_posts_to_moderate should almost certainly fail as AOLserver doesn't let you allocate multiple handles from the same pool within a page unless you allocate them all in the same call.

If so, the fix would be to pass the db handle into the proc.

Collapse
Posted by arief zj on
yupp..it occurred when i access to /chat/moderate.tcl. ..the details of the errors is as follows:

Error: could not allocate 1 handle from pool "main"
could not allocate 1 handle from pool "main"
    while executing
"ns_db gethandle"
    (procedure "chat_room_group_id_internal" line 2)
    invoked from within
"chat_room_group_id_internal 1"
    ("eval" body line 1)
    invoked from within
"eval $tcl_statement"
    (procedure "util_memoize" line 11)
    invoked from within
"util_memoize "chat_room_group_id_internal $chat_room_id" [ad_parameter RoomPropertiesCacheTimeout chat 600"
    (procedure "chat_room_group_id" line 5)
    invoked from within
"chat_room_group_id $chat_room_id"
    invoked from within
"set private_group_id [chat_room_group_id $chat_room_id]"
    (file "/home/servername/webserver/servers/server1/www/chat/moderate.tcl" line 35)
    invoked from within
"source $script"
    (procedure "ns_sourceproc" line 6)
    invoked from within
"ns_sourceproc cns16 {}"

what do u mean by "pass the db handle into the proc." ??
little bit blurry here :))
thanks

Collapse
Posted by Jerry Asher on
Due to it's misuse of handles, that whole page looks screwy to me.

If a page allocates a db handle from pool n, it needs to pass that handle to any function that wants to use a handle from pool n, so all those functions that alloc their own handles from main appear to be wrong: they need to accept the handle as an input param.

from AOLserver's docs: http://www.aolserver.com/docs/deprecated/2.3.3/html/tapi-c31.htm

ns_db gethandle returns the specified number of handles from the specified pool. If poolname is not specified, the Defaultpool from the configuration file is used. If nhandles is not specified, 1 handle is returned. (Note that if you specify nhandles, you must also specify a poolname.) If not enough handles are available to fulfill the request, it waits until they are available. You must request all the handles you will need for a specific pool with one call to ns_db gethandle. You must release all your database handles explicitly (with ns_db releasehandle) before acquiring more. If you request multiple handles from the database, this function returns a Tcl list of database handles (space delimited). In this case, each handle must be released with a separate call to ns_db releasehandle.
Oh well, it's off to Vacaville for a toddler party.
Collapse
Posted by arief zj on
well...thanks a lot ... got to try :)
bye