Summary: | Create a Lock File when running KMyMoney | ||
---|---|---|---|
Product: | [Applications] kmymoney | Reporter: | Brendan <KDE> |
Component: | general | Assignee: | KMyMoney Devel Mailing List <kmymoney-devel> |
Status: | RESOLVED FIXED | ||
Severity: | wishlist | CC: | cloutier.jo |
Priority: | NOR | ||
Version First Reported In: | git (master) | ||
Target Milestone: | --- | ||
Platform: | Other | ||
OS: | Linux | ||
Latest Commit: | https://invent.kde.org/office/kmymoney/-/commit/8f5cf1c82a90869e2cc62bfc624a9de2336c0193 | Version Fixed In: | 5.2 |
Sentry Crash Report: |
Description
Brendan
2023-10-16 00:05:06 UTC
*** Bug 499729 has been marked as a duplicate of this bug. *** A possibly relevant merge request was started @ https://invent.kde.org/office/kmymoney/-/merge_requests/269 Git commit 8f5cf1c82a90869e2cc62bfc624a9de2336c0193 by Thomas Baumgart. Committed on 01/04/2025 at 08:39. Pushed by tbaumgart into branch 'master'. Protect opening file multiple times by a lockfile This locks the file on any mounted drive but not when you access it on some sort of cloud storage using a http(s) based URL. Related: bug 497229 FIXED-IN: 5.2 M +5 -0 kmymoney/interfaces/kmymoneyplugin.cpp M +20 -0 kmymoney/interfaces/kmymoneyplugin.h M +18 -24 kmymoney/kmymoney.cpp M +0 -2 kmymoney/kmymoney.h M +4 -0 kmymoney/plugins/gnc/import/gncimporter.cpp M +1 -0 kmymoney/plugins/gnc/import/gncimporter.h M +4 -0 kmymoney/plugins/sql/sqlstorage.cpp M +1 -0 kmymoney/plugins/sql/sqlstorage.h M +286 -184 kmymoney/plugins/xml/xmlstorage.cpp M +7 -25 kmymoney/plugins/xml/xmlstorage.h https://invent.kde.org/office/kmymoney/-/commit/8f5cf1c82a90869e2cc62bfc624a9de2336c0193 I just tested this change and it does not appear to be working correctly. When I run KMM, it does create a file named FileName.kmy.lck which then appears on my other system after Syncthing syncs the folder. When I try to open FileName.kmy on the second system, it opens fine, meaning I now have the same KMM file open on 2 systems. It overwrites the original lock file with the information from the second system. Contents of the lck file: First System: 699112 kmymoney LNX-BMC ac37039462fe4d0ab453b92a7b496f83 52b82ed4-97dd-4e78-a58a-4bf11c4bf95a Second System: 38354 kmymoney LNX-KIT ac37039462fe4d0ab453b92a7b496f83 95ade840-0d72-431d-b996-0db4f80d0f57 When I close KMM on the second system, the lock file is deleted. When I close it on the second system, I get and error on the command line (because the file is no longer there): Could not remove our own lock file "/PATH/FileName.kmy.lck" maybe permissions changed meanwhile? Here is the commend line output from the First and Second system *referrint to the order that I open KMM): First System: WebConnect: Running in server mode This is not KMyMoney plugin: '/usr/lib64/qt5/plugins/kmymoney_plugins/konlinetasks_sepa.so' 3:2025/04/01 09-21-00:(null)(699112):banking_update.c: 610: No AqBanking config folder found at [/home/bcoupe/.aqbanking/settings6/users] (-1) 3:2025/04/01 09-21-00:(null)(699112):banking_update.c: 610: No AqBanking config folder found at [/home/bcoupe/.aqbanking/settings/users] (-1) 3:2025/04/01 09-21-00:(null)(699112):banking_update.c: 411: There is no old settings folder, need initial setup "kmymoneySHeZoO" Python module failed to load Traceback (most recent call last): File "/tmp/kmymoneySHeZoO.py", line 10, in <module> import logging.config File "/usr/lib64/python3.13/logging/config.py", line 31, in <module> import logging.handlers File "/usr/lib64/python3.13/logging/handlers.py", line 30, in <module> import pickle File "/usr/lib64/python3.13/pickle.py", line 33, in <module> from struct import pack, unpack File "/usr/lib64/python3.13/struct.py", line 13, in <module> from _struct import * ImportError: /usr/lib64/python3.13/lib-dynload/_struct.cpython-313-x86_64-linux-gnu.so: undefined symbol: PyByteArray_Type Could not remove our own lock file "/home/bcoupe/KMM/Coupes.kmy.lck" maybe permissions changed meanwhile? (kmymoney:699112): GLib-GIO-CRITICAL **: 09:23:05.374: GFileInfo created without standard::icon (kmymoney:699112): GLib-GIO-CRITICAL **: 09:23:05.374: file ../gio/gfileinfo.c: line 1765 (g_file_info_get_icon): should not be reached (kmymoney:699112): GLib-GIO-CRITICAL **: 09:23:05.374: GFileInfo created without standard::icon (kmymoney:699112): GLib-GIO-CRITICAL **: 09:23:05.374: file ../gio/gfileinfo.c: line 1765 (g_file_info_get_icon): should not be reached (kmymoney:699112): GLib-GIO-CRITICAL **: 09:23:05.374: GFileInfo created without standard::icon Second System: WebConnect: Running in server mode This is not KMyMoney plugin: '/usr/lib64/qt5/plugins/kmymoney_plugins/konlinetasks_sepa.so' 3:2025/04/01 09-22-18:(null)(38354):banking_update.c: 610: No AqBanking config folder found at [/home/bcoupe/.aqbanking/settings6/users] (-1) 3:2025/04/01 09-22-18:(null)(38354):banking_update.c: 610: No AqBanking config folder found at [/home/bcoupe/.aqbanking/settings/users] (-1) 3:2025/04/01 09-22-18:(null)(38354):banking_update.c: 411: There is no old settings folder, need initial setup "kmymoneyJIOaix" Python module failed to load Traceback (most recent call last): File "/tmp/kmymoneyJIOaix.py", line 10, in <module> import logging.config File "/usr/lib64/python3.13/logging/config.py", line 31, in <module> import logging.handlers File "/usr/lib64/python3.13/logging/handlers.py", line 30, in <module> import pickle File "/usr/lib64/python3.13/pickle.py", line 33, in <module> from struct import pack, unpack File "/usr/lib64/python3.13/struct.py", line 13, in <module> from _struct import * ImportError: /usr/lib64/python3.13/lib-dynload/_struct.cpython-313-x86_64-linux-gnu.so: undefined symbol: PyByteArray_Type (kmymoney:38354): GLib-GIO-CRITICAL **: 09:22:36.569: GFileInfo created without standard::icon (kmymoney:38354): GLib-GIO-CRITICAL **: 09:22:36.569: file ../gio/gfileinfo.c: line 1765 (g_file_info_get_icon): should not be reached (kmymoney:38354): GLib-GIO-CRITICAL **: 09:22:36.569: GFileInfo created without standard::icon (kmymoney:38354): GLib-GIO-CRITICAL **: 09:22:36.569: file ../gio/gfileinfo.c: line 1765 (g_file_info_get_icon): should not be reached (kmymoney:38354): GLib-GIO-CRITICAL **: 09:22:36.569: GFileInfo created without standard::icon (kmymoney:38354): GLib-GIO-CRITICAL **: 09:22:36.569: file ../gio/gfileinfo.c: line 1765 (g_file_info_get_icon): should not be reached I analyzed the problem and it turns out that QSysInfo::machineUniqueId (https://doc.qt.io/qt-5/qsysinfo.html#machineUniqueId) is returning the same ID on both systems (ac37039462fe4d0ab453b92a7b496f83). Diving into Qt source code I found out that this value is extracted from /var/lib/dbus/machine-id (which in my case is a symlink to /etc/machine-id). https://wiki.debian.org/MachineId contains some more information including how to create a new value. That was the problem. They are cloned systems. Is it possible to display the hostname from the lck file in the error message? That's a Qt feature I don't have control over. I haven't look in deep into the mr, but since the dbus check seems to be removed, if the lock file contains the same machine ID, shouldn't it prevent opening it, otherwise it would now allow opening or twice on the same device? KMM already handled the case when you try to open the same file on the same computer and that still works after this change. The error message for both attempting to open the file a second time on the same system and on a remote system are the same. "File FineName.kmy is already opened by another process." I would argue that is should say on another system when it's based on the lock file and the machine IDs are different but that sounds like a Qt issue. Not sure how KMM detects that the local file is already opened. It seems like different mechanisms with the same error message. > Not sure how KMM detects that the local file is already opened.
> It seems like different mechanisms with the same error message.
Not really. All handled by QLockFile. On the same machine it takes the process ID contained in the first line of the lockfile and checks that the process is still running.
Where was the lck file stored? I never saw that before the recent change. There was no lock file prior to this change. It was handled using calls over D-Bus between the KMyMoney processes. This sure does only work on systems that have a D-Bus instance and only on the local host not over a network. |