do not use transaction scope in insert_withdraw_info

This commit is contained in:
Christian Grothoff 2015-07-01 14:11:54 +02:00
parent 3cdfdea881
commit 4b447d032d
4 changed files with 51 additions and 58 deletions

View File

@ -34,7 +34,7 @@ main (int argc, char ** argv)
struct PERF_TALER_MINTDB_Cmd test[] = struct PERF_TALER_MINTDB_Cmd test[] =
{ {
// Denomination used to create coins // Denomination used to create coins
PERF_TALER_MINTDB_INIT_CMD_DEBUG ("00 - Start of interpretor"), PERF_TALER_MINTDB_INIT_CMD_DEBUG ("00 - Start of interpreter"),
PERF_TALER_MINTDB_INIT_CMD_LOOP ("01 - denomination loop", PERF_TALER_MINTDB_INIT_CMD_LOOP ("01 - denomination loop",
PERF_TALER_MINTDB_NB_DENOMINATION_INIT), PERF_TALER_MINTDB_NB_DENOMINATION_INIT),
@ -60,7 +60,7 @@ main (int argc, char ** argv)
PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("02 - init reserve end loop", PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("02 - init reserve end loop",
"02 - init reserve loop"), "02 - init reserve loop"),
PERF_TALER_MINTDB_INIT_CMD_DEBUG ("02 - reserve init complete"), PERF_TALER_MINTDB_INIT_CMD_DEBUG ("02 - reserve init complete"),
// End reserve init // End reserve init"00 - Start of interpreter"),
// Withdrawal initialization // Withdrawal initialization
PERF_TALER_MINTDB_INIT_CMD_LOOP ("03 - init withdraw loop", PERF_TALER_MINTDB_INIT_CMD_LOOP ("03 - init withdraw loop",
PERF_TALER_MINTDB_NB_WITHDRAW_INIT), PERF_TALER_MINTDB_NB_WITHDRAW_INIT),
@ -108,21 +108,20 @@ main (int argc, char ** argv)
GNUNET_log_setup ("perf-taler-mintdb", GNUNET_log_setup ("perf-taler-mintdb",
"INFO", "INFO",
NULL); NULL);
config = GNUNET_CONFIGURATION_create(); config = GNUNET_CONFIGURATION_create ();
GNUNET_CONFIGURATION_load(config, "./test-mint-db-postgres.conf"); GNUNET_CONFIGURATION_load (config, "./test-mint-db-postgres.conf");
GNUNET_assert (NULL != GNUNET_assert (NULL !=
(plugin = TALER_MINTDB_plugin_load (config))); (plugin = TALER_MINTDB_plugin_load (config)));
plugin->create_tables (plugin->cls, GNUNET_YES); plugin->create_tables (plugin->cls, GNUNET_YES);
// Run command PERF_TALER_MINTDB_interpret (plugin, test);
PERF_TALER_MINTDB_interpret(plugin, test); /* Drop tables */
// Drop tables
{ {
struct TALER_MINTDB_Session *session; struct TALER_MINTDB_Session *session;
session = plugin->get_session (plugin->cls, GNUNET_YES); session = plugin->get_session (plugin->cls, GNUNET_YES);
plugin->drop_temporary (plugin->cls, session); plugin->drop_temporary (plugin->cls, session);
} }
TALER_MINTDB_plugin_unload(plugin); TALER_MINTDB_plugin_unload (plugin);
GNUNET_CONFIGURATION_destroy(config); GNUNET_CONFIGURATION_destroy (config);
return GNUNET_OK; return 0;
} }

View File

@ -15,7 +15,7 @@
*/ */
/** /**
* @file mintdb/perf_taler_mintdb_init.h * @file mintdb/perf_taler_mintdb_init.h
* @brief Heler function for creating dummy inpus for the mint database * @brief Heler function for creating dummy inputs for the mint database
* @author Nicolas Fournier * @author Nicolas Fournier
*/ */
#ifndef __PERF_TALER_MINTDB_INIT_H___ #ifndef __PERF_TALER_MINTDB_INIT_H___

View File

