Bio/Graphics/Browser2/UserDB.pm : possible update ?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Bio/Graphics/Browser2/UserDB.pm : possible update ?

Frédéric Sapet
i have noticed that my sessions database was overwhelmed by connections.

It's in a way the same problem I have noticed with LDAPAuthenticate.pm, the first connection is no saved, so each time you need data from the database, GGB will create a new one !

This is related to a bug described in Bio/Graphics/Browser2/UserTracks/Database.pm
# BUG: Two copies of UserDB; one here and one in the Render object

I have done something, which is not maybe the best way to do this, but it does the trick.

I've added a class variable in Bio/Graphics/Browser2/UserDB.pm :

our $alreadyLoggedIn;

and then the new method will become :

sub new {
  my $class   = shift;
  my $globals = shift;

  my $VERSION = '0.5';
  my $credentials  = $globals->user_account_db
      || "DBI:mysql:gbrowse_login;user=gbrowse;password=gbrowse";
  my $login;
  if (!defined $alreadyLoggedIn) {
    $login = DBI->connect($credentials);
    $alreadyLoggedIn = $login;
  }
  else {
    $login = $alreadyLoggedIn;
  }
  unless ($login) {
      confess "Could not open login database $credentials";
  }

  my $self = bless {
      dbi      => $login,
      globals  => $globals,
      openid   => HAVE_OPENID,
      register => HAVE_SMTP,
  }, ref $class || $class;

  return $self;
}

it avoids some connections to the database.

By the way, I have a question about the $globals object. This is a Bio::Graphics::Browser2 object.  I have noticed that this object is not always the same through the different calls of Bio/Graphics/Browser2/UserDB.pm even when I work with the same datasource on the interface. I though that the same object should be reused ? (and so the class variable be more powerfull)

thank you.

Fred


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Gmod-gbrowse mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-gbrowse
Reply | Threaded
Open this post in threaded view
|

Re: Bio/Graphics/Browser2/UserDB.pm : possible update ?

Lincoln Stein
The db handle caching system must not be working correctly. I will fix it.

L

On Monday, March 4, 2013, Frédéric Sapet wrote:
i have noticed that my sessions database was overwhelmed by connections.

It's in a way the same problem I have noticed with LDAPAuthenticate.pm, the first connection is no saved, so each time you need data from the database, GGB will create a new one !

This is related to a bug described in Bio/Graphics/Browser2/UserTracks/Database.pm
# BUG: Two copies of UserDB; one here and one in the Render object

I have done something, which is not maybe the best way to do this, but it does the trick.

I've added a class variable in Bio/Graphics/Browser2/UserDB.pm :

our $alreadyLoggedIn;

and then the new method will become :

sub new {
  my $class   = shift;
  my $globals = shift;

  my $VERSION = '0.5';
  my $credentials  = $globals->user_account_db
      || "DBI:mysql:gbrowse_login;user=gbrowse;password=gbrowse";
  my $login;
  if (!defined $alreadyLoggedIn) {
    $login = DBI->connect($credentials);
    $alreadyLoggedIn = $login;
  }
  else {
    $login = $alreadyLoggedIn;
  }
  unless ($login) {
      confess "Could not open login database $credentials";
  }

  my $self = bless {
      dbi      => $login,
      globals  => $globals,
      openid   => HAVE_OPENID,
      register => HAVE_SMTP,
  }, ref $class || $class;

  return $self;
}

it avoids some connections to the database.

By the way, I have a question about the $globals object. This is a Bio::Graphics::Browser2 object.  I have noticed that this object is not always the same through the different calls of Bio/Graphics/Browser2/UserDB.pm even when I work with the same datasource on the interface. I though that the same object should be reused ? (and so the class variable be more powerfull)

thank you.

Fred



--
Lincoln D. Stein
Director, Informatics and Biocomputing Platform
Ontario Institute for Cancer Research
101 College St., Suite 800
Toronto, ON, Canada M5G0A3
416 673-8514
Assistant: Renata Musa <[hidden email]>

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Gmod-gbrowse mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-gbrowse