[ruby-oci8-devel] propose to implement pooling technology for Ruby-OCI8
KUBO Takehiro
kubo at jiubao.org
Mon Dec 24 09:35:44 EST 2007
Hi,
shiwei zhang <shiwei.zhang at oracle.com> writes:
>> BTW, I have a small question: you use "OCISessionBegin()" for
>> T_EXPLICIT (external credential or OCI_SYSDBA, OCI_SYSOPER); and use
>> "OCILogon" for T_IMPLICIT (OCI_CRED_RDBMS). *Why don't you use
>> "OCISessionBegin()" for both T_EXPLICIT and T_IMPLICIT?* I think
>> "OCISessionBegin()" can work for both of the two conditions, do you
>> have other concerns about this?
I agree in theory. I had used OCISessionBegin() for both before 0.1.13.
But I received a mail it sometimes causes a segmentation faults in 10
logons. Its environment was as follows.
ruby 1.8.2
ruby-oci8 0.1.13
Oracle Client 8.1.7 (Windows)
Oracle Server 8.0.5
This would be really rare. But there was no workaround. I changed to
use OCILogon for non-privilege logons.
If the code become too complex by your changes, you can merge them
to OCISessionBegin(). Because it might be caused by a bug in ruby-oci8
and its internal structure was changed. The same problem may not occur
in current implementation.
>> For now I think:
>>
>> # connection pool
>> pool = OCI8::ConnectionPool.new(username, password, tns_name, conn_min, conn_max, conn_incr)
>> conn = OCI8.new(pool, appusername, apppassword)
>> or
>> pool = OCI8::ConnectionPool.new(username, password, tns_name, conn_min, conn_max, conn_incr)
>> conn = OCI8.new($poolname, appusername, apppassword)
>>
>> # session pool
>> pool = OCI8::SessionPool.new(username, password, tns_name, sess_min, sess_max)
>> conn = OCI8.new(pool, appusername, apppassword)
>> or
>> pool = OCI8::SessionPool.new(username, password, tns_name, sess_min, sess_max)
>> conn = OCI8.new($poolname, appusername, apppassword)
>>
>> Notes:
>> username is used to create the pool, it's the implicit user.
>> appusername is used to create/get a session from the pool. appusername
>> could be different with username.
Another proposal:
pool = OCI8::ConnectionPool.new(username, password, tns_name, conn_min, conn_max, conn_incr)
conn = OCI8.new(appusername, apppassword, pool)
Change the current spec to:
OCI8.new(username, password, dbname_or_pool = nil, privilege = nil)
Argument values username and password are appusername and apppassword
respectively if the third argument is a connection pool.
One question:
Are appusername and apppassword required mandatory or optional?
>> $poolname is generate from "OCI8::ConnectionPool.new()" or
>> "OCI8::ConnectionPool.new()". If we've gotten the value of $poolname,
>> it's enough for "OCI8.new()" to create/hand out a session for appusername.
What is the data type of $poolname? If it is a string, we cannot
distinguish a logon with dbname from a login using connection pool.
If is is a connection pool object, when is the pool destroyed?
$poolname is set by a side effect of OCI::ConnectionPool.new(). IMO,
it is not straightforward.
--
KUBO Takehiro <kubo at jiubao.org>
More information about the ruby-oci8-devel
mailing list