Subject AW: [firebird-support] Firebird 2.5.x leaking memory on long living connections coming from ado.net provider clients
Author Dominik Psenner
Hi Mark,

thanks for your valuable feedback. The mailing list did not pick up my message for a longer period and therefore I have already filed an issue in the issue tracker. For future readers that stumble upon this or a similar symptoms, the issue is:

http://tracker.firebirdsql.org/browse/DNET-852

Mit freundlichen Grüßen - Distinti saluti - Best regards

Dominik Psenner
Software Developer

Tel: +39 0471 319 999
Fax: +39 0471 319 990
Email: dominik.psenner@...

[cid:image001.jpg@01D453E2.40567830]<http://www.topcontrol.it/>
Enzenbergweg 24/A - Via Enzenberg 24/A
I- 39018 Terlan - Terlano (BZ)
www.topcontrol.it<http://www.topcontrol.it>


Die unbefugte Verwendung dieser Mitteilung ist verboten und könnte strafrechtlich verfolgt werden. Wer diese Mitteilung irrtümlicherweise erhält wird gebeten uns umgehend zu informieren und anschließend die Mitteilung zu vernichten. Vielen Dank.
Il presente messaggio è diretto unicamente al destinatario sopra indicato. L'utilizzo non autorizzato del presente messaggio è vietato e potrebbe costituire reato. Chiunque altro riceva questa comunicazione per errore è invitato ad informarci immediatamente ed è tenuto a istruggere quanto ricevuto. Grazie per la collaborazione.
Caution: The unauthorized use of this message is prohibited and may be prosecuted by law. Anyone who receives this communication in error is requested to inform us immediately and then delete the message. Thank you very much for your collaboration!
Von: firebird-support@yahoogroups.com [mailto:firebird-support@yahoogroups.com]
Gesendet: 21. Sep 2018 15:07
An: firebird-support@yahoogroups.com
Betreff: Re: [firebird-support] Firebird 2.5.x leaking memory on long living connections coming from ado.net provider clients



Please post this to the firebird-net-provider Googlegroups mailing list,
your problem seems to be Firebird .net provider specific, so it is more
on-topic there than here.

Mark

On 20-9-2018 14:38, Dominik Psenner dominik.psenner@...
[firebird-support] wrote:
> Hi,
>
> after a recent update of the firebird ado.net driver from 5.12.0 we observe that the firebird server 2.5.x leaks memory that is related to a connection that a client opened using the ado.net provider > 5.12.0.
>
> We observe both an increase in the private memory set but also nonpaged pool increases significantly until the server is no longer able to handle any statements. Closing the connection in question however properly releases all related resources in the firebird server process and the firebird server process recovers, going back to normal. This may relates to changes implemented with that before ado.net provider 5.12.1, connections from the ado.net provider to the firebird server were closed too early and therefore were always short-living. 5.12.1 fixes that and from then on connections are properly pooled and therefore connections are from then on long-living as long as there is activity. A connection is then taken from the pool, queries are run and the connection is returned to the connection pool.
>
> We have observed fbserver.exe to have an np pool of way beyond 5000K and a working set way beyond 4GB for a database that is 500MB on disk (and probably fits into ram).
>
> While attempting to implement a minimal sample project that reproduces the issue we have implemented a minimal application that populates several thousand records into a dummy database that contains only one table created as follows:
>
> CREATE TABLE ITEM (
> ID BIGINT NOT NULL,
> MEASUREMENT DOUBLE PRECISION NOT NULL,
> UNIT VARCHAR(10) NOT NULL);
>
> ALTER TABLE ITEM ADD CONSTRAINT PK_ITEM PRIMARY KEY (ID);
> CREATE UNIQUE DESCENDING INDEX PK_ITEM_DESC ON ITEM (ID);
>
> CREATE SEQUENCE GEN_ITEM_ID;
>
> SET TERM ^ ;
>
> create trigger item_bi for item
> active before insert position 0
> as
> begin
> if (new.id is null) then
> new.id = gen_id(gen_item_id,1);
> end
> ^
>
> SET TERM ; ^
>
> For simplicity I do not how we have populated the table with values. After having populated the database, we start the breaking application which works as follows:
>
> The application does loop, selecting a value by the primary key in range [1, `select max(id) from item`] and then sleeps for a short period of time.
>
> Even only a short period of time later the server begins to grow in np pool until it refuses to execute new queries. Soon the breaking application crashes with IscError 335544761 "too many open handles to database" and the SQLSTATE is "HY000".
>
> Now, there may be two apparent causes for the symptom:
>
>
> 1. Ado.net provider has been broken since ever and this bug has been hidden until the connection pool was fixed with 5.12.1.0
>
> 2. The server code leaks handles, causing the np pool to grow until it can no longer handle any request.
>
> Would you please guide us on where to go next? Should we report this to the maintainer of the firebird ado net provider? Is this bug in the firebird server 2.5.x that causes it to leak in some circumstances?
>
> Things that are related to this issue:
>
> · https://github.com/cincuranet/FirebirdSql.Data.FirebirdClient/compare/5.12.0..0...5.12.1.0
>
> · http://tracker.firebirdsql.org/browse/DNET/fixforversion/10856
>
> Things that appear to be related to this issue (but might not be related at all):
>
> · https://firebirder.ru/problemy-s-icu-podxod-2
>
> · http://tracker.firebirdsql.org/browse/CORE-2642
>
> Firebird Server Versions affected:
>
> · 2.5.3 superserver on windows 7 x64
>
> · 2.5.8 superserver on windows 7 x64
>
> · 2.5.4 classic on windows 2016 x64

--
Mark Rotteveel



[Non-text portions of this message have been removed]