You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by Patrick Kalkman <PK...@hoogendoorn.nl> on 2009/08/18 14:29:17 UTC

Experiencing locks while using AdoNetAppender

Hi,

I am using the AdoNetAppender for logging messages from multiple
application. All the applications log into one sqllite database.
Sometimes when a lot of information is logged I am experiencing
exceptions like:

log4net:ERROR [AdoNetAppender] Exception while writing to database 
System.Data.SQLite.SQLiteException: The database file is locked 
database is locked 
at System.Data.SQLite.SQLite3.Reset(SQLiteStatement stmt) 
at System.Data.SQLite.SQLite3.Step(SQLiteStatement stmt) 
at System.Data.SQLite.SQLiteCommand.ExecuteNonQuery() 
at System.Data.SQLite.SQLiteTransaction..ctor(SQLiteConnection
connection, Boolean deferredLock) 
at System.Data.SQLite.SQLiteConnection.BeginTransaction(Boolean
deferredLock) 
at System.Data.SQLite.SQLiteConnection.BeginDbTransaction(IsolationLevel
isolationLevel) 
at
System.Data.Common.DbConnection.System.Data.IDbConnection.BeginTransacti
on() 
at log4net.Appender.AdoNetAppender.SendBuffer(LoggingEvent[] events) 

The default CommandTimeout in the AdoNetAppender on the IDbCommand is 30
seconds, but I would like to influence this timeout in the log4net
configuration (file) so that I can influence the timeout on the logging
if the database is locked for a longer portion of time. Reducing the
timeout may lead to events getting lost, but I prefer that to our
application hanging for the full CommandTimeout waiting for the database
to become unlocked.

Is it possible to configure the timeout using configuration? or would it
be better to choose for a solution like deriving from the AdoNetAppender
and add the functionality?

Thanks in advance for any answers.

Patrick


**********************DISCLAIMER**********************
Deze E-mail is uitsluitend bestemd voor de geadresseerde(n). 
Verstrekking aan en gebruik door anderen is niet toegestaan. 
De Hoogendoorn Groep sluit iedere aansprakelijkheid uit die 
voortvloeit uit elektronische verzending.
This E-mail is intended exclusively for the addressee(s), 
and may not be passed on to, or made available for use by 
any person other than the addressee(s). 
The Hoogendoorn Group rules out any and every liability 
resulting from any electronic transmission.
*******************************************************
This message has been scanned by Network Associates' 
McAfee AntiVirus Technology



Re: Experiencing locks while using AdoNetAppender

Posted by Michael Schall <mi...@gmail.com>.
Not sure if this has changed, but I'm pretty sure there is a database  
lock on inserts/updates.  So only one insert at a time. You might try  
the BufferedForwardingAppender. It might serialize the inserts for you.

On Aug 18, 2009, at 8:36 PM, Ron Grabowski <ro...@yahoo.com>  
wrote:

> I think that's how SQLite works. Have you tried writing to a  
> single .db file from multiple threads without using log4net?
>
> From: Patrick Kalkman <PK...@hoogendoorn.nl>
> To: log4net-user@logging.apache.org
> Sent: Tuesday, August 18, 2009 8:29:17 AM
> Subject: Experiencing locks while using AdoNetAppender
>
> Hi,
>
> I am using the AdoNetAppender for logging messages from multiple  
> application. All the applications log into one sqllite database.  
> Sometimes when a lot of information is logged I am experiencing  
> exceptions like:
>
> log4net:ERROR [AdoNetAppender] Exception while writing to database
> System.Data.SQLite.SQLiteException: The database file is locked
> database is locked
> at System.Data.SQLite.SQLite3.Reset(SQLiteStatement stmt)
> at System.Data.SQLite.SQLite3.Step(SQLiteStatement stmt)
> at System.Data.SQLite.SQLiteCommand.ExecuteNonQuery()
> at System.Data.SQLite.SQLiteTransaction..ctor(SQLiteConnection  
> connection, Boolean deferredLock)
> at System.Data.SQLite.SQLiteConnection.BeginTransaction(Boolean  
> deferredLock)
> at System.Data.SQLite.SQLiteConnection.BeginDbTransaction 
> (IsolationLevel isolationLevel)
> at  
> System.Data.Common.DbConnection.System.Data.IDbConnection.BeginTransaction( 
> )
> at log4net.Appender.AdoNetAppender.SendBuffer(LoggingEvent[] events)
>
> The default CommandTimeout in the AdoNetAppender on the IDbCommand  
> is 30 seconds, but I would like to influence this timeout in the  
> log4net configuration (file) so that I can influence the timeout on  
> the logging if the database is locked for a longer portion of time.  
> Reducing the timeout may lead to events getting lost, but I prefer  
> that to our application hanging for the full CommandTimeout waiting  
> for the database to become unlocked.
>
> Is it possible to configure the timeout using configuration? or  
> would it be better to choose for a solution like deriving from the  
> AdoNetAppender and add the functionality?
>
> Thanks in advance for any answers.
>
> Patrick
>
> **********************DISCLAIMER**********************
> Deze E-mail is uitsluitend bestemd voor de geadresseerde(n).
> Verstrekking aan en gebruik door anderen is niet toegestaan.
> De Hoogendoorn Groep sluit iedere aansprakelijkheid uit die
> voortvloeit uit elektronische verzending.
> This E-mail is intended exclusively for the addressee(s),
> and may not be passed on to, or made available for use by
> any person other than the addressee(s).
> The Hoogendoorn Group rules out any and every liability
> resulting from any electronic transmission.
> *******************************************************
> This message has been scanned by Network Associates'
> McAfee AntiVirus Technology

