<div dir="auto">logs fro disconnections will help we understand what is going on. what mysql server version system?</div><br><div class="gmail_quote"><div dir="ltr">Em seg, 14 de jan de 2019 10:00,  <<a href="mailto:dev-request@ensembl.org">dev-request@ensembl.org</a> escreveu:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Send Dev mailing list submissions to<br>
        <a href="mailto:dev@ensembl.org" target="_blank" rel="noreferrer">dev@ensembl.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
        <a href="http://lists.ensembl.org/mailman/listinfo/dev" rel="noreferrer noreferrer" target="_blank">http://lists.ensembl.org/mailman/listinfo/dev</a><br>
or, via email, send a message with subject or body 'help' to<br>
        <a href="mailto:dev-request@ensembl.org" target="_blank" rel="noreferrer">dev-request@ensembl.org</a><br>
<br>
You can reach the person managing the list at<br>
        <a href="mailto:dev-owner@ensembl.org" target="_blank" rel="noreferrer">dev-owner@ensembl.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of Dev digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
   1. Re: Database timeouts for Ensembl API script (Kieron Taylor)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Mon, 14 Jan 2019 11:27:43 +0000<br>
From: Kieron Taylor <<a href="mailto:ktaylor@ebi.ac.uk" target="_blank" rel="noreferrer">ktaylor@ebi.ac.uk</a>><br>
To: Ensembl developers list <<a href="mailto:dev@ensembl.org" target="_blank" rel="noreferrer">dev@ensembl.org</a>><br>
Subject: Re: [ensembl-dev] Database timeouts for Ensembl API script<br>
Message-ID: <<a href="mailto:F389812C-D8F0-4074-BA02-6BCE3FA28A73@ebi.ac.uk" target="_blank" rel="noreferrer">F389812C-D8F0-4074-BA02-6BCE3FA28A73@ebi.ac.uk</a>><br>
Content-Type: text/plain;       charset=utf-8<br>
<br>
Hi Simon,<br>
<br>
True long-running scripts that revisit a database can fall afoul of MySQL 8 hour timeouts. We cannot remove this constraint on our public database servers for reasons of fair use, but if it's your own database it can be altered by a DBA. The Ensembl API offers the set_reconnect_when_lost() function [1] which operates on all connected adaptors, and a per-connection function reconnect_when_lost() [2]<br>
<br>
In general it is better if your code knows when it can disconnect and does so manually for long running jobs which only occasionally make DB requests.<br>
<br>
Looking at your script, I would say that you are being too iterative, and you should start considering bulk fetching of specific data so that you don't need to go back to the database so often. It makes the code a bit more complex, and uses plenty more RAM, but it usually makes a large increase in performance. As a stopgap, you could also trigger a reconnection to the database between chromosomes to reset your connection timer.<br>
<br>
Hopefully one of these approaches will help you either speed up your script or allow it to keep running.<br>
<br>
Regards,<br>
<br>
<br>
Kieron<br>
<br>
<br>
Kieron Taylor PhD.<br>
Ensembl Developer<br>
<br>
EMBL, European Bioinformatics Institute<br>
<br>
[1] - <a href="http://www.ensembl.org/info/docs/Doxygen/core-api/classBio_1_1EnsEMBL_1_1Registry.html#ac77cb4f710542fe0d53f1c8f09db5c4d" rel="noreferrer noreferrer" target="_blank">http://www.ensembl.org/info/docs/Doxygen/core-api/classBio_1_1EnsEMBL_1_1Registry.html#ac77cb4f710542fe0d53f1c8f09db5c4d</a><br>
[2] - <a href="http://www.ensembl.org/info/docs/Doxygen/core-api/classBio_1_1EnsEMBL_1_1DBSQL_1_1DBConnection.html#a131d35ef79d2d8ee1add8084baaeb1e8" rel="noreferrer noreferrer" target="_blank">http://www.ensembl.org/info/docs/Doxygen/core-api/classBio_1_1EnsEMBL_1_1DBSQL_1_1DBConnection.html#a131d35ef79d2d8ee1add8084baaeb1e8</a><br>
<br>
> On 8 Jan 2019, at 11:33, Simon Andrews <<a href="mailto:simon.andrews@babraham.ac.uk" target="_blank" rel="noreferrer">simon.andrews@babraham.ac.uk</a>> wrote:<br>
> <br>
> A script we?ve been using for years has started to become flaky very recently, with repeated losses of connections to the back end database.<br>
>  <br>
> Eg:<br>
>  <br>
> DBD::mysql::st execute failed: Lost connection to MySQL server during query at /home/andrewss/EnsemblAPI/ensembl/modules/Bio/EnsEMBL/DBSQL/DBEntryAdaptor.pm line 109, <STDIN> line 1.<br>
> DBD::mysql::st execute failed: MySQL server has gone away at /home/andrewss/EnsemblAPI/ensembl/modules/Bio/EnsEMBL/DBSQL/BaseAdaptor.pm line 481, <IN> line 1243757.<br>
>  <br>
> The script runs for a pretty long time (a few hours) and just iterates through every chromosome / gene / transcript / CDS in a target genome.  We?ve not seen these types of timeout before.<br>
>  <br>
> The failures are not consistent - I?ve had the same chromosome fail a couple of times, and then work on a subsequent attempt.  Is there anything we can do from the client side to keep these connections alive (or reconnect?), or are there any known issues at the moment which might be affecting the stability of the database?<br>
>  <br>
> If it helps, the script I?m running can be seen at: <br>
> <a href="https://github.com/s-andrews/SeqMonk/blob/master/Scripts/export_annotated_embl_from_assembly.pl" rel="noreferrer noreferrer" target="_blank">https://github.com/s-andrews/SeqMonk/blob/master/Scripts/export_annotated_embl_from_assembly.pl</a><br>
>  <br>
> Cheers<br>
>  <br>
> Simon.<br>
>  <br>
> The Babraham Institute, Babraham Research Campus, Cambridge CB22 3AT Registered Charity No. 1053902.<br>
> The information transmitted in this email is directed only to the addressee. If you received this in error, please contact the sender and delete this email from your system. The contents of this e-mail are the views of the sender and do not necessarily represent the views of the Babraham Institute. Full conditions at:<a href="http://www.babraham.ac.uk" rel="noreferrer noreferrer" target="_blank">www.babraham.ac.uk</a><br>
> _______________________________________________<br>
> Dev mailing list    <a href="mailto:Dev@ensembl.org" target="_blank" rel="noreferrer">Dev@ensembl.org</a><br>
> Posting guidelines and subscribe/unsubscribe info: <a href="http://lists.ensembl.org/mailman/listinfo/dev" rel="noreferrer noreferrer" target="_blank">http://lists.ensembl.org/mailman/listinfo/dev</a><br>
> Ensembl Blog: <a href="http://www.ensembl.info/" rel="noreferrer noreferrer" target="_blank">http://www.ensembl.info/</a><br>
<br>
<br>
<br>
------------------------------<br>
<br>
Subject: Digest Footer<br>
<br>
_______________________________________________<br>
Dev mailing list    <a href="mailto:Dev@ensembl.org" target="_blank" rel="noreferrer">Dev@ensembl.org</a><br>
Posting guidelines and subscribe/unsubscribe info: <a href="http://lists.ensembl.org/mailman/listinfo/dev" rel="noreferrer noreferrer" target="_blank">http://lists.ensembl.org/mailman/listinfo/dev</a><br>
Ensembl Blog: <a href="http://www.ensembl.info/" rel="noreferrer noreferrer" target="_blank">http://www.ensembl.info/</a><br>
<br>
<br>
------------------------------<br>
<br>
End of Dev Digest, Vol 103, Issue 8<br>
***********************************<br>
</blockquote></div>