diff options
author | Marco Boss <bossm8@bfh.ch> | 2022-04-02 18:43:49 +0200 |
---|---|---|
committer | Marco Boss <bossm8@bfh.ch> | 2022-04-02 18:43:49 +0200 |
commit | ae75ff2cb4f0b7322a9f0451acaadfb7b7514b54 (patch) | |
tree | 815a2bdc75d437f733ec8f60b8d150f915ea9540 /src/exchange-tools/taler-exchange-dbinit.c | |
parent | caabee9e9482b0e2553172ce17676a0ad89b38ff (diff) |
extend sharding logic that shard nodes can be initialied and dropped
Diffstat (limited to 'src/exchange-tools/taler-exchange-dbinit.c')
-rw-r--r-- | src/exchange-tools/taler-exchange-dbinit.c | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/src/exchange-tools/taler-exchange-dbinit.c b/src/exchange-tools/taler-exchange-dbinit.c index 34b68f8ff..c2d8964d6 100644 --- a/src/exchange-tools/taler-exchange-dbinit.c +++ b/src/exchange-tools/taler-exchange-dbinit.c @@ -60,6 +60,11 @@ static uint32_t num_foreign_servers; static uint32_t shard_idx; /** + * -R option: do full shard DB reset + */ +static uint32_t reset_shard_db; + +/** * Main function that will be run. * * @param cls closure @@ -94,10 +99,25 @@ run (void *cls, "Could not drop tables as requested. Either database was not yet initialized, or permission denied. Consult the logs. Will still try to create new tables.\n"); } } - if (1 < + if (0 < + reset_shard_db) + { + if (GNUNET_OK != plugin->drop_shard_tables (plugin->cls, reset_shard_db)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Could not drop shard tables as requested. Either database was not yet initialized or permission denied. Consult the logs.\n"); + global_ret = EXIT_FAILURE; + return; + } + GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, + "Dropped shard database, please call taler-exchange-dbinit -S <N> to initialize a new shard database\n"); + return; + } + if (0 < shard_idx) { - if (GNUNET_OK != plugin->create_shard_tables (plugin->cls, shard_idx)) + if (GNUNET_OK != plugin->create_shard_tables (plugin->cls, + shard_idx)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not create shard database\n"); @@ -226,13 +246,18 @@ main (int argc, GNUNET_GETOPT_option_uint ('F', "foreign", "NUMBER", - "Setup a sharded database whit N foreign servers (shards) / tables", + "Setup a sharded database whit N foreign servers (shards) / tables, must be called as DB superuser", &num_foreign_servers), GNUNET_GETOPT_option_uint ('S', "shard", "INDEX", "Setup a shard server, creates tables with INDEX as suffix", &shard_idx), + GNUNET_GETOPT_option_uint ('R', + "reset-shard", + "OLD_SHARD_IDX", + "reset a shard database, does not reinitialize i.e. call taler-exchange-dbinit -S afterwards (DANGEROUS: all existsing data is lost!)", + &reset_shard_db), GNUNET_GETOPT_OPTION_END }; enum GNUNET_GenericReturnValue ret; |