Database is locked or write protected only with version 5.3.2

Started by sampson, January 17, 2015, 02:57:28 AM

Previous topic - Next topic

sampson

This problem only happen after updated to version 5.3.2.

I have two workstations (w7a and w7b) at home.  One for myself and one for my wife.

My Photos and Databases are put in a shared folder.  Both machine mapped to the same Z:.

For 5.3.2, I discovered that for Databases updated by w7a, it cannot be opended by w7b and vice versa.

For testing
- At w7a, create new DB "at-w7a"
- close IM and shutdown machine
- At w7b, open the DB "at-w7a"
Immediately, I got the same error

w7a and w7b are using the same licensed version.  Is that I need to buy two license for using at two machines to avoid this problem?

Thanks in advance!

Sampson

Mario

You did update from which version to 5.3.2?
Can you please show us a log file, because it will contain more info. Lookup log file in the IMatch help for details.
A database can only be opened in writable mode from one computer at a time.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

sampson

My previous version is also iMatch 5.  Which is the license version from Dec 2014.

I updated to 5.3.2 around Jan 10, 2015.

I am aware only one machine can open DB in read/write mode. 

Thus in my final test, I completely shutdown the computer that created the new DB.

Attached is the log file from the computer failed to open the DB.

Thank you!


[attachment deleted by admin]

joel23

Quote from: sampson on January 17, 2015, 09:50:56 AM
My previous version is also iMatch 5.  Which is the license version from Dec 2014.

I updated to 5.3.2 around Jan 10, 2015.

I am aware only one machine can open DB in read/write mode. 

Thus in my final test, I completely shutdown the computer that created the new DB.

Attached is the log file from the computer failed to open the DB.

Thank you!
Check the mapping respectively the access rights for the mappings on each computer on which you can't open the DB. The log is telling that the DB is read-only on a read-only media. This might happen when the imd5 files is read-only or the user accessing the share only has read-only rights.

It seems to me that only the particular owner/creater of the DB has write access.
Eg. w7a\username has r/w access to at-w7a from w7a, but w7b/username has only read access to at-w7a from w7b and vice versa.
regards,
Joerg

Mario

I agree. The first thing to check that all users who access the folder (and all files within) containing the database must have read/modify/write access. Note that user "A" on computer "A" is not the same as user "A" on computer "B" (from a Windows security perspective).
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

sampson

folder permission checked.

At w7b, w7b\usernameI can delete that file, modify that file and create new file.
Also at w7a, w7a\username can delete/modify/create.

Access to the database files are fine from both computers until updated to 5.3.2 version.


Mario

The folder must have these permissions as well, because IMatch needs to create read/write temporary files.
Does the folder contain a file with the .imsema extension?
This file is used to control concurrent access by multiple users to a database file.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

sampson

Yes.  Folder permission are there as well.

I can open the old DB from previous version without issues.

Only after upgrade to  5.3.2 version then having this problem.


Mario

Older versions of IMatch cannot open databases created or modified with newer versions (IMatch performs ín-line upgrades when opening older databases as needed). You should get a message. If you can open the database with an older IMatch version, IMatch 5.3.2 was never able to open the database in writable mode and thus could not perform the necessary changes. Which may also explain the problem you see.

Try to copy the database to a local disk, open it with IMatch 5.3.2 in writable mode, and then copy it back.

Also make sure that the "Open databases read-only" option is not enabled in the Database menu.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

sampson

I have about 20 DBs, one per year, which is created in the version just prior to 5.3.2.

All of them can be opened by either of w7a or w7b at that time.

Then 5.3.2 released and I upgraded at around Jan 10, 2015.

Then I discover, DB "upgraded" by w7a cannot be opened by w7b, and vice versa.

To double confirm this problem, in w7a using 5.3.2, I create a new DB - without any photos added.

I completely shutdown w7a, then use w7b to open the new DB (also with 5.3.2 version).

It shows the same problem.

5.3.2 can upgrade old schematic of DB without issues - I upgrade two DBs, one from w7a and one from w7b so far.

Mario

Your log file tells us that IMatch opens the db in read-only mode because the read-only open option is enabled, or the database can only be accessed in read-only mode (Windows refuses to allow IMatch to open the file in writable mode). Did you see my question about the .imsema file?
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

