Sqlite: Unable to open database file

The webapp for my project at work was receiving the error “unable to open database file” from SQLite. The error was intermittent hence it was hard to diagnose. I was using a SQLite database on a webserver running xsp2 and mono (i.e. ASP.Net).  A few times I also received the error “System.IO.File: Too many files open” but this only happened once or twice.

I was running the webapp on openSUSE 11, after some dead ends I finally tried opening a large number of file descriptors from a simple console app. That’s how I discovered that by default openSUSE 11 only lets a process open ~1023 file descriptors. But xsp2 opens a large number of file descriptors when it’s serving web pages in fact this is why SQLite was giving the error “unable to open database file”. SQLite couldn’t allocated a new file descriptor for opening the database file since xsp2 had already used all of the available file descriptors. The fix is to add the following lines to /etc/security/limits.conf

* soft nofile 2048

* hard nofile 4096

To check the user file descriptor limits on unix run the command: ulimit -a

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s