RE: Experiencing locks while using AdoNetAppender

Posted by Patrick Kalkman <PK...@hoogendoorn.nl>.
Ron and Michael thanks for your suggestions,
 
It is indeed how SQLite works and the locking itself is not the problem.
This is expected as multiple processes try to log at once. 
 
The ADODBAppender uses a internal buffer to store the logevents. The
problem is that with default timeout for the DBCommand of 30 seconds
(which is specified in the ADODBAppender) I experience out of memory
exceptions as the internal buffers grow too fast while waiting for the
timeout. 
 
A timeout of say 5s would be better for me. Or better make the timeout
configurable through the config file of the ADODBAppender.
 
What would be the best way to make the neccessary changes? Create my own
version of the ADODBAppender? 
 
Thanks for any reactions,
 
Patrick
 

 
________________________________

Van: Ron Grabowski [mailto:rongrabowski@yahoo.com] 
Verzonden: Wednesday, August 19, 2009 3:36 AM
Aan: Log4NET User
Onderwerp: Re: Experiencing locks while using AdoNetAppender


I think that's how SQLite works. Have you tried writing to a single .db
file from multiple threads without using log4net?


________________________________

From: Patrick Kalkman <PK...@hoogendoorn.nl>
To: log4net-user@logging.apache.org
Sent: Tuesday, August 18, 2009 8:29:17 AM
Subject: Experiencing locks while using AdoNetAppender 



Hi, 

I am using the AdoNetAppender for logging messages from multiple
application. All the applications log into one sqllite database.
Sometimes when a lot of information is logged I am experiencing
exceptions like:

log4net:ERROR [AdoNetAppender] Exception while writing to database
System.Data.SQLite.SQLiteException: The database file is locked
database is locked
at System.Data.SQLite.SQLite3.Reset(SQLiteStatement stmt)
at System.Data.SQLite.SQLite3.Step(SQLiteStatement stmt)
at System.Data.SQLite.SQLiteCommand.ExecuteNonQuery()
at System.Data.SQLite.SQLiteTransaction..ctor(SQLiteConnection
connection, Boolean deferredLock)
at System.Data.SQLite.SQLiteConnection.BeginTransaction(Boolean
deferredLock)
at System.Data.SQLite.SQLiteConnection.BeginDbTransaction(IsolationLevel
isolationLevel)
at
System.Data.Common.DbConnection.System.Data.IDbConnection.BeginTransacti
on()
at log4net.Appender.AdoNetAppender.SendBuffer(LoggingEvent[] events) 

The default CommandTimeout in the AdoNetAppender on the IDbCommand is 30
seconds, but I would like to influence this timeout in the log4net
configuration (file) so that I can influence the timeout on the logging
if the database is locked for a longer portion of time. Reducing the
timeout may lead to events getting lost, but I prefer that to our
application hanging for the full CommandTimeout waiting for the database
to become unlocked.

Is it possible to configure the timeout using configuration? or would it
be better to choose for a solution like deriving from the AdoNetAppender
and add the functionality?

Thanks in advance for any answers. 

Patrick 

**********************DISCLAIMER**********************
Deze E-mail is uitsluitend bestemd voor de geadresseerde(n). 
Verstrekking aan en gebruik door anderen is niet toegestaan. 
De Hoogendoorn Groep sluit iedere aansprakelijkheid uit die 
voortvloeit uit elektronische verzending.
This E-mail is intended exclusively for the addressee(s), 
and may not be passed on to, or made available for use by 
any person other than the addressee(s). 
The Hoogendoorn Group rules out any and every liability 
resulting from any electronic transmission.
*******************************************************
This message has been scanned by Network Associates' 
McAfee AntiVirus Technology


Re: Experiencing locks while using AdoNetAppender

Posted by Ron Grabowski <ro...@yahoo.com>.
I think that's how SQLite works. Have you tried writing to a single .db file from multiple threads without using log4net?




________________________________
From: Patrick Kalkman <PK...@hoogendoorn.nl>
To: log4net-user@logging.apache.org
Sent: Tuesday, August 18, 2009 8:29:17 AM
Subject: Experiencing locks while using AdoNetAppender 

 Experiencing locks while using AdoNetAppender  