joel23

I tried to reproduce your problem with a network share mapped to both computers, accessed by different users on each computer.
Created one DBs on each computer and I'm able to open them on the respectively other computer in r/w, as it should be.

Show us the security settings of the shared folder and the permissions for the share. And let us know in which groups the users are in.
regards,
Joerg

Aubrey

I'm using a disk on another machine for one of my databases - technical papers in PDF format. I had to ensure that the protection of the folder where the database resides was to allow everyone to read/write (well that's what I did since I am the only user on my machines). Imatch did tell me that I had a protection issues.

If I don't use the disk remotely I will sometimes remote login to the laptop and work there from my main machine, either way I don't have issues.

Aubrey.


sampson

I created two new virtual machines with iMatch 5.2.18 installed.

At each machine, I created two new DBs 5.2.18at-w7a and 5.2.18at-w7b to the same shared folder.

Both of the DBs can be opened by the other machine.

I will upgrade both machines to iMatch 5.3.2  testing again tonight and report back.

Thank you everyone for your inputs.

sampson

This log files shows a "Database is locked" error while creating a new DB to the shared folder.

It should after the DB file is created by before the dialog asking for "Cache" options.

[attachment deleted by admin]

sampson

This log file shows for the same DB 'Z:\sdc\PhotoMaster\iMatchDBs\IMatch-2002.imd5':

At 08:10 , DB open failed with the "Database is Locked" error.

Re-open at 08:13, DB opened without problem.

[attachment deleted by admin]

joel23

Same entries in log as before.

But what I haven't noticed before is that there is no DB name:

Database '' for thread 0 (0)  Database file read-only/on read-only media. Read-only requested.
Should look like
Database 'Z:\test.imd5' for thread 2410 (9232)  Database file read-only/on read-only media. Read-only requested.
regards,
Joerg

Mario

Read-only requested could indicate that the database was opened while the option "Open databases in read-only mode" option was set in the Database menu.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

joel23

Quote from: Mario on January 21, 2015, 08:45:36 AM
Read-only requested could indicate that the database was opened while the option "Open databases in read-only mode" option was set in the Database menu.
Than the line(s)
Database 'Z:\sdc\PhotoMaster\iMatchDBs\IMatch-2002.imd5' for thread 5E8 (1512)  Writable.
wouldn't exist in this form.

01.21 08:10:01+    0 [05E8] 02  I>        Database 'Z:\sdc\PhotoMaster\iMatchDBs\IMatch-2002.imd5' for thread 5E8 (1512)  Writable.
01.21 08:10:01+    0 [05E8] 02  I>        Database file has 64.34 MB
01.21 08:10:01+    0 [05E8] 02  I>        Journal mode is: WAL
01.21 08:10:01+    0 [05E8] 02  I>    Locking mode is EXCLUSIVE
01.21 08:10:01+    0 [05E8] 02  I>    SyncMode is NORMAL
01.21 08:10:01+    0 [05E8] 02  I>        Database 'Z:\sdc\PhotoMaster\iMatchDBs\IMatch-2002.imd5' for thread 5E8 (1512)  Writable.
01.21 08:10:01+    0 [05E8] 02  I>        Database file has 64.34 MB
01.21 08:10:01+    0 [05E8] 02  I>        Journal mode is: WAL


All is normal until here, followed by the errors:
Database is on a read-only media or the current user has no write privileges to the folder containing the database file. The database must be prepared for this situation. See IMatch help for details.  'IMSQLite.cpp(2798)'
01.21 08:10:01+   15 [05E8] 02  I>        Database '' for thread 0 (0)  Database file read-only/on read-only media.
01.21 08:10:01+    0 [05E8] 02  I>        Failed to open file (3)
01.21 08:10:01+    0 [05E8] 02  I>        Database '' for thread 5E8 (1512)  Database file read-only/on read-only media. Read-only requested.
01.21 08:10:01+    0 [05E8] 02  I>        Failed to open file (3)
01.21 08:10:01+    0 [05E8] 02  I>        Journal mode is: DELETE
01.21 08:10:01+    0 [05E8] 02  I>    SyncMode is NORMAL
01.21 08:10:01+    0 [05E8] 02  I>        Journal mode is: DELETE


entries like "Journal mode is: DELETE" I never saw before.
regards,
Joerg