@ -15,7 +15,7 @@
*/ */
/** /**
* @file mintdb/perf_taler_mintdb_interpreter.h * @file mintdb/perf_taler_mintdb_interpreter.h
* @brief Library for performance analysis of taler database * @brief Library for performance analysis of the Taler database
* @author Nicolas Fournier * @author Nicolas Fournier
*/ */
@ -50,7 +50,7 @@
/** /**
* The begining of a loop * The begining of a loop
* @param _label the name of the loop * @param _label the name of the loop
* @param _iter the number of iteration of the loop * @param _iter the number of iterations of the loop
*/ */
#define PERF_TALER_MINTDB_INIT_CMD_LOOP(_label, _iter) \ #define PERF_TALER_MINTDB_INIT_CMD_LOOP(_label, _iter) \
{ \ { \
@ -74,22 +74,23 @@
} }
/** /**
* Saves the time of execution to use for logging with gauger * Saves the time of execution to use for logging with Gauger
*/ */
#define PERF_TALER_MINTDB_INIT_CMD_GET_TIME(_label) \ #define PERF_TALER_MINTDB_INIT_CMD_GET_TIME(_label) \
{ \ { \
.command = PERF_TALER_MINTDB_CMD_GET_TIME, \ .command = PERF_TALER_MINTDB_CMD_GET_TIME, \
.label = _label, \ .label = _label, \
.exposed.type = PERF_TALER_MINTDB_NONE, \ .exposed.type = PERF_TALER_MINTDB_NONE \
} }
/** /**
* Commits the duration between @a _label_start and @a _label_stop * Commits the duration between @a _label_start and @a _label_stop
* to Gauger with @a _description explaining * to Gauger with @a _description explaining what was measured.
*
* @param _label_start label of the start of the measurment * @param _label_start label of the start of the measurment
* @param _label_stop label of the end of the measurment * @param _label_stop label of the end of the measurment
* @param _description description of the measure displayed in gauger * @param _description description of the measure displayed in Gauger
* @param _divide number of measurments in the interval * @param _divide number of measurments in the interval [FIXME: need UNIT]
*/ */
#define PERF_TALER_MINTDB_INIT_CMD_GAUGER(_label, _label_start, _label_stop, _description, _divide) \ #define PERF_TALER_MINTDB_INIT_CMD_GAUGER(_label, _label_start, _label_stop, _description, _divide) \
{ \ { \
@ -115,7 +116,7 @@
} }
/** /**
* Commits a database connection * Commits a database transaction
*/ */
#define PERF_TALER_MINTDB_INIT_CMD_COMMIT_TRANSACTION(_label) \ #define PERF_TALER_MINTDB_INIT_CMD_COMMIT_TRANSACTION(_label) \
{ \ { \
@ -244,7 +245,7 @@
/** /**
* Polls the database about informations regarding a secific withdrawal * Polls the database about informations regarding a specific withdrawal
*/ */
#define PERF_TALER_MINTDB_INIT_CMD_GET_WITHDRAW(_label, _label_source) \ #define PERF_TALER_MINTDB_INIT_CMD_GET_WITHDRAW(_label, _label_source) \
{ \ { \
@ -267,7 +268,7 @@ enum PERF_TALER_MINTDB_Type
PERF_TALER_MINTDB_BLINDCOIN, PERF_TALER_MINTDB_BLINDCOIN,
PERF_TALER_MINTDB_RESERVE, PERF_TALER_MINTDB_RESERVE,
PERF_TALER_MINTDB_DENOMINATION_INFO, PERF_TALER_MINTDB_DENOMINATION_INFO,
PERF_TALER_MINTDB_COIN_INFO, PERF_TALER_MINTDB_COIN_INFO
}; };
@ -290,8 +291,8 @@ union PERF_TALER_MINTDB_Memory
*/ */
struct PERF_TALER_MINTDB_Data struct PERF_TALER_MINTDB_Data
{ {
union PERF_TALER_MINTDB_Memory data;
enum PERF_TALER_MINTDB_Type type; enum PERF_TALER_MINTDB_Type type;
union PERF_TALER_MINTDB_Memory data; // inline def.
}; };
@ -300,10 +301,14 @@ struct PERF_TALER_MINTDB_Data
*/ */
enum PERF_TALER_MINTDB_CMD_Name enum PERF_TALER_MINTDB_CMD_Name
{ {
// All comand chain must hace this as their last command /**
* All comand chain must hace this as their last command
*/
PERF_TALER_MINTDB_CMD_END, PERF_TALER_MINTDB_CMD_END,
// Prints it's label /**
* Prints it's label
*/
PERF_TALER_MINTDB_CMD_DEBUG, PERF_TALER_MINTDB_CMD_DEBUG,
// Define the start of al command chain loop // Define the start of al command chain loop
@ -361,7 +366,7 @@ enum PERF_TALER_MINTDB_CMD_Name
PERF_TALER_MINTDB_CMD_GET_DENOMINATION, PERF_TALER_MINTDB_CMD_GET_DENOMINATION,
// Refresh a coin // Refresh a coin
PERF_TALER_MINTDB_CMD_REFRESH_COIN, PERF_TALER_MINTDB_CMD_REFRESH_COIN
}; };
@ -377,7 +382,7 @@ struct PERF_TALER_MINTDB_CMD_loop_details
/** /**
* Extra data requiered by the LOOP_END command * Extra data requiered by the #PERF_TALER_MINTDB_CMD_END_LOOP command
*/ */
struct PERF_TALER_MINTDB_CMD_loop_end_details struct PERF_TALER_MINTDB_CMD_loop_end_details
{ {
@ -389,7 +394,7 @@ struct PERF_TALER_MINTDB_CMD_loop_end_details
/** /**
* Details about the GAUGER command * Details about the Gauger command
*/ */
struct PERF_TALER_MINTDB_CMD_gauger_details struct PERF_TALER_MINTDB_CMD_gauger_details
{ {
@ -404,7 +409,7 @@ struct PERF_TALER_MINTDB_CMD_gauger_details
const char *label_stop; const char *label_stop;
/** /**
* Description of the metric, used in GAUGER * Description of the metric, used in Gauger
*/ */
const char *description; const char *description;

View File

@ -1536,11 +1536,6 @@ postgres_insert_withdraw_info (void *cls,
TALER_PQ_query_param_end TALER_PQ_query_param_end
}; };
if (GNUNET_OK != postgres_start (cls,
session))
{
return GNUNET_SYSERR;
}
now = GNUNET_TIME_absolute_get (); now = GNUNET_TIME_absolute_get ();
result = TALER_PQ_exec_prepared (session->conn, result = TALER_PQ_exec_prepared (session->conn,
"insert_withdraw_info", "insert_withdraw_info",
@ -1548,7 +1543,7 @@ postgres_insert_withdraw_info (void *cls,
if (PGRES_COMMAND_OK != PQresultStatus (result)) if (PGRES_COMMAND_OK != PQresultStatus (result))
{ {
QUERY_ERR (result); QUERY_ERR (result);
goto rollback; goto cleanup;
} }
reserve.pub = collectable->reserve_pub; reserve.pub = collectable->reserve_pub;
if (GNUNET_OK != postgres_reserve_get (cls, if (GNUNET_OK != postgres_reserve_get (cls,
@ -1557,7 +1552,7 @@ postgres_insert_withdraw_info (void *cls,
{ {
/* Should have been checked before we got here... */ /* Should have been checked before we got here... */
GNUNET_break (0); GNUNET_break (0);
goto rollback; goto cleanup;
} }
if (GNUNET_SYSERR == if (GNUNET_SYSERR ==
TALER_amount_subtract (&reserve.balance, TALER_amount_subtract (&reserve.balance,
@ -1566,7 +1561,7 @@ postgres_insert_withdraw_info (void *cls,
{ {
/* Should have been checked before we got here... */ /* Should have been checked before we got here... */
GNUNET_break (0); GNUNET_break (0);
goto rollback; goto cleanup;
} }
expiry = GNUNET_TIME_absolute_add (now, expiry = GNUNET_TIME_absolute_add (now,
TALER_IDLE_RESERVE_EXPIRATION_TIME); TALER_IDLE_RESERVE_EXPIRATION_TIME);
@ -1575,17 +1570,11 @@ postgres_insert_withdraw_info (void *cls,
if (GNUNET_OK != reserves_update (cls, if (GNUNET_OK != reserves_update (cls,
session, session,
&reserve)) &reserve))
goto rollback;
if (GNUNET_OK == postgres_commit (cls,
session))
{ {
ret = GNUNET_OK; GNUNET_break (0);
goto cleanup; goto cleanup;
} }
ret = GNUNET_OK;
rollback:
postgres_rollback (cls,
session);
cleanup: cleanup:
PQclear (result); PQclear (result);
return ret; return ret;