Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Full and Correct Support for Connection Pooling? #2

Open
mdgozza opened this issue Apr 20, 2021 · 5 comments
Open

[Question] Full and Correct Support for Connection Pooling? #2

mdgozza opened this issue Apr 20, 2021 · 5 comments

Comments

@mdgozza
Copy link

mdgozza commented Apr 20, 2021

Hi!

Thanks so much for supporting rust.

When reviewing the r2d2 pooling implementation I noticed that this library doesn't yet seem to properly take care of broken and invalid connections in the r2d2 pool. Is there any timeline for when this might become officially complete?

rust-ibm_db/src/lib.rs

Lines 138 to 146 in 1fd871d

fn is_valid(&self, _conn: &mut Self::Connection) -> std::result::Result<(), Self::Error> {
//TODO
Ok(())
}
fn has_broken(&self, _conn: &mut Self::Connection) -> bool {
//TODO
false
}

Also: I noticed the work on this library is quite new. What kind of levels of support is IBM currently looking at providing for this module?

Again, thanks so much for supporting rust!!

@AWADHAMBIKA
Copy link
Collaborator

Hi @mdgozza thanks for your query.
We are always happy to help and support open-source drivers on Db2.
Also, current idea was to support ODBC APIs as is and that is what is supported as of now.
In future, we are planning to support DB2 complete set of CLI APIs as well.
In the meanwhile, if you have any specific API in mind that you would like to e supported, do let us know and we will prioritize the same.

As we are learning(this project is inspired by r2d2 pooling itself) and implementing, we are still in process of implementing certain things like the above connection pooling thing. We will try to create full support for connection pooling.

Hope it clarifies.

@mdgozza
Copy link
Author

mdgozza commented Apr 23, 2021

Awesome @AWADHAMBIKA thanks so much for the explanation!

I am going to try to build an http server that processes db2 queries in rust and pools connections using this connection manager, but I am worried that without an is_valid implementation pool connections will be created and left open even if they are no longer valid. ( likewise for has_broken )

I will do some research into how it may be possible to detect if a connection is valid or has broken and maybe provide those implementations so that I can use connection pooling and feel confident that a connection I get from the pool will be both valid and not broken.

@mdgozza
Copy link
Author

mdgozza commented Apr 23, 2021

A quick glance at the postgres implementation shows maybe it's not so bad! 🎉

https://github.com/sfackler/r2d2-postgres/blob/master/src/lib.rs#L70-L76

@AWADHAMBIKA
Copy link
Collaborator

AWADHAMBIKA commented Jul 22, 2021

Hi @mdgozza not sure if you were able to implement the is_valid.
I was thinking of something like below(There might be syntactical problem but I hope I am able to explain myself) i.e. if prepare is working fine then that means the connection is still valid. Does this looks good?:

 fn is_valid(&self, _conn: &mut Self::Connection) -> std::result::Result<(), Self::Error> { 
     Statement::with_parent(&_conn)?.prepare(
        "select * from sysibm.sysdummy1",
    )?;
} 

@mdgozza
Copy link
Author

mdgozza commented Jul 24, 2021

Hey @AWADHAMBIKA,
Yeah, I think that's fantastic.
Only concern I have is with prepare.

I'm not positive about this, but it should be confirmed.
Prepare might be telling the sql server ( DB2 ) that we are going to execute a statement.
So maybe the sql server ( DB2 ) hangs onto information about that unexecuted statement and causes some kind of buildup in the engine?

I feel like prepare might leave some stuff hanging around where a full query might be more clean on both sides.
Let me know your thoughts, you might know more that I do here, don't have a ton of experience working with sql engines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants