From 1a3e1817fd06bba941cfa73ecd1c91600ba37f52 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 10 Nov 2024 17:22:23 +0100 Subject: ensure we do not start if the database version is outdated (#9203) --- src/backend/taler-merchant-depositcheck.c | 2 +- src/backend/taler-merchant-exchangekeyupdate.c | 2 +- src/backend/taler-merchant-httpd.c | 2 +- src/backend/taler-merchant-kyccheck.c | 2 +- src/backend/taler-merchant-reconciliation.c | 2 +- src/backend/taler-merchant-webhook.c | 2 +- src/backend/taler-merchant-wirewatch.c | 2 +- src/backenddb/plugin_merchantdb_postgres.c | 11 ++++++----- src/backenddb/test_merchantdb.c | 1 + src/merchant-tools/taler-merchant-passwd.c | 2 +- 10 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/backend/taler-merchant-depositcheck.c b/src/backend/taler-merchant-depositcheck.c index ab333903..c7452a30 100644 --- a/src/backend/taler-merchant-depositcheck.c +++ b/src/backend/taler-merchant-depositcheck.c @@ -1017,7 +1017,7 @@ run (void *cls, db_plugin->connect (db_plugin->cls)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to connect to database\n"); + "Failed to connect to database. Consider running taler-merchant-dbinit!\n"); GNUNET_SCHEDULER_shutdown (); global_ret = EXIT_NO_RESTART; return; diff --git a/src/backend/taler-merchant-exchangekeyupdate.c b/src/backend/taler-merchant-exchangekeyupdate.c index 3d9dc299..0945ad7e 100644 --- a/src/backend/taler-merchant-exchangekeyupdate.c +++ b/src/backend/taler-merchant-exchangekeyupdate.c @@ -954,7 +954,7 @@ run (void *cls, db_plugin->connect (db_plugin->cls)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to connect to database\n"); + "Failed to connect to database. Consider running taler-merchant-dbinit!\n"); GNUNET_SCHEDULER_shutdown (); global_ret = EXIT_FAILURE; return; diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c index 9ce53da9..8730c119 100644 --- a/src/backend/taler-merchant-httpd.c +++ b/src/backend/taler-merchant-httpd.c @@ -2344,7 +2344,7 @@ run (void *cls, TMH_db->connect (TMH_db->cls)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to initialize database connection\n"); + "Failed to connect to database. Consider running taler-merchant-dbinit!\n"); GNUNET_SCHEDULER_shutdown (); return; } diff --git a/src/backend/taler-merchant-kyccheck.c b/src/backend/taler-merchant-kyccheck.c index fe4b5792..60b7d615 100644 --- a/src/backend/taler-merchant-kyccheck.c +++ b/src/backend/taler-merchant-kyccheck.c @@ -1379,7 +1379,7 @@ run (void *cls, db_plugin->connect (db_plugin->cls)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to connect to database\n"); + "Failed to connect to database. Consider running taler-merchant-dbinit.\n"); GNUNET_SCHEDULER_shutdown (); global_ret = EXIT_FAILURE; return; diff --git a/src/backend/taler-merchant-reconciliation.c b/src/backend/taler-merchant-reconciliation.c index 238e33fd..b08571c2 100644 --- a/src/backend/taler-merchant-reconciliation.c +++ b/src/backend/taler-merchant-reconciliation.c @@ -1192,7 +1192,7 @@ run (void *cls, db_plugin->connect (db_plugin->cls)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to connect to database\n"); + "Failed to connect to database. Consider running taler-merchant-dbinit!\n"); GNUNET_SCHEDULER_shutdown (); global_ret = EXIT_FAILURE; return; diff --git a/src/backend/taler-merchant-webhook.c b/src/backend/taler-merchant-webhook.c index d9910ade..12da345f 100644 --- a/src/backend/taler-merchant-webhook.c +++ b/src/backend/taler-merchant-webhook.c @@ -522,7 +522,7 @@ run (void *cls, db_plugin->connect (db_plugin->cls)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to connect to database\n"); + "Failed to connect to database. Consider running taler-merchant-dbinit!\n"); GNUNET_SCHEDULER_shutdown (); global_ret = EXIT_FAILURE; return; diff --git a/src/backend/taler-merchant-wirewatch.c b/src/backend/taler-merchant-wirewatch.c index 999d5e67..e41dceee 100644 --- a/src/backend/taler-merchant-wirewatch.c +++ b/src/backend/taler-merchant-wirewatch.c @@ -654,7 +654,7 @@ run (void *cls, db_plugin->connect (db_plugin->cls)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to connect to database\n"); + "Failed to connect to database. Consider running taler-merchant-dbinit!\n"); GNUNET_SCHEDULER_shutdown (); global_ret = EXIT_FAILURE; return; diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c index de0b9181..59e3f2fb 100644 --- a/src/backenddb/plugin_merchantdb_postgres.c +++ b/src/backenddb/plugin_merchantdb_postgres.c @@ -320,11 +320,12 @@ postgres_connect (void *cls) GNUNET_PQ_EXECUTE_STATEMENT_END }; - pg->conn = GNUNET_PQ_connect_with_cfg (pg->cfg, - "merchantdb-postgres", - NULL, - es, - NULL); + pg->conn = GNUNET_PQ_connect_with_cfg2 (pg->cfg, + "merchantdb-postgres", + "merchant-", + es, + NULL, /* prepared statemetns */ + GNUNET_PQ_FLAG_CHECK_CURRENT); pg->prep_gen++; if (NULL == pg->conn) return GNUNET_SYSERR; diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c index f9943754..8671cfc5 100644 --- a/src/backenddb/test_merchantdb.c +++ b/src/backenddb/test_merchantdb.c @@ -7307,6 +7307,7 @@ run (void *cls) if (GNUNET_OK != plugin->connect (plugin->cls)) { + GNUNET_break (0); result = 17; return; } diff --git a/src/merchant-tools/taler-merchant-passwd.c b/src/merchant-tools/taler-merchant-passwd.c index a5dd8cf2..5f061d89 100644 --- a/src/merchant-tools/taler-merchant-passwd.c +++ b/src/merchant-tools/taler-merchant-passwd.c @@ -105,7 +105,7 @@ run (void *cls, plugin->connect (plugin->cls)) { fprintf (stderr, - "Failed to connect to database\n"); + "Failed to connect to database. Consider running taler-merchant-dbinit!\n"); global_ret = 1; TALER_MERCHANTDB_plugin_unload (plugin); GNUNET_CONFIGURATION_destroy (cfg); -- cgit v1.2.3