Added a query plan recorder for debugging purposes
This commit is contained in:
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<messages xmlns:if="Wt.WTemplate.conditions">
|
||||||
|
|
||||||
|
<message id="Lms.Admin.DebugTools.Db.template">
|
||||||
|
<form>
|
||||||
|
<div class="row g-3">
|
||||||
|
<div class="col-12">
|
||||||
|
${export-query-plans-btn class="btn btn-primary"}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</message>
|
||||||
|
|
||||||
|
</messages>
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<messages xmlns:if="Wt.WTemplate.conditions">
|
||||||
|
|
||||||
|
<message id="Lms.Admin.DebugTools.template">
|
||||||
|
<form>
|
||||||
|
<legend>${tr:Lms.Admin.DebugTools.Tracing.tracing}</legend>
|
||||||
|
${tracing}
|
||||||
|
<hr/>
|
||||||
|
<legend>${tr:Lms.Admin.DebugTools.Db.db}</legend>
|
||||||
|
${db}
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</message>
|
||||||
|
|
||||||
|
</messages>
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<messages xmlns:if="Wt.WTemplate.conditions">
|
<messages xmlns:if="Wt.WTemplate.conditions">
|
||||||
|
|
||||||
<message id="Lms.Admin.Tracing.template">
|
<message id="Lms.Admin.DebugTools.Tracing.template">
|
||||||
<form>
|
<form>
|
||||||
<legend>${tr:Lms.Admin.Tracing.tracing}</legend>
|
|
||||||
<div class="row g-3">
|
<div class="row g-3">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
${export-btn class="btn btn-primary"}
|
${export-btn class="btn btn-primary"}
|
||||||
|
|||||||
+4
-1
@@ -44,7 +44,10 @@
|
|||||||
<li>${scan-settings class="dropdown-item"}</li>
|
<li>${scan-settings class="dropdown-item"}</li>
|
||||||
<li>${scanner class="dropdown-item"}</li>
|
<li>${scanner class="dropdown-item"}</li>
|
||||||
<li>${users class="dropdown-item"}</li>
|
<li>${users class="dropdown-item"}</li>
|
||||||
<li>${tracing class="dropdown-item"}</li>
|
${<if-debug-tools>}
|
||||||
|
<li class="dropdown-divider"></li>
|
||||||
|
<li>${debug-tools class="dropdown-item"}</li>
|
||||||
|
${</if-debug-tools>}
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
${</if-is-admin>}
|
${</if-is-admin>}
|
||||||
|
|||||||
+10
-3
@@ -52,10 +52,10 @@
|
|||||||
<message id="Lms.Error.user-not-found">User not found</message>
|
<message id="Lms.Error.user-not-found">User not found</message>
|
||||||
|
|
||||||
<!--Administration-->
|
<!--Administration-->
|
||||||
|
<message id="Lms.Admin.menu-debug-tools"><i class="fa fa-fw fa-bug" aria-hidden="true"></i> Debug tools</message>
|
||||||
<message id="Lms.Admin.menu-media-libraries"><i class="fa fa-fw fa-database" aria-hidden="true"></i> Libraries</message>
|
<message id="Lms.Admin.menu-media-libraries"><i class="fa fa-fw fa-database" aria-hidden="true"></i> Libraries</message>
|
||||||
<message id="Lms.Admin.menu-scan-settings"><i class="fa fa-fw fa-cogs" aria-hidden="true"></i> Scan settings</message>
|
<message id="Lms.Admin.menu-scan-settings"><i class="fa fa-fw fa-cogs" aria-hidden="true"></i> Scan settings</message>
|
||||||
<message id="Lms.Admin.menu-scanner"><i class="fa fa-fw fa-wrench" aria-hidden="true"></i> Scanner</message>
|
<message id="Lms.Admin.menu-scanner"><i class="fa fa-fw fa-wrench" aria-hidden="true"></i> Scanner</message>
|
||||||
<message id="Lms.Admin.menu-tracing"><i class="fa fa-fw fa-bar-chart" aria-hidden="true"></i> Tracing</message>
|
|
||||||
<message id="Lms.Admin.menu-users"><i class="fa fa-fw fa-users" aria-hidden="true"></i> Users</message>
|
<message id="Lms.Admin.menu-users"><i class="fa fa-fw fa-users" aria-hidden="true"></i> Users</message>
|
||||||
|
|
||||||
<!--MediaLibraries-->
|
<!--MediaLibraries-->
|
||||||
@@ -149,9 +149,16 @@
|
|||||||
<message id="Lms.Admin.ScannerController.step-status">Step status</message>
|
<message id="Lms.Admin.ScannerController.step-status">Step status</message>
|
||||||
<message id="Lms.Admin.ScannerController.step-updating-library-fields">Updating library fields: {1} entries</message>
|
<message id="Lms.Admin.ScannerController.step-updating-library-fields">Updating library fields: {1} entries</message>
|
||||||
|
|
||||||
|
<!--Debug Tools-->
|
||||||
|
<message id="Lms.Admin.DebugTools.debug-tools">Debug tools</message>
|
||||||
|
|
||||||
|
<!--Db-->
|
||||||
|
<message id="Lms.Admin.DebugTools.Db.export-query-plans">Export query plans</message>
|
||||||
|
<message id="Lms.Admin.DebugTools.Db.db">Database</message>
|
||||||
|
|
||||||
<!--Tracing-->
|
<!--Tracing-->
|
||||||
<message id="Lms.Admin.Tracing.export-current-buffer">Export traces</message>
|
<message id="Lms.Admin.DebugTools.Tracing.export-current-buffer">Export traces</message>
|
||||||
<message id="Lms.Admin.Tracing.tracing">Tracing</message>
|
<message id="Lms.Admin.DebugTools.Tracing.tracing">Tracing</message>
|
||||||
|
|
||||||
<!--Users-->
|
<!--Users-->
|
||||||
<message id="Lms.Admin.Users.add">New user</message>
|
<message id="Lms.Admin.Users.add">New user</message>
|
||||||
|
|||||||
+10
-3
@@ -52,10 +52,10 @@
|
|||||||
<message id="Lms.Error.user-not-found">No existe el usuario</message>
|
<message id="Lms.Error.user-not-found">No existe el usuario</message>
|
||||||
|
|
||||||
<!--Administration-->
|
<!--Administration-->
|
||||||
|
<message id="Lms.Admin.menu-debug-tools"><i class="fa fa-fw fa-bug" aria-hidden="true"></i> Herramientas de depuración</message>
|
||||||
<message id="Lms.Admin.menu-media-libraries"><i class="fa fa-fw fa-database" aria-hidden="true"></i> Bibliotecas</message>
|
<message id="Lms.Admin.menu-media-libraries"><i class="fa fa-fw fa-database" aria-hidden="true"></i> Bibliotecas</message>
|
||||||
<message id="Lms.Admin.menu-scan-settings"><i class="fa fa-fw fa-cogs" aria-hidden="true"></i> Opciones de escaneo</message>
|
<message id="Lms.Admin.menu-scan-settings"><i class="fa fa-fw fa-cogs" aria-hidden="true"></i> Opciones de escaneo</message>
|
||||||
<message id="Lms.Admin.menu-scanner"><i class="fa fa-fw fa-wrench" aria-hidden="true"></i> Escanear</message>
|
<message id="Lms.Admin.menu-scanner"><i class="fa fa-fw fa-wrench" aria-hidden="true"></i> Escanear</message>
|
||||||
<message id="Lms.Admin.menu-tracing"><i class="fa fa-fw fa-bar-chart" aria-hidden="true"></i> Traces</message>
|
|
||||||
<message id="Lms.Admin.menu-users"><i class="fa fa-fw fa-users" aria-hidden="true"></i> Usuarios</message>
|
<message id="Lms.Admin.menu-users"><i class="fa fa-fw fa-users" aria-hidden="true"></i> Usuarios</message>
|
||||||
|
|
||||||
<!--MediaLibraries-->
|
<!--MediaLibraries-->
|
||||||
@@ -148,9 +148,16 @@
|
|||||||
<message id="Lms.Admin.ScannerController.step-status">Estado de las etapas</message>
|
<message id="Lms.Admin.ScannerController.step-status">Estado de las etapas</message>
|
||||||
<message id="Lms.Admin.ScannerController.step-updating-library-fields">Actualizando campos de la biblioteca: {1} entradas</message>
|
<message id="Lms.Admin.ScannerController.step-updating-library-fields">Actualizando campos de la biblioteca: {1} entradas</message>
|
||||||
|
|
||||||
|
<!--Debug Tools-->
|
||||||
|
<message id="Lms.Admin.DebugTools.debug-tools">Herramientas de depuración</message>
|
||||||
|
|
||||||
|
<!--Db-->
|
||||||
|
<message id="Lms.Admin.DebugTools.Db.export-query-plans">Exportar planes de consulta</message>
|
||||||
|
<message id="Lms.Admin.DebugTools.Db.db">Base de datos</message>
|
||||||
|
|
||||||
<!--Tracing-->
|
<!--Tracing-->
|
||||||
<message id="Lms.Admin.Tracing.export-current-buffer">Exportar las trazas</message>
|
<message id="Lms.Admin.DebugTools.Tracing.export-current-buffer">Exportar las trazas</message>
|
||||||
<message id="Lms.Admin.Tracing.tracing">Trazas</message>
|
<message id="Lms.Admin.DebugTools.Tracing.tracing">Trazas</message>
|
||||||
|
|
||||||
<!--Users-->
|
<!--Users-->
|
||||||
<message id="Lms.Admin.Users.add">Añadir</message>
|
<message id="Lms.Admin.Users.add">Añadir</message>
|
||||||
|
|||||||
+10
-3
@@ -52,10 +52,10 @@
|
|||||||
<message id="Lms.Error.user-not-found">L'utilisateur n'existe pas</message>
|
<message id="Lms.Error.user-not-found">L'utilisateur n'existe pas</message>
|
||||||
|
|
||||||
<!--Administration-->
|
<!--Administration-->
|
||||||
|
<message id="Lms.Admin.menu-debug-tools"><i class="fa fa-fw fa-bug" aria-hidden="true"></i> Outils de débogage</message>
|
||||||
<message id="Lms.Admin.menu-media-libraries"><i class="fa fa-fw fa-database" aria-hidden="true"></i> Bibliothèques</message>
|
<message id="Lms.Admin.menu-media-libraries"><i class="fa fa-fw fa-database" aria-hidden="true"></i> Bibliothèques</message>
|
||||||
<message id="Lms.Admin.menu-scan-settings"><i class="fa fa-fw fa-cogs" aria-hidden="true"></i> Paramètres du scan</message>
|
<message id="Lms.Admin.menu-scan-settings"><i class="fa fa-fw fa-cogs" aria-hidden="true"></i> Paramètres du scan</message>
|
||||||
<message id="Lms.Admin.menu-scanner"><i class="fa fa-fw fa-wrench" aria-hidden="true"></i> Scanner</message>
|
<message id="Lms.Admin.menu-scanner"><i class="fa fa-fw fa-wrench" aria-hidden="true"></i> Scanner</message>
|
||||||
<message id="Lms.Admin.menu-tracing"><i class="fa fa-fw fa-bar-chart" aria-hidden="true"></i> Traces</message>
|
|
||||||
<message id="Lms.Admin.menu-users"><i class="fa fa-fw fa-users" aria-hidden="true"></i> Utilisateurs</message>
|
<message id="Lms.Admin.menu-users"><i class="fa fa-fw fa-users" aria-hidden="true"></i> Utilisateurs</message>
|
||||||
|
|
||||||
<!--MediaLibraries-->
|
<!--MediaLibraries-->
|
||||||
@@ -148,9 +148,16 @@
|
|||||||
<message id="Lms.Admin.ScannerController.step-status">Statut de l'étape</message>
|
<message id="Lms.Admin.ScannerController.step-status">Statut de l'étape</message>
|
||||||
<message id="Lms.Admin.ScannerController.step-updating-library-fields">Mise à jour des champs des bibliothèques: {1} entrées</message>
|
<message id="Lms.Admin.ScannerController.step-updating-library-fields">Mise à jour des champs des bibliothèques: {1} entrées</message>
|
||||||
|
|
||||||
|
<!--Debug Tools-->
|
||||||
|
<message id="Lms.Admin.DebugTools.debug-tools">Outils de débogage</message>
|
||||||
|
|
||||||
|
<!--Db-->
|
||||||
|
<message id="Lms.Admin.DebugTools.Db.export-query-plans">Exporter les plans de requête</message>
|
||||||
|
<message id="Lms.Admin.DebugTools.Db.db">Base de données</message>
|
||||||
|
|
||||||
<!--Tracing-->
|
<!--Tracing-->
|
||||||
<message id="Lms.Admin.Tracing.export-current-buffer">Exporter les traces</message>
|
<message id="Lms.Admin.DebugTools.Tracing.export-current-buffer">Exporter les traces</message>
|
||||||
<message id="Lms.Admin.Tracing.tracing">Traces</message>
|
<message id="Lms.Admin.DebugTools.Tracing.tracing">Traces</message>
|
||||||
|
|
||||||
<!--Users-->
|
<!--Users-->
|
||||||
<message id="Lms.Admin.Users.add">Ajouter</message>
|
<message id="Lms.Admin.Users.add">Ajouter</message>
|
||||||
|
|||||||
+10
-3
@@ -52,10 +52,10 @@
|
|||||||
<message id="Lms.Error.user-not-found">Utente non trovato</message>
|
<message id="Lms.Error.user-not-found">Utente non trovato</message>
|
||||||
|
|
||||||
<!--Administration-->
|
<!--Administration-->
|
||||||
|
<message id="Lms.Admin.menu-debug-tools"><i class="fa fa-fw fa-bug" aria-hidden="true"></i> Strumenti di debug</message>
|
||||||
<message id="Lms.Admin.menu-media-libraries"><i class="fa fa-fw fa-database" aria-hidden="true"></i> Librerie</message>
|
<message id="Lms.Admin.menu-media-libraries"><i class="fa fa-fw fa-database" aria-hidden="true"></i> Librerie</message>
|
||||||
<message id="Lms.Admin.menu-scan-settings"><i class="fa fa-fw fa-cogs" aria-hidden="true"></i> Impostazioni di scansione</message>
|
<message id="Lms.Admin.menu-scan-settings"><i class="fa fa-fw fa-cogs" aria-hidden="true"></i> Impostazioni di scansione</message>
|
||||||
<message id="Lms.Admin.menu-scanner"><i class="fa fa-fw fa-wrench" aria-hidden="true"></i> Scanner</message>
|
<message id="Lms.Admin.menu-scanner"><i class="fa fa-fw fa-wrench" aria-hidden="true"></i> Scanner</message>
|
||||||
<message id="Lms.Admin.menu-tracing"><i class="fa fa-fw fa-bar-chart" aria-hidden="true"></i> Tracing</message>
|
|
||||||
<message id="Lms.Admin.menu-users"><i class="fa fa-fw fa-users" aria-hidden="true"></i> Utenti</message>
|
<message id="Lms.Admin.menu-users"><i class="fa fa-fw fa-users" aria-hidden="true"></i> Utenti</message>
|
||||||
|
|
||||||
<!--MediaLibraries-->
|
<!--MediaLibraries-->
|
||||||
@@ -148,9 +148,16 @@
|
|||||||
<message id="Lms.Admin.ScannerController.step-status">Stato passo</message>
|
<message id="Lms.Admin.ScannerController.step-status">Stato passo</message>
|
||||||
<message id="Lms.Admin.ScannerController.step-updating-library-fields">Aggiornamento dei campi della libreria: {1} voci</message>
|
<message id="Lms.Admin.ScannerController.step-updating-library-fields">Aggiornamento dei campi della libreria: {1} voci</message>
|
||||||
|
|
||||||
|
<!--Debug Tools-->
|
||||||
|
<message id="Lms.Admin.DebugTools.debug-tools">Strumenti di debug</message>
|
||||||
|
|
||||||
|
<!--Db-->
|
||||||
|
<message id="Lms.Admin.DebugTools.Db.export-query-plans">Esporta i piani di query</message>
|
||||||
|
<message id="Lms.Admin.DebugTools.Db.db">Database</message>
|
||||||
|
|
||||||
<!--Tracing-->
|
<!--Tracing-->
|
||||||
<message id="Lms.Admin.Tracing.export-current-buffer">Esporta tracce</message>
|
<message id="Lms.Admin.DebugTools.Tracing.export-current-buffer">Esporta tracce</message>
|
||||||
<message id="Lms.Admin.Tracing.tracing">Tracing</message>
|
<message id="Lms.Admin.DebugTools.Tracing.tracing">Tracing</message>
|
||||||
|
|
||||||
<!--Users-->
|
<!--Users-->
|
||||||
<message id="Lms.Admin.Users.add">Nuovo utente</message>
|
<message id="Lms.Admin.Users.add">Nuovo utente</message>
|
||||||
|
|||||||
+10
-3
@@ -53,10 +53,10 @@
|
|||||||
<message id="Lms.Error.user-not-found">Użytkownik nie odnaleziony</message>
|
<message id="Lms.Error.user-not-found">Użytkownik nie odnaleziony</message>
|
||||||
|
|
||||||
<!--Administration-->
|
<!--Administration-->
|
||||||
|
<message id="Lms.Admin.menu-debug-tools"><i class="fa fa-fw fa-bug" aria-hidden="true"></i> Narzędzia debugowania</message>
|
||||||
<message id="Lms.Admin.menu-media-libraries"><i class="fa fa-fw fa-database" aria-hidden="true"></i> Biblioteki</message>
|
<message id="Lms.Admin.menu-media-libraries"><i class="fa fa-fw fa-database" aria-hidden="true"></i> Biblioteki</message>
|
||||||
<message id="Lms.Admin.menu-scan-settings"><i class="fa fa-fw fa-cogs" aria-hidden="true"></i> Ustawienia skanowania</message>
|
<message id="Lms.Admin.menu-scan-settings"><i class="fa fa-fw fa-cogs" aria-hidden="true"></i> Ustawienia skanowania</message>
|
||||||
<message id="Lms.Admin.menu-scanner"><i class="fa fa-fw fa-wrench" aria-hidden="true"></i> Skaner</message>
|
<message id="Lms.Admin.menu-scanner"><i class="fa fa-fw fa-wrench" aria-hidden="true"></i> Skaner</message>
|
||||||
<message id="Lms.Admin.menu-tracing"><i class="fa fa-fw fa-bar-chart" aria-hidden="true"></i> Śledzenie</message>
|
|
||||||
<message id="Lms.Admin.menu-users"><i class="fa fa-fw fa-users" aria-hidden="true"></i> Użytkownicy</message>
|
<message id="Lms.Admin.menu-users"><i class="fa fa-fw fa-users" aria-hidden="true"></i> Użytkownicy</message>
|
||||||
|
|
||||||
<!--MediaLibraries-->
|
<!--MediaLibraries-->
|
||||||
@@ -165,9 +165,16 @@
|
|||||||
<message id="Lms.Admin.ScannerController.step-status">Obecny krok</message>
|
<message id="Lms.Admin.ScannerController.step-status">Obecny krok</message>
|
||||||
<message id="Lms.Admin.ScannerController.step-updating-library-fields">Aktualizowanie pól biblioteki: {1} wpisów</message>
|
<message id="Lms.Admin.ScannerController.step-updating-library-fields">Aktualizowanie pól biblioteki: {1} wpisów</message>
|
||||||
|
|
||||||
|
<!--Debug Tools-->
|
||||||
|
<message id="Lms.Admin.DebugTools.debug-tools">Narzędzia debugowania</message>
|
||||||
|
|
||||||
|
<!--Db-->
|
||||||
|
<message id="Lms.Admin.DebugTools.Db.export-query-plans">Eksportuj plany zapytań</message>
|
||||||
|
<message id="Lms.Admin.DebugTools.Db.db">Baza danych</message>
|
||||||
|
|
||||||
<!--Tracing-->
|
<!--Tracing-->
|
||||||
<message id="Lms.Admin.Tracing.export-current-buffer">Eksportuj ślady</message>
|
<message id="Lms.Admin.DebugTools.Tracing.export-current-buffer">Eksportuj ślady</message>
|
||||||
<message id="Lms.Admin.Tracing.tracing">Śledzenie</message>
|
<message id="Lms.Admin.DebugTools.Tracing.tracing">Śledzenie</message>
|
||||||
|
|
||||||
<!--Users-->
|
<!--Users-->
|
||||||
<message id="Lms.Admin.Users.add">Nowy użytkownik</message>
|
<message id="Lms.Admin.Users.add">Nowy użytkownik</message>
|
||||||
|
|||||||
@@ -145,6 +145,12 @@
|
|||||||
|
|
||||||
<message id="Lms.Admin.ScannerController.step-status">当前步骤状态</message>
|
<message id="Lms.Admin.ScannerController.step-status">当前步骤状态</message>
|
||||||
|
|
||||||
|
<!--Debug Tools-->
|
||||||
|
|
||||||
|
|
||||||
|
<!--Db-->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!--Tracing-->
|
<!--Tracing-->
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,11 @@ log-min-severity = "info";
|
|||||||
# Can be "none", "quick", or "full"
|
# Can be "none", "quick", or "full"
|
||||||
db-integrity-check = "quick";
|
db-integrity-check = "quick";
|
||||||
# Output db queries on stdout
|
# Output db queries on stdout
|
||||||
|
# Use this only for debugging purpose, as this may impact performance
|
||||||
db-show-queries = false;
|
db-show-queries = false;
|
||||||
|
# Record query plans for database queries.
|
||||||
|
# Use this only for debugging purposes, as this may impact performance
|
||||||
|
db-record-query-plans = false;
|
||||||
|
|
||||||
# Listen port/addr of the web server
|
# Listen port/addr of the web server
|
||||||
listen-port = 5082;
|
listen-port = 5082;
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ extern "C"
|
|||||||
}
|
}
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <map>
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
#include "core/ILogger.hpp"
|
#include "core/ILogger.hpp"
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ add_library(lmsdatabase STATIC
|
|||||||
impl/IdType.cpp
|
impl/IdType.cpp
|
||||||
impl/Migration.cpp
|
impl/Migration.cpp
|
||||||
impl/Object.cpp
|
impl/Object.cpp
|
||||||
|
impl/QueryPlanRecorder.cpp
|
||||||
impl/Session.cpp
|
impl/Session.cpp
|
||||||
impl/SqlQuery.cpp
|
impl/SqlQuery.cpp
|
||||||
impl/Transaction.cpp
|
impl/Transaction.cpp
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ namespace lms::db
|
|||||||
LMS_LOG(DB, INFO, "Performing quick database check...");
|
LMS_LOG(DB, INFO, "Performing quick database check...");
|
||||||
|
|
||||||
// Quick check is just a simple integrity check
|
// Quick check is just a simple integrity check
|
||||||
bool quickCheckPassed{ checkDbIntegrity(*connection, IntegrityCheckType::Quick, [&](std::string_view error) {
|
const bool quickCheckPassed{ checkDbIntegrity(*connection, IntegrityCheckType::Quick, [&](std::string_view error) {
|
||||||
LMS_LOG(DB, ERROR, "Quick check error: " << error);
|
LMS_LOG(DB, ERROR, "Quick check error: " << error);
|
||||||
}) };
|
}) };
|
||||||
|
|
||||||
@@ -222,7 +222,7 @@ namespace lms::db
|
|||||||
|
|
||||||
LMS_LOG(DB, INFO, "Checking database integrity...");
|
LMS_LOG(DB, INFO, "Checking database integrity...");
|
||||||
|
|
||||||
bool integrityCheckPassed{ checkDbIntegrity(*connection, IntegrityCheckType::Full, [&](std::string_view error) {
|
const bool integrityCheckPassed{ checkDbIntegrity(*connection, IntegrityCheckType::Full, [&](std::string_view error) {
|
||||||
LMS_LOG(DB, ERROR, "Integrity check error: " << error);
|
LMS_LOG(DB, ERROR, "Integrity check error: " << error);
|
||||||
}) };
|
}) };
|
||||||
|
|
||||||
@@ -238,7 +238,7 @@ namespace lms::db
|
|||||||
|
|
||||||
LMS_LOG(DB, INFO, "Checking foreign key constraints...");
|
LMS_LOG(DB, INFO, "Checking foreign key constraints...");
|
||||||
|
|
||||||
bool foreignKeyConstraintsPassed{ checkDbForeignKeyConstraints(*connection, [&](std::string_view table, long long rowId, std::string_view referredTable) {
|
const bool foreignKeyConstraintsPassed{ checkDbForeignKeyConstraints(*connection, [&](std::string_view table, long long rowId, std::string_view referredTable) {
|
||||||
LMS_LOG(DB, ERROR, "Foreign key constraint failed in table '" << table << "', rowid = " << rowId << ", referred table = '" << referredTable << "'");
|
LMS_LOG(DB, ERROR, "Foreign key constraint failed in table '" << table << "', rowid = " << rowId << ", referred table = '" << referredTable << "'");
|
||||||
}) };
|
}) };
|
||||||
|
|
||||||
|
|||||||
@@ -36,8 +36,6 @@ namespace lms::db
|
|||||||
public:
|
public:
|
||||||
Db(const std::filesystem::path& dbPath, std::size_t connectionCount);
|
Db(const std::filesystem::path& dbPath, std::size_t connectionCount);
|
||||||
|
|
||||||
Session& getTLSSession() override;
|
|
||||||
|
|
||||||
void executeSql(const std::string& sql);
|
void executeSql(const std::string& sql);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -46,6 +44,8 @@ namespace lms::db
|
|||||||
|
|
||||||
friend class Session;
|
friend class Session;
|
||||||
|
|
||||||
|
Session& getTLSSession() override;
|
||||||
|
|
||||||
core::RecursiveSharedMutex& getMutex() { return _sharedMutex; }
|
core::RecursiveSharedMutex& getMutex() { return _sharedMutex; }
|
||||||
Wt::Dbo::SqlConnectionPool& getConnectionPool() { return *_connectionPool; }
|
Wt::Dbo::SqlConnectionPool& getConnectionPool() { return *_connectionPool; }
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,112 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2025 Emeric Poupon
|
||||||
|
*
|
||||||
|
* This file is part of LMS.
|
||||||
|
*
|
||||||
|
* LMS is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* LMS is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "QueryPlanRecorder.hpp"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
|
#include <Wt/Dbo/SqlStatement.h>
|
||||||
|
#include <Wt/Dbo/Transaction.h>
|
||||||
|
|
||||||
|
#include "core/ILogger.hpp"
|
||||||
|
|
||||||
|
namespace lms::db
|
||||||
|
{
|
||||||
|
std::unique_ptr<IQueryPlanRecorder> createQueryPlanRecorder()
|
||||||
|
{
|
||||||
|
return std::make_unique<QueryPlanRecorder>();
|
||||||
|
}
|
||||||
|
|
||||||
|
QueryPlanRecorder::QueryPlanRecorder()
|
||||||
|
{
|
||||||
|
LMS_LOG(DB, INFO, "Recording database query plans");
|
||||||
|
}
|
||||||
|
|
||||||
|
QueryPlanRecorder::~QueryPlanRecorder() = default;
|
||||||
|
|
||||||
|
void QueryPlanRecorder::visitQueryPlans(const QueryPlanVisitor& visitor) const
|
||||||
|
{
|
||||||
|
const std::shared_lock lock{ _mutex };
|
||||||
|
|
||||||
|
for (const auto& [query, plan] : _queryPlans)
|
||||||
|
visitor(query, plan);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QueryPlanRecorder::recordQueryPlanIfNeeded(Wt::Dbo::Session& session, const std::string& query)
|
||||||
|
{
|
||||||
|
{
|
||||||
|
const std::shared_lock lock{ _mutex };
|
||||||
|
|
||||||
|
if (_queryPlans.contains(query))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Wt::Dbo::Transaction transaction{ session };
|
||||||
|
|
||||||
|
Wt::Dbo::SqlConnection* connection{ transaction.connection() };
|
||||||
|
auto statement{ connection->prepareStatement("EXPLAIN QUERY PLAN " + query) };
|
||||||
|
statement->execute();
|
||||||
|
|
||||||
|
std::map<int, std::string> entries{ { 0, "" } };
|
||||||
|
std::map<int, std::vector<int>> relationships;
|
||||||
|
|
||||||
|
std::string detail;
|
||||||
|
while (statement->nextRow())
|
||||||
|
{
|
||||||
|
detail.clear();
|
||||||
|
|
||||||
|
int id{};
|
||||||
|
int parent{};
|
||||||
|
int unused{};
|
||||||
|
|
||||||
|
if (statement->getResult(0, &id)
|
||||||
|
&& statement->getResult(1, &parent)
|
||||||
|
&& statement->getResult(2, &unused)
|
||||||
|
&& statement->getResult(3, &detail, static_cast<int>(detail.capacity())))
|
||||||
|
{
|
||||||
|
entries.emplace(id, detail);
|
||||||
|
relationships[parent].push_back(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// format
|
||||||
|
std::string result;
|
||||||
|
std::function<void(int, unsigned)> formatQuery = [&](int id, unsigned level) -> void {
|
||||||
|
for (std::size_t i{}; i < level; ++i)
|
||||||
|
result += '\t';
|
||||||
|
|
||||||
|
result += entries.at(id);
|
||||||
|
result += '\n';
|
||||||
|
auto itChildren = relationships.find(id);
|
||||||
|
if (itChildren == relationships.end())
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (int child : itChildren->second)
|
||||||
|
formatQuery(child, level + 1);
|
||||||
|
};
|
||||||
|
|
||||||
|
formatQuery(0, 0);
|
||||||
|
|
||||||
|
{
|
||||||
|
const std::unique_lock lock{ _mutex };
|
||||||
|
_queryPlans.try_emplace(query, std::move(result));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // namespace lms::db
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2025 Emeric Poupon
|
||||||
|
*
|
||||||
|
* This file is part of LMS.
|
||||||
|
*
|
||||||
|
* LMS is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* LMS is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <shared_mutex>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include <Wt/Dbo/Session.h>
|
||||||
|
|
||||||
|
#include "database/IQueryPlanRecorder.hpp"
|
||||||
|
|
||||||
|
namespace lms::db
|
||||||
|
{
|
||||||
|
class QueryPlanRecorder : public IQueryPlanRecorder
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QueryPlanRecorder();
|
||||||
|
~QueryPlanRecorder() override;
|
||||||
|
QueryPlanRecorder(const QueryPlanRecorder&) = delete;
|
||||||
|
QueryPlanRecorder& operator=(const QueryPlanRecorder&) = delete;
|
||||||
|
|
||||||
|
void visitQueryPlans(const QueryPlanVisitor& visitor) const override;
|
||||||
|
|
||||||
|
void recordQueryPlanIfNeeded(Wt::Dbo::Session& session, const std::string& query);
|
||||||
|
|
||||||
|
private:
|
||||||
|
mutable std::shared_mutex _mutex;
|
||||||
|
std::map<std::string, std::string> _queryPlans;
|
||||||
|
};
|
||||||
|
} // namespace lms::db
|
||||||
@@ -19,22 +19,39 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <functional>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
#include <Wt/Dbo/Dbo.h>
|
#include <Wt/Dbo/Call.h>
|
||||||
|
#include <Wt/Dbo/Query.h>
|
||||||
|
#include <Wt/Dbo/Session.h>
|
||||||
|
#include <Wt/Dbo/collection.h>
|
||||||
#include <Wt/WDateTime.h>
|
#include <Wt/WDateTime.h>
|
||||||
|
|
||||||
#include "core/ITraceLogger.hpp"
|
#include "core/ITraceLogger.hpp"
|
||||||
|
#include "core/Service.hpp"
|
||||||
#include "database/Types.hpp"
|
#include "database/Types.hpp"
|
||||||
|
|
||||||
|
#include "QueryPlanRecorder.hpp"
|
||||||
|
|
||||||
namespace lms::db::utils
|
namespace lms::db::utils
|
||||||
{
|
{
|
||||||
#define ESCAPE_CHAR_STR "\\"
|
#define ESCAPE_CHAR_STR "\\"
|
||||||
static inline constexpr char escapeChar{ '\\' };
|
static inline constexpr char escapeChar{ '\\' };
|
||||||
std::string escapeLikeKeyword(std::string_view keywords);
|
std::string escapeLikeKeyword(std::string_view keywords);
|
||||||
|
|
||||||
|
Wt::WDateTime normalizeDateTime(const Wt::WDateTime& dateTime);
|
||||||
|
|
||||||
|
namespace details
|
||||||
|
{
|
||||||
|
template<typename Query>
|
||||||
|
void recordQueryPlanIfNeeded(const Query& query)
|
||||||
|
{
|
||||||
|
if (IQueryPlanRecorder * recorder{ core::Service<IQueryPlanRecorder>::get() })
|
||||||
|
static_cast<QueryPlanRecorder*>(recorder)->recordQueryPlanIfNeeded(query.session(), query.asString());
|
||||||
|
}
|
||||||
|
} // namespace details
|
||||||
|
|
||||||
template<typename Query>
|
template<typename Query>
|
||||||
void applyRange(Query& query, std::optional<Range> range)
|
void applyRange(Query& query, std::optional<Range> range)
|
||||||
{
|
{
|
||||||
@@ -82,13 +99,18 @@ namespace lms::db::utils
|
|||||||
template<typename Query, typename UnaryFunc>
|
template<typename Query, typename UnaryFunc>
|
||||||
void forEachQueryResult(const Query& query, UnaryFunc&& func)
|
void forEachQueryResult(const Query& query, UnaryFunc&& func)
|
||||||
{
|
{
|
||||||
|
details::recordQueryPlanIfNeeded(query);
|
||||||
|
|
||||||
LMS_SCOPED_TRACE_DETAILED_WITH_ARG("Database", "ForEachQueryResult", "Query", query.asString());
|
LMS_SCOPED_TRACE_DETAILED_WITH_ARG("Database", "ForEachQueryResult", "Query", query.asString());
|
||||||
|
|
||||||
forEachResult(query.resultList(), std::forward<UnaryFunc>(func));
|
forEachResult(query.resultList(), std::forward<UnaryFunc>(func));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename Query>
|
template<typename T, typename Query>
|
||||||
std::vector<T> fetchQueryResults(const Query& query)
|
std::vector<T> fetchQueryResults(const Query& query)
|
||||||
{
|
{
|
||||||
|
details::recordQueryPlanIfNeeded(query);
|
||||||
|
|
||||||
LMS_SCOPED_TRACE_DETAILED_WITH_ARG("Database", "FetchQueryResults", "Query", query.asString());
|
LMS_SCOPED_TRACE_DETAILED_WITH_ARG("Database", "FetchQueryResults", "Query", query.asString());
|
||||||
|
|
||||||
auto collection{ query.resultList() };
|
auto collection{ query.resultList() };
|
||||||
@@ -98,6 +120,8 @@ namespace lms::db::utils
|
|||||||
template<typename Query>
|
template<typename Query>
|
||||||
std::vector<typename QueryResultType<Query>::type> fetchQueryResults(const Query& query)
|
std::vector<typename QueryResultType<Query>::type> fetchQueryResults(const Query& query)
|
||||||
{
|
{
|
||||||
|
details::recordQueryPlanIfNeeded(query);
|
||||||
|
|
||||||
LMS_SCOPED_TRACE_DETAILED_WITH_ARG("Database", "FetchQueryResults", "Query", query.asString());
|
LMS_SCOPED_TRACE_DETAILED_WITH_ARG("Database", "FetchQueryResults", "Query", query.asString());
|
||||||
|
|
||||||
auto collection{ query.resultList() };
|
auto collection{ query.resultList() };
|
||||||
@@ -107,6 +131,8 @@ namespace lms::db::utils
|
|||||||
template<typename Query>
|
template<typename Query>
|
||||||
auto fetchQuerySingleResult(const Query& query)
|
auto fetchQuerySingleResult(const Query& query)
|
||||||
{
|
{
|
||||||
|
details::recordQueryPlanIfNeeded(query);
|
||||||
|
|
||||||
LMS_SCOPED_TRACE_DETAILED_WITH_ARG("Database", "FetchQuerySingleResult", "Query", query.asString());
|
LMS_SCOPED_TRACE_DETAILED_WITH_ARG("Database", "FetchQuerySingleResult", "Query", query.asString());
|
||||||
return query.resultValue();
|
return query.resultValue();
|
||||||
}
|
}
|
||||||
@@ -183,6 +209,4 @@ namespace lms::db::utils
|
|||||||
call.run();
|
call.run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Wt::WDateTime normalizeDateTime(const Wt::WDateTime& dateTime);
|
|
||||||
} // namespace lms::db::utils
|
} // namespace lms::db::utils
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "database/objects/Artwork.hpp"
|
#include "database/objects/Artwork.hpp"
|
||||||
|
|
||||||
#include <Wt/Dbo/WtSqlTraits.h>
|
#include <Wt/Dbo/WtSqlTraits.h>
|
||||||
|
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2025 Emeric Poupon
|
||||||
|
*
|
||||||
|
* This file is part of LMS.
|
||||||
|
*
|
||||||
|
* LMS is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* LMS is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
namespace lms::db
|
||||||
|
{
|
||||||
|
// Due to technical limitations, query plans are recorded globally across all databases.
|
||||||
|
// As a result, this class is implemented as a singleton rather than being owned per DB instance.
|
||||||
|
class IQueryPlanRecorder
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~IQueryPlanRecorder() = default;
|
||||||
|
|
||||||
|
using QueryPlanVisitor = std::function<void(std::string_view query, std::string_view plan)>;
|
||||||
|
virtual void visitQueryPlans(const QueryPlanVisitor& visitor) const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::unique_ptr<IQueryPlanRecorder> createQueryPlanRecorder();
|
||||||
|
} // namespace lms::db
|
||||||
@@ -14,10 +14,12 @@ add_executable(lms
|
|||||||
ui/State.cpp
|
ui/State.cpp
|
||||||
ui/Tooltip.cpp
|
ui/Tooltip.cpp
|
||||||
ui/Utils.cpp
|
ui/Utils.cpp
|
||||||
|
ui/admin/debug/Database.cpp
|
||||||
|
ui/admin/debug/Tracing.cpp
|
||||||
|
ui/admin/DebugToolsView.cpp
|
||||||
ui/admin/InitWizardView.cpp
|
ui/admin/InitWizardView.cpp
|
||||||
ui/admin/MediaLibrariesView.cpp
|
ui/admin/MediaLibrariesView.cpp
|
||||||
ui/admin/MediaLibraryModal.cpp
|
ui/admin/MediaLibraryModal.cpp
|
||||||
ui/admin/TracingView.cpp
|
|
||||||
ui/admin/ScannerController.cpp
|
ui/admin/ScannerController.cpp
|
||||||
ui/admin/ScannerReportResource.cpp
|
ui/admin/ScannerReportResource.cpp
|
||||||
ui/admin/ScanSettingsView.cpp
|
ui/admin/ScanSettingsView.cpp
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
#include "core/SystemPaths.hpp"
|
#include "core/SystemPaths.hpp"
|
||||||
#include "core/WtLogger.hpp"
|
#include "core/WtLogger.hpp"
|
||||||
#include "database/IDb.hpp"
|
#include "database/IDb.hpp"
|
||||||
|
#include "database/IQueryPlanRecorder.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
#include "image/Image.hpp"
|
#include "image/Image.hpp"
|
||||||
#include "services/artwork/IArtworkService.hpp"
|
#include "services/artwork/IArtworkService.hpp"
|
||||||
@@ -315,6 +316,10 @@ namespace lms
|
|||||||
|
|
||||||
core::IOContextRunner ioContextRunner{ ioContext, getThreadCount(), "Misc" };
|
core::IOContextRunner ioContextRunner{ ioContext, getThreadCount(), "Misc" };
|
||||||
|
|
||||||
|
core::Service<db::IQueryPlanRecorder> queryPlanRecorder;
|
||||||
|
if (config->getBool("db-record-query-plans", false))
|
||||||
|
queryPlanRecorder.assign(db::createQueryPlanRecorder());
|
||||||
|
|
||||||
// Connection pool size must be twice the number of threads: we have at least 2 io pools with getThreadCount() each and they all may access the database
|
// Connection pool size must be twice the number of threads: we have at least 2 io pools with getThreadCount() each and they all may access the database
|
||||||
auto database{ db::createDb(config->getPath("working-dir", "/var/lms") / "lms.db", getThreadCount() * 2) };
|
auto database{ db::createDb(config->getPath("working-dir", "/var/lms") / "lms.db", getThreadCount() * 2) };
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
#include "core/ITraceLogger.hpp"
|
#include "core/ITraceLogger.hpp"
|
||||||
#include "core/Service.hpp"
|
#include "core/Service.hpp"
|
||||||
#include "database/IDb.hpp"
|
#include "database/IDb.hpp"
|
||||||
|
#include "database/IQueryPlanRecorder.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
#include "database/objects/Artist.hpp"
|
#include "database/objects/Artist.hpp"
|
||||||
#include "database/objects/Cluster.hpp"
|
#include "database/objects/Cluster.hpp"
|
||||||
@@ -51,11 +52,11 @@
|
|||||||
#include "NotificationContainer.hpp"
|
#include "NotificationContainer.hpp"
|
||||||
#include "PlayQueue.hpp"
|
#include "PlayQueue.hpp"
|
||||||
#include "SettingsView.hpp"
|
#include "SettingsView.hpp"
|
||||||
|
#include "admin/DebugToolsView.hpp"
|
||||||
#include "admin/InitWizardView.hpp"
|
#include "admin/InitWizardView.hpp"
|
||||||
#include "admin/MediaLibrariesView.hpp"
|
#include "admin/MediaLibrariesView.hpp"
|
||||||
#include "admin/ScanSettingsView.hpp"
|
#include "admin/ScanSettingsView.hpp"
|
||||||
#include "admin/ScannerController.hpp"
|
#include "admin/ScannerController.hpp"
|
||||||
#include "admin/TracingView.hpp"
|
|
||||||
#include "admin/UserView.hpp"
|
#include "admin/UserView.hpp"
|
||||||
#include "admin/UsersView.hpp"
|
#include "admin/UsersView.hpp"
|
||||||
#include "common/Template.hpp"
|
#include "common/Template.hpp"
|
||||||
@@ -75,6 +76,8 @@ namespace lms::ui
|
|||||||
const std::string appRoot{ Wt::WApplication::appRoot() };
|
const std::string appRoot{ Wt::WApplication::appRoot() };
|
||||||
|
|
||||||
auto res{ std::make_shared<Wt::WMessageResourceBundle>() };
|
auto res{ std::make_shared<Wt::WMessageResourceBundle>() };
|
||||||
|
res->use(appRoot + "admin-db");
|
||||||
|
res->use(appRoot + "admin-debugtools");
|
||||||
res->use(appRoot + "admin-initwizard");
|
res->use(appRoot + "admin-initwizard");
|
||||||
res->use(appRoot + "admin-medialibraries");
|
res->use(appRoot + "admin-medialibraries");
|
||||||
res->use(appRoot + "admin-medialibrary");
|
res->use(appRoot + "admin-medialibrary");
|
||||||
@@ -132,7 +135,7 @@ namespace lms::ui
|
|||||||
IdxAdminScanner,
|
IdxAdminScanner,
|
||||||
IdxAdminUsers,
|
IdxAdminUsers,
|
||||||
IdxAdminUser,
|
IdxAdminUser,
|
||||||
IdxAdminTracing,
|
IdxAdminDebugTools,
|
||||||
};
|
};
|
||||||
|
|
||||||
void handlePathChange(Wt::WStackedWidget& stack, bool isAdmin)
|
void handlePathChange(Wt::WStackedWidget& stack, bool isAdmin)
|
||||||
@@ -158,7 +161,7 @@ namespace lms::ui
|
|||||||
{ "/admin/scanner", IdxAdminScanner, true, Wt::WString::tr("Lms.Admin.ScannerController.scanner") },
|
{ "/admin/scanner", IdxAdminScanner, true, Wt::WString::tr("Lms.Admin.ScannerController.scanner") },
|
||||||
{ "/admin/users", IdxAdminUsers, true, Wt::WString::tr("Lms.Admin.Users.users") },
|
{ "/admin/users", IdxAdminUsers, true, Wt::WString::tr("Lms.Admin.Users.users") },
|
||||||
{ "/admin/user", IdxAdminUser, true, std::nullopt },
|
{ "/admin/user", IdxAdminUser, true, std::nullopt },
|
||||||
{ "/admin/tracing", IdxAdminTracing, true, Wt::WString::tr("Lms.Admin.Tracing.tracing") },
|
{ "/admin/debug-tools", IdxAdminDebugTools, true, Wt::WString::tr("Lms.Admin.DebugTools.debug-tools") },
|
||||||
};
|
};
|
||||||
|
|
||||||
LMS_LOG(UI, DEBUG, "Internal path changed to '" << wApp->internalPath() << "'");
|
LMS_LOG(UI, DEBUG, "Internal path changed to '" << wApp->internalPath() << "'");
|
||||||
@@ -461,11 +464,13 @@ namespace lms::ui
|
|||||||
navbar->bindNew<Wt::WAnchor>("scan-settings", Wt::WLink{ Wt::LinkType::InternalPath, "/admin/scan-settings" }, Wt::WString::tr("Lms.Admin.menu-scan-settings"));
|
navbar->bindNew<Wt::WAnchor>("scan-settings", Wt::WLink{ Wt::LinkType::InternalPath, "/admin/scan-settings" }, Wt::WString::tr("Lms.Admin.menu-scan-settings"));
|
||||||
navbar->bindNew<Wt::WAnchor>("scanner", Wt::WLink{ Wt::LinkType::InternalPath, "/admin/scanner" }, Wt::WString::tr("Lms.Admin.menu-scanner"));
|
navbar->bindNew<Wt::WAnchor>("scanner", Wt::WLink{ Wt::LinkType::InternalPath, "/admin/scanner" }, Wt::WString::tr("Lms.Admin.menu-scanner"));
|
||||||
navbar->bindNew<Wt::WAnchor>("users", Wt::WLink{ Wt::LinkType::InternalPath, "/admin/users" }, Wt::WString::tr("Lms.Admin.menu-users"));
|
navbar->bindNew<Wt::WAnchor>("users", Wt::WLink{ Wt::LinkType::InternalPath, "/admin/users" }, Wt::WString::tr("Lms.Admin.menu-users"));
|
||||||
// Hide the entry if the trace logger is not enabled
|
// Hide the entry if no debug service is enabled
|
||||||
if (core::Service<core::tracing::ITraceLogger>::get())
|
if (core::Service<core::tracing::ITraceLogger>::get()
|
||||||
navbar->bindNew<Wt::WAnchor>("tracing", Wt::WLink{ Wt::LinkType::InternalPath, "/admin/tracing" }, Wt::WString::tr("Lms.Admin.menu-tracing"));
|
|| core::Service<db::IQueryPlanRecorder>::get())
|
||||||
else
|
{
|
||||||
navbar->bindEmpty("tracing");
|
navbar->setCondition("if-debug-tools", true);
|
||||||
|
navbar->bindNew<Wt::WAnchor>("debug-tools", Wt::WLink{ Wt::LinkType::InternalPath, "/admin/debug-tools" }, Wt::WString::tr("Lms.Admin.menu-debug-tools"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Contents
|
// Contents
|
||||||
@@ -486,7 +491,7 @@ namespace lms::ui
|
|||||||
mainStack->addNew<ScannerController>();
|
mainStack->addNew<ScannerController>();
|
||||||
mainStack->addNew<UsersView>();
|
mainStack->addNew<UsersView>();
|
||||||
mainStack->addNew<UserView>();
|
mainStack->addNew<UserView>();
|
||||||
mainStack->addNew<TracingView>();
|
mainStack->addNew<DebugToolsView>();
|
||||||
}
|
}
|
||||||
|
|
||||||
explore->getPlayQueueController().setMaxTrackCountToEnqueue(_playQueue->getCapacity());
|
explore->getPlayQueueController().setMaxTrackCountToEnqueue(_playQueue->getCapacity());
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2024 Emeric Poupon
|
||||||
|
*
|
||||||
|
* This file is part of LMS.
|
||||||
|
*
|
||||||
|
* LMS is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* LMS is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "DebugToolsView.hpp"
|
||||||
|
|
||||||
|
#include "admin/debug/Database.hpp"
|
||||||
|
#include "debug/Database.hpp"
|
||||||
|
#include "debug/Tracing.hpp"
|
||||||
|
|
||||||
|
namespace lms::ui
|
||||||
|
{
|
||||||
|
DebugToolsView::DebugToolsView()
|
||||||
|
: Wt::WTemplate{ Wt::WString::tr("Lms.Admin.DebugTools.template") }
|
||||||
|
{
|
||||||
|
addFunction("tr", &Wt::WTemplate::Functions::tr);
|
||||||
|
|
||||||
|
bindNew<Tracing>("tracing");
|
||||||
|
bindNew<Database>("db");
|
||||||
|
}
|
||||||
|
} // namespace lms::ui
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2024 Emeric Poupon
|
||||||
|
*
|
||||||
|
* This file is part of LMS.
|
||||||
|
*
|
||||||
|
* LMS is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* LMS is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Wt/WTemplate.h>
|
||||||
|
|
||||||
|
namespace lms::ui
|
||||||
|
{
|
||||||
|
class DebugToolsView : public Wt::WTemplate
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DebugToolsView();
|
||||||
|
};
|
||||||
|
} // namespace lms::ui
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2024 Emeric Poupon
|
||||||
|
*
|
||||||
|
* This file is part of LMS.
|
||||||
|
*
|
||||||
|
* LMS is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* LMS is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Database.hpp"
|
||||||
|
|
||||||
|
#include <Wt/Http/Response.h>
|
||||||
|
#include <Wt/Utils.h>
|
||||||
|
#include <Wt/WDateTime.h>
|
||||||
|
#include <Wt/WPushButton.h>
|
||||||
|
#include <Wt/WResource.h>
|
||||||
|
|
||||||
|
#include "core/ITraceLogger.hpp"
|
||||||
|
#include "core/String.hpp"
|
||||||
|
#include "database/IQueryPlanRecorder.hpp"
|
||||||
|
|
||||||
|
namespace lms::ui
|
||||||
|
{
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
class QueryPlansReportResource : public Wt::WResource
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QueryPlansReportResource(const db::IQueryPlanRecorder& recorder)
|
||||||
|
: _recorder{ recorder }
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
~QueryPlansReportResource()
|
||||||
|
{
|
||||||
|
beingDeleted();
|
||||||
|
}
|
||||||
|
QueryPlansReportResource(const QueryPlansReportResource&) = delete;
|
||||||
|
QueryPlansReportResource& operator=(const QueryPlansReportResource&) = delete;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void handleRequest(const Wt::Http::Request&, Wt::Http::Response& response)
|
||||||
|
{
|
||||||
|
response.setMimeType("application/text");
|
||||||
|
|
||||||
|
auto encodeHttpHeaderField = [](const std::string& fieldName, const std::string& fieldValue) {
|
||||||
|
// This implements RFC 5987
|
||||||
|
return fieldName + "*=UTF-8''" + Wt::Utils::urlEncode(fieldValue);
|
||||||
|
};
|
||||||
|
|
||||||
|
const std::string cdp{ encodeHttpHeaderField("filename", "LMS_db_query_plans_" + core::stringUtils::toISO8601String(Wt::WDateTime::currentDateTime()) + ".txt") };
|
||||||
|
response.addHeader("Content-Disposition", "attachment; " + cdp);
|
||||||
|
|
||||||
|
_recorder.visitQueryPlans([&](std::string_view query, std::string_view plan) {
|
||||||
|
response.out() << query << '\n';
|
||||||
|
response.out() << plan << "\n-------------------------\n";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const db::IQueryPlanRecorder& _recorder;
|
||||||
|
};
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
Database::Database()
|
||||||
|
: Wt::WTemplate{ Wt::WString::tr("Lms.Admin.DebugTools.Db.template") }
|
||||||
|
{
|
||||||
|
addFunction("tr", &Wt::WTemplate::Functions::tr);
|
||||||
|
|
||||||
|
Wt::WPushButton* dumpBtn{ bindNew<Wt::WPushButton>("export-query-plans-btn", Wt::WString::tr("Lms.Admin.DebugTools.Db.export-query-plans")) };
|
||||||
|
|
||||||
|
if (const auto* recorder{ core::Service<db::IQueryPlanRecorder>::get() })
|
||||||
|
{
|
||||||
|
Wt::WLink link{ std::make_shared<QueryPlansReportResource>(*recorder) };
|
||||||
|
link.setTarget(Wt::LinkTarget::NewWindow);
|
||||||
|
dumpBtn->setLink(link);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
dumpBtn->setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace lms::ui
|
||||||
@@ -23,9 +23,9 @@
|
|||||||
|
|
||||||
namespace lms::ui
|
namespace lms::ui
|
||||||
{
|
{
|
||||||
class TracingView : public Wt::WTemplate
|
class Database : public Wt::WTemplate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TracingView();
|
Database();
|
||||||
};
|
};
|
||||||
} // namespace lms::ui
|
} // namespace lms::ui
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "TracingView.hpp"
|
#include "Tracing.hpp"
|
||||||
|
|
||||||
#include <Wt/Http/Response.h>
|
#include <Wt/Http/Response.h>
|
||||||
#include <Wt/Utils.h>
|
#include <Wt/Utils.h>
|
||||||
@@ -73,12 +73,12 @@ namespace lms::ui
|
|||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
TracingView::TracingView()
|
Tracing::Tracing()
|
||||||
: Wt::WTemplate{ Wt::WString::tr("Lms.Admin.Tracing.template") }
|
: Wt::WTemplate{ Wt::WString::tr("Lms.Admin.DebugTools.Tracing.template") }
|
||||||
{
|
{
|
||||||
addFunction("tr", &Wt::WTemplate::Functions::tr);
|
addFunction("tr", &Wt::WTemplate::Functions::tr);
|
||||||
|
|
||||||
Wt::WPushButton* dumpBtn{ bindNew<Wt::WPushButton>("export-btn", Wt::WString::tr("Lms.Admin.Tracing.export-current-buffer")) };
|
Wt::WPushButton* dumpBtn{ bindNew<Wt::WPushButton>("export-btn", Wt::WString::tr("Lms.Admin.DebugTools.Tracing.export-current-buffer")) };
|
||||||
|
|
||||||
if (auto traceLogger{ core::Service<core::tracing::ITraceLogger>::get() })
|
if (auto traceLogger{ core::Service<core::tracing::ITraceLogger>::get() })
|
||||||
{
|
{
|
||||||
@@ -89,4 +89,5 @@ namespace lms::ui
|
|||||||
else
|
else
|
||||||
dumpBtn->setEnabled(false);
|
dumpBtn->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace lms::ui
|
} // namespace lms::ui
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2024 Emeric Poupon
|
||||||
|
*
|
||||||
|
* This file is part of LMS.
|
||||||
|
*
|
||||||
|
* LMS is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* LMS is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Wt/WTemplate.h>
|
||||||
|
|
||||||
|
namespace lms::ui
|
||||||
|
{
|
||||||
|
class Tracing : public Wt::WTemplate
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Tracing();
|
||||||
|
};
|
||||||
|
} // namespace lms::ui
|
||||||
Reference in New Issue
Block a user