]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
debuginfod: Turn -d ":memory:" into -d "file::memory:?cache=shared"
authorMark Wielaard <mark@klomp.org>
Sat, 28 Aug 2021 18:25:56 +0000 (20:25 +0200)
committerMark Wielaard <mark@klomp.org>
Sat, 28 Aug 2021 18:25:56 +0000 (20:25 +0200)
debuginfod opens the database twice, once in read/wrote and once in
read-only mode. This means the magic ":memory:" in-memory database
cannot be used as is because the two connections don't really share
the underlying database. Fix this by turning ":memory:" into
":file::memory:?cache=shared" which makes the in-memory database
shared. See https://sqlite.org/inmemorydb.html

Document this in debuginfod.8 and make some tests use -d :memory:

Signed-off-by: Mark Wielaard <mark@klomp.org>
debuginfod/ChangeLog
debuginfod/debuginfod.cxx
doc/ChangeLog
doc/debuginfod.8
tests/ChangeLog
tests/run-debuginfod-find.sh

index 395af94f4ae58634560b2d979b4c1586a6597915..c54598239c82c34810c93995f73cd503b4fc84b6 100644 (file)
@@ -1,3 +1,8 @@
+2021-08-28  Mark Wielaard  <mjw@redhat.com>
+
+       * debuginfod.cxx (parse_opt): Turn the -d arg ":memory:" into
+       "file::memory:?cache=shared" for the db_path.
+
 2021-08-20  Di Chen  <dichen@redhat.com>
 
        * debuginfod.cxx (options): Add ARGP_KEY_FORWARDED_TTL_LIMIT.
index 6e182a845168dedefd040a8b99726e8e53ae74c1..3269f657cc8ddf964137b7105ac89d61ec0ca01c 100644 (file)
@@ -483,7 +483,14 @@ parse_opt (int key, char *arg,
   switch (key)
     {
     case 'v': verbose ++; break;
-    case 'd': db_path = string(arg); break;
+    case 'd':
+      /* When using the in-memory database make sure it is shareable,
+        so we can open it twice as read/write and read-only.  */
+      if (strcmp (arg, ":memory:") == 0)
+       db_path = "file::memory:?cache=shared";
+      else
+       db_path = string(arg);
+      break;
     case 'p': http_port = (unsigned) atoi(arg);
       if (http_port == 0 || http_port > 65535)
         argp_failure(state, 1, EINVAL, "port number");
index d5f34f0f8d476a6906e9ab5e6b94e06ad5363ddd..ada483837859b5a519a8503a3c82501dc1b33dec 100644 (file)
@@ -1,3 +1,7 @@
+2021-08-28  Di Chen  <dichen@redhat.com>
+
+       * debuginfod.8 (-d): Document ":memory:" as in-memory database.
+
 2021-08-20  Di Chen  <dichen@redhat.com>
 
        * debuginfod.8: Add --forwarded-ttl-limit=NUM documentation.
index 5b0d793c522039a359ce057ba3cd1aeb581906eb..f9a418d16253f27eb086789489c12327194be10a 100644 (file)
@@ -117,8 +117,10 @@ file is disposable in the sense that a later rescan will repopulate
 data.  It will contain absolute file path names, so it may not be
 portable across machines.  It may be frequently read/written, so it
 should be on a fast filesystem.  It should not be shared across
-machines or users, to maximize sqlite locking performance.  The
-default database file is \%$HOME/.debuginfod.sqlite.
+machines or users, to maximize sqlite locking performance.  For quick
+testing the magic string ":memory:" can be used to use an one-time
+memory-only database.  The default database file is
+\%$HOME/.debuginfod.sqlite.
 
 .TP
 .B "\-D SQL" "\-\-ddl=SQL"
index cbd1c227ecec0aa85bad581955c768d5ab557b5e..3fa7c2e445ff6beb620918e400e0b83a1a7f53b2 100644 (file)
@@ -1,3 +1,8 @@
+2021-08-28  Mark Wielaard  <mark@klomp.org>
+
+       * run-debuginfod-find.sh: Use ":memory:" for the
+       forwarded-ttl-limit tests.
+
 2021-08-28  Mark Wielaard  <mark@klomp.org>
 
        * run-debuginfod-find.sh: Use clean, separate databases for
index 5d38d62558ed4b1bd4ad8106e9cca9e0a059ae7b..7515b7cd4cd7cfa24ff6aefea42f9a93b1c1bed3 100755 (executable)
@@ -824,13 +824,10 @@ done
 tempfiles vlog$PORT4 vlog$PORT5
 errfiles vlog$PORT4 vlog$PORT5
 
-# Give each debuginfd its own clean database.
-tempfiles db.$PORT4.sql db.$PORT5.sql
-
-env LD_LIBRARY_PATH=$ldpath DEBUGINFOD_URLS=http://127.0.0.1:$PORT5 ${abs_builddir}/../debuginfod/debuginfod $VERBOSE -d db.$PORT4.sql --forwarded-ttl-limit 0 -p $PORT4 > vlog$PORT4 2>&1 &
+env LD_LIBRARY_PATH=$ldpath DEBUGINFOD_URLS=http://127.0.0.1:$PORT5 ${abs_builddir}/../debuginfod/debuginfod $VERBOSE -d :memory: --forwarded-ttl-limit 0 -p $PORT4 > vlog$PORT4 2>&1 &
 PID5=$!
 
-env LD_LIBRARY_PATH=$ldpath DEBUGINFOD_URLS=http://127.0.0.1:$PORT4 ${abs_builddir}/../debuginfod/debuginfod $VERBOSE -d db.$PORT5.sql --forwarded-ttl-limit 1 -p $PORT5 > vlog$PORT5 2>&1 &
+env LD_LIBRARY_PATH=$ldpath DEBUGINFOD_URLS=http://127.0.0.1:$PORT4 ${abs_builddir}/../debuginfod/debuginfod $VERBOSE -d :memory: --forwarded-ttl-limit 1 -p $PORT5 > vlog$PORT5 2>&1 &
 PID6=$!
 
 wait_ready $PORT4 'ready' 1