Mario

Database is on a read-only media or the current user has no write privileges to the folder containing the database file.

Is the key line. We're running in circles here as it seems. The database system recognizes that the user running IMatch is not allowed to make changes to the database file or the folder or is not allowed to create new temporary files (which is done frequently while IMatch is running) and switches the database to read-only mode.

Check your security settings, file system permissions, make sure that they are properly inherited etc. As soon as the database system can write to the folder, open files in writable mode and is allowed you create the cruical temporary files it will work like a charm. Just fix your security.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

sampson

Quote from: Mario on January 21, 2015, 11:55:34 AM
Database is on a read-only media or the current user has no write privileges to the folder containing the database file.

Is the key line. We're running in circles here as it seems. The database system recognizes that the user running IMatch is not allowed to make changes to the database file or the folder or is not allowed to create new temporary files (which is done frequently while IMatch is running) and switches the database to read-only mode.

Check your security settings, file system permissions, make sure that they are properly inherited etc. As soon as the database system can write to the folder, open files in writable mode and is allowed you create the cruical temporary files it will work like a charm. Just fix your security.

Folder / File security is verified without issues.

Please recall my previous test cases:

1.  in Version 5.2.18, DBs in the Same Shared folder can be accessed.  (Even same DB)
2.  In 5.3.2, I can create New DB at the Same Shared folder.
3.  In my recent logs, one moment DB opening is OK, and the second moment DB is locked.

I can assure you that all up to the OS level, I did verify and they are normal.

From my file server, there is no access denied recorded.


Mario

Then this seems to be a very mysterious case. It works here and (judging by the absence of complaints) for other users using IMatch 5.3 in a shared environment. I'm not sure if you missed the version jump which introduced the sema files (I asked about that above two times bit you have not yet answered if you see a .imsema file in the folder).
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

sampson

Quote from: Mario on January 21, 2015, 03:48:15 PM
Then this seems to be a very mysterious case. It works here and (judging by the absence of complaints) for other users using IMatch 5.3 in a shared environment. I'm not sure if you missed the version jump which introduced the sema files (I asked about that above two times bit you have not yet answered if you see a .imsema file in the folder).

Sorry that I missed your question.

Yes, when the DB can be opened, there are 3 temp files created at the same folder of the DB file.  The .imsema file is one of them.  Once I close the DB, those 3 files are gone.

*-wal
*-shm
*.imsema

Mario

If IMatch can create these files, everything seems to be in order - or does it create these three files and then switches the database to read-only mode?
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

sampson

Quote from: Mario on January 21, 2015, 05:21:13 PM
If IMatch can create these files, everything seems to be in order - or does it create these three files and then switches the database to read-only mode?

The Open DB in Read-only mode is not set in Settings.

And when open the DB, Read-only is not selected.

If indeed I use Read-only mode by mistake, it should just able to open without giving me the "Database is locked" message - as that file is not opened by anyone.

Mario

A read-only database and a locked database are different. Locked means that the database is already open by another user/application and that Windows refuses IMatch exclusive access. Since the exclusive access pattern does not work on some configurations (e.g. with databases on a NAS with SAMBA), IMatch uses the imsema (semaphore) file to control exclusive access.

If the imsema file exists, another user has open the database already in writable mode and if you attempt to open the database, IMatch reports it as locked. If all users open the database with the "Open in read-only mode" option set in the Database menu, multiple users can open the database. This works with or without a imsema file. If the database file is marked as read-only or Windows refuses to open the database file in writable mode, IMatch attempts to open the database in read-only mode automatically. If this also fails, you get message. If the database file can be opened in writable mode but the database system fails to create the temporary files because of security permission problems for the folder itself, you get a message (the one we had in one of your log files, don't recall which one).

If something in this schema fails, it's always (at least in the past up to now) some security settings or more or less weird network-related issues. If your DB is on a NAS with SAMBA, things may be further complicated by the combination of security settings in Windows and security settings in Linux on the NAS and security settings in SAMBA on the NAS:
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

joel23

I can reproduce this error messages - which is different from a read-only DB, which I thought was the reason -, by making imd5-wal or imd5.imsema files read-only.
Make sure the files are not accessed and locked by eg. a virus scanner or any other application.
regards,
Joerg