NFS or not NFS

A user has a database on an NFS share. The database is an SQLite fts one. After writing some data the database has a hissy fit and produces an error “unable to open database file” when trying to write. He has confirmed that the error doesn’t show up when the database is local.

So I tried to goggle and had a 30 minutes conversation with ChatGPT to have a Terminal command to get information about nfs. Is this correct?

mp=$(/usr/bin/stat -f %m "/Users/beatrixwillius/Mail Archive.DBIndex"); mount -t nfs | awk 'match($0,/ on (.*) \(/,m){print m[1]}' | grep -Fx -- "$mp" >/dev/null && echo nfs || echo not-nfs

The file is just for me for testing.

I’d also welcome a plugin solution rather than working with a fiddly Terminal command.

Not sure what you want to achieve here…

A simple mount -t TYPE does show only file systems with the given type.

I have no NFS mount here but for smbfs I have this example from terminal:

tom ~ % mount -t smbfs

//USERNAME@tSERVERURL/VOLUMENAME on /Volumes/VOLUMENAME (smbfs, nodev, nosuid, mounted by tom)

In case there is no mounted volume with the given type the result is empty.

You can also use statfs as shown in MacVRefNum and Monterey - #11 by TomE1

For the above shown example I get

statfs_fsid: 16777260
*** /Volumes/Software ***
f_fssubtype: “24”
f_fstypename[MFSTYPENAMELEN]: “smbfs”
f_mntonname[MAXPATHLEN]: “/Volumes/Software”

So you can just go thru all volumes and check the f_fstypename.

No need for any plugin here.

Should the simple Terminal command show no result if I’m connected to my second computer with SMB?

What does the result of the code from 2023 mean?

Again this doesn’t show my second computer.

You can look in terminal just using the mount command without options. It shows all currently mounted volumes.
Note: the SMB file type is smbfs not just smb!

I guess you used the code from another reply where just a block size is returned. See my code in the post from March, 10 where all fields are returned.
The output is partly shown in my 2nd reply here.
You can adjust the code to get the wanted field (f_fstypename), only.

1 Like

You’re aware that SQLite doesn’t support network use for this very reason, right?

1 Like

I think what Beatrix is trying to do is detect the network drive and alert the user.

I’m not doing “network use”. ChatGPT recommends to use a different WAL mode on a network share. I want to test if this actually does something.

I’m now using a way more simple solution: the main Valentina database has a lock file if it’s on a remove drive. In this case I use some different pragmas and I can check if ChatGPT is full of sugar or not.

Oh, I would just straight up tell the user “You can’t do that.”

The SQLite guys recommend that you don’t put databases on a network share.

I know that. However, the users do not understand why they should use my Pro version which is 4 times as expensive and needs a database server. The Valentina databases uses a lock file so that only one person can open the database at a time. The SQLite databases only have an fts table. If the database goes corrupt it can be re-created. Or you ask the Valentina guys why they haven’t made an fts search in 2 decades. I’d love to have that in Valentina.

Have you tried this trick with SQLite ?

What I was thinking was to add a Prefs file when the SQLite file is opened and delete it when it is closed. On the other(s) applications, when the user want to write, the application check the presence of the Prefs file: if it is Present (True): stop and report the Open operation cannot be done right now, etc.

No: I do not had the opportunity to implement that, sorry.

Ask, if my text above is unclear.

:backhand_index_pointing_right: After writing some data the database has a hissy fit and produces an error “unable to open database file” :backhand_index_pointing_left:

:thinking:

Maybe get your app in this situation to copy the file locally, use the local copy and then copy it back when it is closed.

1 Like

I call this feature “Super Simple Sync” in Lifeboat, and it’s an effing nightmare to get people to use correctly.

As long as only one user is allowed to access the database the app could do this automatically so the user wouldn’t know (we do this in one of our apps as the SQLite files are nearly always on a network).

Which is literally the first problem ever in 15 years.