This project is read-only.

Is this useable on the server? (SOLVED)

Jan 27, 2013 at 8:15 PM
Edited Jan 27, 2013 at 8:18 PM

Can I use NDatabase as a backend store for a web application?

I ask because while you do have the web application as an example, earlier, you commented that NDatabase isn't capable of multithreaded use.

Jan 29, 2013 at 8:14 AM

Yes, there is sample with ASP.NET usage, but you need to have in mind that for now NDatabase is working in single thread mode, but .. if you manage calls to db and always the calls will be put into using, then you can have a lock which will block changes done in the same time on db.

Parallel access to db is not possible for now, but that doesn't mean you cannot use it with on sync code ;)

Jan 29, 2013 at 9:00 AM

The question I have is this.

Since "using" will lock, if another web user tries to use the resource(the db file), will the using statement wait if a lock is already present, or will it fail?

Or is it just better to do either of the following(even though there is overhead to sync).

object obj = x;
try {
    // add using code here
finally {

or this

 public void MyMethod()
 // Our database stuff here
Feb 3, 2013 at 7:21 AM

It will throw exception. I'm planning to make changes in that for one of the future releases, so I want to implement multithread access to that. Thanks for all your suggestions!

Regarding your code samples, here I think you have a right answer on that :)
Feb 5, 2013 at 8:48 PM
Good, I'm glad it helps.

Right now, we use a service bus(messaging system), so I'm guaranteed that each request to access the database will be single threaded, so I'm in no rush.

Another way I thought of to eliminate the collision is to have a database for each user. I would create the database filename using some unique user identification. So there are ways to mitigate the problem, but it would be nice to have the database itself handle the conflict.

BTW, I'm loving this product.
Mar 17, 2013 at 6:42 AM
Now it is easier to use NDatabase on the server too. It supports multithread access, and even access from many processes with many threads. (NDatabase 3.6).

Mar 17, 2013 at 9:08 AM
Very good news, congratulations on your good and hard work!
Mar 20, 2013 at 9:39 PM
Are there any performance issues when accessing database file from multiple processes?
Mar 21, 2013 at 8:34 AM
Could be, the default settings (OdbFileManager) are only the defaults ;)

You could check, if changing this settings is helping you, if yes I will move this two settings to OdbConfiguration.

Mar 21, 2013 at 7:13 PM
Thanks for pointing out the OdbFileManager.

If i run into problem with this "if is file locked wait one second" approach, instead of messing with settings i'll change synchronization to system wide mutex. I don't like the while(true){TryAgain();Thread.Sleep();} approach :)
Mar 22, 2013 at 9:06 AM
The solution was chosen because of its simplicity, and when you have different processes which shouldn't be dependent (only file is shared), the actual solution sounds good for me.

As I wrote above, if there is a need I could make it configurable.