[tracker/wip/carlosg/several-fixes: 4/4] tracker: Use readonly connection if possible on "tracker3 sparql"




commit ccac0922a592ae4b2b200a0ad8deb8dafbbf0f0d
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Aug 25 17:58:29 2020 +0200

    tracker: Use readonly connection if possible on "tracker3 sparql"
    
    Otherwise, the connection competes with whoever really owns the database,
    and goes through the rather slow file locking and busy handling methods.
    We should strive to keep the database writable by a single process, so
    make sure we use a readonly connection if we are only doing queries.

 src/tracker/tracker-sparql.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/src/tracker/tracker-sparql.c b/src/tracker/tracker-sparql.c
index 07c1b3b59..2841d355f 100644
--- a/src/tracker/tracker-sparql.c
+++ b/src/tracker/tracker-sparql.c
@@ -180,7 +180,9 @@ create_connection (GError **error)
                GFile *file;
 
                file = g_file_new_for_commandline_arg (database_path);
-               return tracker_sparql_connection_new (TRACKER_SPARQL_CONNECTION_FLAGS_NONE,
+               return tracker_sparql_connection_new (update ?
+                                                     TRACKER_SPARQL_CONNECTION_FLAGS_NONE :
+                                                     TRACKER_SPARQL_CONNECTION_FLAGS_READONLY,
                                                      file, NULL, NULL, error);
        } else if (dbus_service && !database_path && !remote_service) {
                GDBusConnection *dbus_conn;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]