Database locked error

I have just had an SQLite database locked error for the second time in a few days

As you will see from the screen print, I had two windows on this database open - not something I had intended. When I had mistakenly done this before, one of the copies was listed in the window heading as ‘read only’, but this time not.

RM/SQLite won’t even let me close the close the locked database. I can keep on working on the database in the other window and can close that, which then undoes the locking of the first window so that I can eventually close that too and re-open it safely. The first time I had this problem, I didn’t see that I had a second window on the database open and had to resort to task manager to close things.

So ultimately this is not a big issue but I think that there are three points

  1. People like me are used to double-clicking on things to open them; it seems that RM9 just needs a single click and that double-clicking opens the file twice. (By contrast, if you click to open a file after it has already opened, RM9 switches to it rather than opening it again)

  2. Although I have seen a file marked as ‘read only’ I cannot create one right now; double clicking consistently seems to open the same file twice, with neither marked as ‘read only’. Some combination of opening/editing things after this then produces the ‘database locked’ error.

  3. As has been noted by others in this forum, RM9 on windows does not indicate to you how many windows you have open; I had no idea that I had opened two windows on the same file until I had started investigating this error. This really is not good.


If by double-clicking… You mean… within the Recent Files name listings, I can’t seem to get two copies to open simultaneously on my Edition Windows 10 Pro Version 22H2 OS build 19045.3208 64-bit. Also, don’t recall ever seeing it reported here in the forum. Anything unique about your environment? Other program(s) running concurrently? Using an alternate to vanilla Windows File Explorer? Virtual Machine?
EDIT: Nevermind, I see from another post that you’re running Windows 11. That might be it.

I am using windows 11, but I doubt that that makes a difference.

Starting here, I only have my main database open.

I then double-click on a much smaller file ‘Edwards’ from within the RM9 file tab and it opens twice

I have now done this five or six times in a row. It seems to be completely repeatable.

Nope, I can’t make it happen. Weird. No matter double-, triple-, or more clicks in rapid sucession.

I followed @AlanWatson 's procedure and my RM opened two copies of the second file when I double clicked. However, nothing was locked. I could edit the same person in both copies of the file. I have Windows 10 Home version 22H2 and a second external monitor. I don’t know if it makes any difference, but I went to Windows ‘settings’ and searched the word ‘single’ (without quotes). One of the selections was specify single or double click to open. I have double click selected.
Like I said, I don’t know if it would have anything to do with this (probably not).

I have seen your “read only” situation, but only in very different circumstances.

My RM9 database is stored in my OneDrive folder. Until fairly recently, this seemed safe enough because unlike Dropbox, OneDrive did not try to sync my RM database to the cloud while it was in use. In this environment, after closing RM9, OneDrive will commence a sync immediately and the sync takes quite a while - like several dozen seconds. Once I tried to re-open the database while the sync was still in progress. Under these circumstances, RM9 saw the database as in use by another process (namely, by OneDrive) and opened it as read only. As a read only database, RM9 couldn’t do anything with it.

My bypass at the time was simply to wait for the sync to complete before re-opening my RM9 database. And for that matter, I seldom close my RM9 database and then re-open it immediately. In the meantime, something seems to have changed either in RM9 or in Windows or in OneDrive because sometimes OneDrive now will try to sync my RM9 database even though it’s in use by RM9. My new workaround is to pause OneDrive while I’m using RM9, just like I used to have to do with Dropbox when my RM database was in my Dropbox folder.

So here’s my theory of your case. RM9 does not gain exclusive control of the database at all times. This is proven by the fact that SQLite queries can be run against an RM9 database that is open in RM9. But apparently RM9 does gain exclusive control of the database occasionally. So when you double click your second database and when it opens twice, one of the instances of RM9 is gaining exclusive access for a brief time which is causing the second instance to open the database read only. It’s probably a race condition which is why not every user will see the problem every time. With a race condition, the problem will not be 100% repeatable.

I certainly agree that there are several weaknesses in RM9’s support for multiple databases being open at the same time. The most obvious weakness is that it’s hard to know that more than one database is open at the same time and it’s hard to switch between them… You have identified an additional weakness with your double click scenario.

A database can only be opened in one program window at a time. Confirming the double click and opening twice has been reported to development.

Jerry; Why use Onedrive or Dropbox at all?

My files on my computer are local which ensures automatic backup to my iDrive cloud and time machine external drives without any sync issues.

Because I’m on Windows. And I’m on Windows because I have a strong dislike for the Mac user interface. I have an iPhone and an iPad, both of which I like very much. But I don’t like using a Mac.

1 Like

Thank you for that Renee.

I have also seen the same behavior with double clicking.

SQLite only locks a database while a write operation is in progress and then quickly unlocks it. (SQLite documentation brags about how quick this is, which allows greater thru-put with multiple processes accessing the same database).
I agree with Jerry that it’s probably some kind of race condition, something that should be fixable in RM.

While SQLite may be quick at releasing a write-lock, how does RM handle the error message? Maybe it has no graceful exit strategy and simply dead-ends.

Exactly what I was thinking.