Locked database causes application hang
If an application crashes, it may leave the database locked. In this case, tracker_sparql_connection_new() seems to block forever:
> ls ~/.local/share/gnome-photos/.meta.isrunning -al
-rw-r----- 1 sam sam 0 Aug 25 17:28 /home/sam/.local/share/gnome-photos/.meta.isrunning
(gdb) ba
#0 0x00007ffff77e9801 in clock_nanosleep@GLIBC_2.2.5 () at /lib64/libc.so.6
#1 0x00007ffff77ef157 in nanosleep () at /lib64/libc.so.6
#2 0x00007ffff781a869 in usleep () at /lib64/libc.so.6
#3 0x00007ffff527bbb0 in unixSleep () at /lib64/libsqlite3.so.0
#4 0x00007ffff5276fcd in sqliteDefaultBusyCallback () at /lib64/libsqlite3.so.0
#5 0x00007ffff52de9ac in sqlite3BtreeBeginTrans () at /lib64/libsqlite3.so.0
#6 0x00007ffff531d2e0 in sqlite3VdbeExec () at /lib64/libsqlite3.so.0
#7 0x00007ffff53226e2 in sqlite3_step () at /lib64/libsqlite3.so.0
#8 0x00007ffff556763f in stmt_step (stmt=0x8d5858) at ../subprojects/tracker/src/libtracker-data/tracker-db-interface-sqlite.c:1761
#9 0x00007ffff55697c4 in execute_stmt (interface=0x46a180, stmt=0x8d5858, cancellable=0x0, error=0x7fffffffd408)
at ../subprojects/tracker/src/libtracker-data/tracker-db-interface-sqlite.c:2863
#10 0x00007ffff556b4d9 in tracker_db_statement_execute (stmt=0x7cb080, error=0x7fffffffd408)
at ../subprojects/tracker/src/libtracker-data/tracker-db-interface-sqlite.c:3591
#11 0x00007ffff556c08d in tracker_db_manager_set_metadata
(db_manager=0x45c9e0, key=0x7ffff55a901d "parser-version", value=0x7fffffffd440)
at ../subprojects/tracker/src/libtracker-data/tracker-db-manager.c:280
#12 0x00007ffff556d6bf in tracker_db_manager_tokenizer_update (db_manager=0x45c9e0)
at ../subprojects/tracker/src/libtracker-data/tracker-db-manager.c:980
#13 0x00007ffff555a65a in rebuild_fts_tokens (manager=0x466ae0, iface=0x46a180)
at ../subprojects/tracker/src/libtracker-data/tracker-data-manager.c:3769
#14 0x00007ffff555c51e in tracker_data_manager_initable_init (initable=0x466ae0, cancellable=0x0, error=0x7fffffffd6b8)
at ../subprojects/tracker/src/libtracker-data/tracker-data-manager.c:4622
#15 0x00007ffff66c1e9f in tracker_direct_connection_initable_init (initable=0x466ac0, cancellable=0x0, error=0x7fffffffd778)
at ../subprojects/tracker/src/libtracker-sparql/direct/tracker-direct.c:269
#16 0x00007ffff66a522f in tracker_sparql_connection_new
(flags=(TRACKER_SPARQL_CONNECTION_FLAGS_FTS_ENABLE_UNACCENT | TRACKER_SPARQL_CONNECTION_FLAGS_FTS_ENABLE_STOP_WORDS | TRACKER_SPARQL_CONNECTION_FLAGS_FTS_IGNORE_NUMBERS), store=0x44cb80, ontology=0x7fffe40022c0, cancellable=0x0, error=0x445418)
at ../subprojects/tracker/src/libtracker-sparql/tracker-backend.vala:43
#17 0x00007ffff7e2e9f8 in photos_tracker_queue_initable_init (initable=<optimized out>, cancellable=0x0, error=0x7fffffffd808)
at ../src/photos-tracker-queue.c:402
--Type <RET> for more, q to quit, c to continue without paging--
#18 0x00007ffff7e2ed52 in photos_tracker_queue_dup_singleton (cancellable=0x0, error=0x7fffffffd808)
at ../src/photos-tracker-queue.c:463
#19 0x00007ffff7df76af in photos_item_manager_init (self=0x442090) at ../src/photos-item-manager.c:1105
#20 0x00007ffff7d27498 in g_type_create_instance () at /lib64/libgobject-2.0.so.0
#21 0x00007ffff7d0d205 in g_object_new_internal () at /lib64/libgobject-2.0.so.0
#22 0x00007ffff7d0e6ad in g_object_new_with_properties () at /lib64/libgobject-2.0.so.0
#23 0x00007ffff7d0f331 in g_object_new () at /lib64/libgobject-2.0.so.0
#24 0x00007ffff7df9159 in photos_item_manager_new () at ../src/photos-item-manager.c:1237
#25 0x00007ffff7e184c4 in photos_search_context_state_new (self=<optimized out>) at ../src/photos-search-context.c:52
#26 0x00007ffff7dccc85 in photos_application_init (self=0x4341f0) at ../src/photos-search-context.h:31
#27 0x00007ffff7d27498 in g_type_create_instance () at /lib64/libgobject-2.0.so.0
#28 0x00007ffff7d0d205 in g_object_new_internal () at /lib64/libgobject-2.0.so.0
#29 0x00007ffff7d0efac in g_object_new_valist () at /lib64/libgobject-2.0.so.0
#30 0x00007ffff7d0f30d in g_object_new () at /lib64/libgobject-2.0.so.0
#31 0x00007ffff7dd2807 in photos_application_new () at ../src/photos-application.c:3088
#32 0x00000000004010fb in main (argc=1, argv=0x7fffffffe0a8) at ../src/photos-main.c:56
I'm pretty sure this is what caused the hangs I reported as #246 (closed) as well