Backport swdb-create-persistent-WAL-files-RhBug1640235

Fix problem with non root users that use command that requires swdb like
"dnf list".
This commit is contained in:
Jaroslav Mracek 2018-10-18 17:24:15 +02:00
parent b473d937cf
commit e34f3b2250
2 changed files with 43 additions and 2 deletions

View File

@ -0,0 +1,37 @@
From dbe553c3846061f022dae906276b77a8430cce6a Mon Sep 17 00:00:00 2001
From: Jaroslav Rohel <jrohel@redhat.com>
Date: Thu, 18 Oct 2018 16:06:55 +0200
Subject: [PATCH] [swdb] create persistent WAL files (RhBug:1640235)
---
libdnf/utils/sqlite3/Sqlite3.cpp | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/libdnf/utils/sqlite3/Sqlite3.cpp b/libdnf/utils/sqlite3/Sqlite3.cpp
index 021b5d2..27fed56 100644
--- a/libdnf/utils/sqlite3/Sqlite3.cpp
+++ b/libdnf/utils/sqlite3/Sqlite3.cpp
@@ -30,9 +30,17 @@ SQLite3::open()
sqlite3_close(db);
throw LibException(result, "Open failed");
}
- // sqlite doesn't behave correctly in chroots without following line:
- // turn foreign key checking on
- exec("PRAGMA locking_mode = NORMAL; PRAGMA journal_mode = WAL; PRAGMA foreign_keys = ON;");
+#if SQLITE_VERSION_NUMBER >= 3022000
+ int enabled = 1;
+ sqlite3_file_control(db, "main", SQLITE_FCNTL_PERSIST_WAL, &enabled);
+ if (sqlite3_db_readonly(db, "main") == 1)
+ exec("PRAGMA locking_mode = NORMAL; PRAGMA foreign_keys = ON;");
+ else
+ exec("PRAGMA locking_mode = NORMAL; PRAGMA journal_mode = WAL; PRAGMA foreign_keys = ON;");
+#else
+ // Journal mode WAL in readonly mode is supported from sqlite version 3.22.0
+ exec("PRAGMA locking_mode = NORMAL; PRAGMA journal_mode = TRUNCATE; PRAGMA foreign_keys = ON;");
+#endif
sqlite3_busy_timeout(db, 10000);
}
}
--
libgit2 0.26.7

View File

@ -31,13 +31,14 @@
Name: libdnf
Version: 0.22.0
Release: 2%{?dist}
Release: 3%{?dist}
Summary: Library providing simplified C and Python API to libsolv
License: LGPLv2+
URL: https://github.com/rpm-software-management/libdnf
Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz
Patch0001: 0001-Modify-solver_describe_decision-to-report-cleaned-RhBug1486749.patch
Patch0002: 0002-history-Fix-crash-in-TransactionItemaddReplacedBy.patch
Patch0003: 0003-swdb-create-persistent-WAL-files-RhBug1640235.patch
BuildRequires: cmake
BuildRequires: gcc
@ -245,7 +246,10 @@ popd
%endif
%changelog
* Wed Oct 15 2018 Jaroslav Mracek <jmracek@redhat.com> - 0.22.0-2
* Wed Oct 18 2018 Jaroslav Mracek <jmracek@redhat.com> - 0.22.0-3
- bacport swdb-create-persistent-WAL-files-RhBug1640235
* Wed Oct 17 2018 Jaroslav Mracek <jmracek@redhat.com> - 0.22.0-2
- backport Modify-solver_describe_decision-to-report-cleaned-RhBug1486749
- backport history-Fix-crash-in-TransactionItemaddReplacedBy