support async commit
authorChristian Grothoff <christian@grothoff.org>
Wed, 11 Apr 2018 10:19:55 +0000 (12:19 +0200)
committerChristian Grothoff <christian@grothoff.org>
Wed, 11 Apr 2018 10:19:55 +0000 (12:19 +0200)
src/namestore/gnunet-zoneimport.c
src/namestore/namestore.conf.in
src/namestore/plugin_namestore_postgres.c

index 493569bcaabda9b8d2c7917c8d672316834e52eb..9041431d1d6ad2075d2faa1b47aa70c80c14ce27 100644 (file)
@@ -1254,13 +1254,18 @@ run (void *cls,
                    "libgnunet_plugin_namestore_%s",
                    database);
   ns = GNUNET_PLUGIN_load (db_lib_name,
-                          (void *) cfg);
+                          (void *) cfg); 
   GNUNET_free (database);
+  GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
+                                 NULL);
+  if (NULL == ns)
+  {
+    GNUNET_SCHEDULER_shutdown ();
+    return;
+  }
   id = GNUNET_IDENTITY_connect (cfg,
                                &identity_cb,
                                NULL);
-  GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
-                                 NULL);
 }
 
 
index 0ebd2586bb10f6408e6eb74f62ef5ddbad3b7ec5..f19ac56439726dc1460d9d8b53ed5a2ba6616204 100644 (file)
@@ -19,8 +19,12 @@ FILENAME = $GNUNET_DATA_HOME/namestore/flat.db
 
 
 [namestore-postgres]
+# How to connect to the database
 CONFIG = postgres:///gnunet
+# Use temporary tables
 TEMPORARY_TABLE = NO
+# Use asynchronous commit (SET synchronous_commit TO OFF).
+ASYNC_COMMIT = NO
 
 [uri]
 gns = gnunet-namestore
index 872bf75cb68efcd8eaca0170d19f41da5946addd..4828cb190d8f7eb3c1791979a854aaedd870c81d 100644 (file)
@@ -90,6 +90,25 @@ database_setup (struct Plugin *plugin)
                                             "namestore-postgres");
   if (NULL == plugin->dbh)
     return GNUNET_SYSERR;
+  if (GNUNET_YES ==
+      GNUNET_CONFIGURATION_get_value_yesno (plugin->cfg,
+                                           "namestore-postgres",
+                                           "ASYNC_COMMIT"))
+  {
+    struct GNUNET_PQ_ExecuteStatement es[] = {
+      GNUNET_PQ_make_try_execute ("SET synchronous_commit TO off"),
+      GNUNET_PQ_EXECUTE_STATEMENT_END
+    };
+
+    if (GNUNET_OK !=
+        GNUNET_PQ_exec_statements (plugin->dbh,
+                                   es))
+    {
+      PQfinish (plugin->dbh);
+      plugin->dbh = NULL;
+      return GNUNET_SYSERR;
+    }
+  }
   if (GNUNET_YES ==
       GNUNET_CONFIGURATION_get_value_yesno (plugin->cfg,
                                            "namestore-postgres",