jonpryor / dblinq2007

Automatically exported from code.google.com/p/dblinq2007
0 stars 0 forks source link

File handle leak running under mono #283

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

Build a schema (I used sqlite3) with this table.  I don't think the
table matters.  Generate dblinq code for it.  I did this on windows with
the current SVN.  The project is called EmailDB.

CREATE TABLE [tombstone] (
[category] VARCHAR(10)  NULL,
[item] varchar(128)  NULL,
[id] iNTEGER  NULL,
[tombEventId] INTEGER  NOT NULL PRIMARY KEY AUTOINCREMENT
)

// Here's a small project using it.  Sorry, it's in F# but
// it's very close to C# so I think it's readable enough.

open EmailDB
open Microsoft.FSharp.Linq
open System
open System.Data
open System.Data.SQLite

let test() =
    use db = new EmailDB.Main(new SQLiteConnection("Data Source=test.s3db"))
    for i in {0..10000} do
        let ts = Tombstone()
        db.Tombstone.InsertOnSubmit(ts)
        printf "%d .." i
        db.SubmitChanges()

What is the expected output? What do you see instead?

Running under windows, it (somewhat slowly) inserts 10000 records as
expected.  Watching file handles, database connections are created
and deleted.  Running using mono 2.6.7 on a linux 2.6.11 kernel it 
adds a database handle for every SubmitChanges call, till it runs out
of file handles.  You can see from the /proc/XXX/fid files that they
are all handles the database.  I've made this example somewhat exaggerated.
If I move the SubmitChanges line out of the loop I leak just one handle
but if you're doing this operation a lot you're still losing file handles
till the dbopen finally fails. 

What version of the product are you using? On what operating system?

svn as of ~2 weeks ago.

Please provide any additional information below.

I tried various permutations to better understand the bug.  Doesn't
matter if the fields of the Tombstone record are filled out or now.
You do need to call InsertOnSubmit and Submit Changes - either on their
own aren't problematic.

This is pretty crippling if I can't do database inserts without leaking
a file handle.

Darren

Original issue reported on code.google.com by dagg...@gmail.com on 5 Sep 2010 at 9:15