Hi,

I have written an application that reads values from an SQLite database
and uses them for generating graph images. This process takes up to a
few seconds (most of it is reading the database) and multiple images
shall be generated. So I thought that doing things in parallel might be
a good idea.

As I don't expect a single SQLite connection to be threadsafe, I am
creating a separate connection instance for each background worker
thread and close it when the painting is finished. But that gives me a
strange exception at the same point every time:

> Unclassified.JobException: Error in job: PlotJob ---> 
> System.ArgumentException: Ein Element mit dem
> gleichen Schlüssel wurde bereits hinzugefügt.
>    bei System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
>    bei System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, 
> Boolean add)
>    bei System.Data.SQLite.SQLiteConvert.TypeNameToDbType(String Name)
>    bei System.Data.SQLite.SQLiteDataReader.GetSQLiteType(Int32 i)
>    bei System.Data.SQLite.SQLiteDataReader.VerifyType(Int32 i, DbType typ)
>    bei System.Data.SQLite.SQLiteDataReader.GetInt16(Int32 i)
>    bei LogState.SQLiteLogReader.GetDescription(String codeName)
>    bei LogState.PlotDataSource.Read(ILogReader logReader, DateTime startTime, 
> DateTime endTime, Time
> Span avgTime)
>    bei LogState.StatePlotter.Plot()
>    bei LogState.StatePlotter.Plot(String fileName)
>    bei LogState.Common.PlotBySpec(String plotSpecFileName, String 
> outputFileName, Boolean compact, S
> ize customSize, Boolean newLogReader)
>    bei LogState.PlotJob.DoWork()
>    bei Unclassified.JobList.worker_DoWork(Object sender, DoWorkEventArgs e)
>    --- Ende der internen Ausnahmestapelüberwachung ---
>    bei Unclassified.JobList.worker_DoWork(Object sender, DoWorkEventArgs e)
>    bei System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)
>    bei System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object 
> argument)

The exception message roughly translates as "An element with the same
key has already been added."

It seems that 3 of my 4 jobs run fine, but the first of them always
fails with this message. The cause seems to be inside the method of
reading an Int16 value from a DataReader. This has always worked fine,
but it stopped when accessing the database in parallel. I have already
tried setting the ReadOnly property to true in the
ConnectionStringBuilder but that has not helped.

Can anybody explain to me what this exception even means? Is this an
error in my code, did I use the SQLite library wrong, or is it a bug in
SQLite.NET?

I am currently using System.Data.SQLite version 1.0.76.0 on Windows XP
x86 with .NET 4.0.

-- 
Yves Goergen "LonelyPixel" <nospam.l...@unclassified.de>
Visit my web laboratory at http://beta.unclassified.de
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to