[ruby-oci8-devel] propose to implement pooling technology for Ruby-OCI8

shiwei zhang shiwei.zhang at oracle.com
Sat Dec 29 04:25:45 EST 2007


Hi,

Sorry I had couple days off work, so am replying late. Btw wish 
everyboday a happy new year :-) .

KUBO Takehiro wrote:
> 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.
>   
I plan to choose OCISessionGet() for both connection pooling and session 
pooling, because OCISessionBegin() can't work in session pooling.
And for now I plan to provide pooling only for T_IMPLICIT, not for 
T_EXPLICIT, because: (1) OCI_SYSDBA, OCI_SYSOPER are not supported by 
pooling. (2) external credential is not supported by session pooling. 
(3) external credential is probably not supported by connection pooling.
>>> 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?
>   
I think this is a good proposal.
appusername and apppassword  is mandatory for connection pooling, but 
they are optional for session pooling.
>>> $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 a string. So let's use the pool object instead of it, in 
order that we can use the proposal above.
> $poolname is set by a side effect of OCI::ConnectionPool.new(). IMO,
> it is not straightforward.
>   
Best Regards,
Shiwei
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/ruby-oci8-devel/attachments/20071229/d4716de9/attachment-0001.html 


More information about the ruby-oci8-devel mailing list