Hi, 
I am using the AdoNetAppender for logging messages from multiple application. All the applications log into one sqllite database. Sometimes when a lot of information is logged I am experiencing exceptions like:
log4net:ERROR [AdoNetAppender] Exception while writing to database
System.Data.SQLite.SQLiteException: The database file is locked
database is locked
at System.Data.SQLite.SQLite3.Reset(SQLiteStatement stmt)
at System.Data.SQLite.SQLite3.Step(SQLiteStatement stmt)
at System.Data.SQLite.SQLiteCommand.ExecuteNonQuery()
at System.Data.SQLite.SQLiteTransaction..ctor(SQLiteConnection connection, Boolean deferredLock)
at System.Data.SQLite.SQLiteConnection.BeginTransaction(Boolean deferredLock)
at System.Data.SQLite.SQLiteConnection.BeginDbTransaction(IsolationLevel isolationLevel)
at System.Data.Common.DbConnection.System.Data.IDbConnection.BeginTransaction()
at log4net.Appender.AdoNetAppender.SendBuffer(LoggingEvent[] events) 
The default CommandTimeout in the AdoNetAppender on the IDbCommand is 30 seconds, but I would like to influence this timeout in the log4net configuration (file) so that I can influence the timeout on the logging if the database is locked for a longer portion of time. Reducing the timeout may lead to events getting lost, but I prefer that to our application hanging for the full CommandTimeout waiting for the database to become unlocked.
Is it possible to configure the timeout using configuration? or would it be better to choose for a solution like deriving from the AdoNetAppender and add the functionality?
Thanks in advance for any answers. 
Patrick 
**********************DISCLAIMER**********************
Deze E-mail is uitsluitend bestemd voor de geadresseerde(n). 
Verstrekking aan en gebruik door anderen is niet toegestaan. 
De Hoogendoorn Groep sluit iedere aansprakelijkheid uit die 
voortvloeit uit elektronische verzending.
This E-mail is intended exclusively for the addressee(s), 
and may not be passed on to, or made available for use by 
any person other than the addressee(s). 
The Hoogendoorn Group rules out any and every liability 
resulting from any electronic transmission.
*******************************************************
This message has been scanned by Network Associates' 
McAfee AntiVirus Technology

RE: Experiencing locks while using AdoNetAppender

Posted by Karim Bourouba <ka...@hotmail.com>.

Hi,
 
I have seen similar behaviour when working with Access. I know this wont help, but I found it to be a limitation of file based databases unfortunately :(



 



Subject: Experiencing locks while using AdoNetAppender 
Date: Tue, 18 Aug 2009 14:29:17 +0200
From: PKa@hoogendoorn.nl
To: log4net-user@logging.apache.org


Hi, 

I am using the AdoNetAppender for logging messages from multiple application. All the applications log into one sqllite database. Sometimes when a lot of information is logged I am experiencing exceptions like:

log4net:ERROR [AdoNetAppender] Exception while writing to database
System.Data.SQLite.SQLiteException: The database file is locked
database is locked
at System.Data.SQLite.SQLite3.Reset(SQLiteStatement stmt)
at System.Data.SQLite.SQLite3.Step(SQLiteStatement stmt)
at System.Data.SQLite.SQLiteCommand.ExecuteNonQuery()
at System.Data.SQLite.SQLiteTransaction..ctor(SQLiteConnection connection, Boolean deferredLock)
at System.Data.SQLite.SQLiteConnection.BeginTransaction(Boolean deferredLock)
at System.Data.SQLite.SQLiteConnection.BeginDbTransaction(IsolationLevel isolationLevel)
at System.Data.Common.DbConnection.System.Data.IDbConnection.BeginTransaction()
at log4net.Appender.AdoNetAppender.SendBuffer(LoggingEvent[] events) 

The default CommandTimeout in the AdoNetAppender on the IDbCommand is 30 seconds, but I would like to influence this timeout in the log4net configuration (file) so that I can influence the timeout on the logging if the database is locked for a longer portion of time. Reducing the timeout may lead to events getting lost, but I prefer that to our application hanging for the full CommandTimeout waiting for the database to become unlocked.

Is it possible to configure the timeout using configuration? or would it be better to choose for a solution like deriving from the AdoNetAppender and add the functionality?

Thanks in advance for any answers. 

Patrick 

**********************DISCLAIMER**********************
Deze E-mail is uitsluitend bestemd voor de geadresseerde(n). 
Verstrekking aan en gebruik door anderen is niet toegestaan. 
De Hoogendoorn Groep sluit iedere aansprakelijkheid uit die 
voortvloeit uit elektronische verzending.
This E-mail is intended exclusively for the addressee(s), 
and may not be passed on to, or made available for use by 
any person other than the addressee(s). 
The Hoogendoorn Group rules out any and every liability 
resulting from any electronic transmission.
*******************************************************
This message has been scanned by Network Associates' 
McAfee AntiVirus Technology
_________________________________________________________________
Windows Live Messenger: Celebrate 10 amazing years with free winks and emoticons.
http://clk.atdmt.com/UKM/go/157562755/direct/01/