Forum OpenACS Development: Re: ns_db gethandle gives error 'could not allocate 1 handle from pool "pool1"' Naviserver on Windows
From every pool, every request gets just one handle (and might put it back manually or at the end of the request). The handle information is managed/reused in OpenACS via global tcl variables such that a complex page with e.g. 100 sql requests needs just a single "gethandle" request.
The question whether or not a manual "ns_db gethandle" returns a value or not boils down to the question whether or not the request has already requested a handle. On OpenACS.org, the command
set db [ns_db gethandle]succeeds, but
set db1 [ns_db gethandle] set db2 [ns_db gethandle]fails. It seems, that in your instance, probably the templates issue already requests from pool1, therefore the request from pool1 fails but the request for pool2 succeeds. This is the same behavior as on Linux or Mac OS.
Hope this helps.
thanks very much for replying when you are under so much pressure - I do appreciate it.
I understand the situation much more now, and yes it makes sense that the templating system is getting the first handle. In earlier versions of OpenACS under AOLserver, it didn't seem to cause a problem. Unfortunately we have some legacy code that does call ns_db gethandle, so I'll investigate what's involved in re-writing that using db_with_handle or similar.
all the best