Subject Re: [firebird-support] Firebird 2.5.x leaking memory on long living connections coming from ado.net provider clients
Author Mark Rotteveel
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