do not use transaction scope in insert_withdraw_info
This commit is contained in:
parent
3cdfdea881
commit
4b447d032d
@ -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),
|
||||||
@ -82,7 +82,7 @@ main (int argc, char ** argv)
|
|||||||
PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("03 - withdraw init end loop",
|
PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("03 - withdraw init end loop",
|
||||||
"03 - init withdraw loop"),
|
"03 - init withdraw loop"),
|
||||||
PERF_TALER_MINTDB_INIT_CMD_DEBUG ("03 - withdraw init complete"),
|
PERF_TALER_MINTDB_INIT_CMD_DEBUG ("03 - withdraw init complete"),
|
||||||
//End of withdrawal initialization
|
//End of withdrawal initialization
|
||||||
//Deposit initialization
|
//Deposit initialization
|
||||||
PERF_TALER_MINTDB_INIT_CMD_LOOP ("04 - deposit init loop",
|
PERF_TALER_MINTDB_INIT_CMD_LOOP ("04 - deposit init loop",
|
||||||
PERF_TALER_MINTDB_NB_DEPOSIT_INIT),
|
PERF_TALER_MINTDB_NB_DEPOSIT_INIT),
|
||||||
@ -91,7 +91,7 @@ main (int argc, char ** argv)
|
|||||||
"04 - deposit init loop",
|
"04 - deposit init loop",
|
||||||
"01 - save denomination"),
|
"01 - save denomination"),
|
||||||
|
|
||||||
PERF_TALER_MINTDB_INIT_CMD_INSERT_DEPOSIT ("04 - deposit",
|
PERF_TALER_MINTDB_INIT_CMD_INSERT_DEPOSIT ("04 - deposit",
|
||||||
"04 - denomination load"),
|
"04 - denomination load"),
|
||||||
PERF_TALER_MINTDB_INIT_CMD_COMMIT_TRANSACTION ("04 - commit transaction"),
|
PERF_TALER_MINTDB_INIT_CMD_COMMIT_TRANSACTION ("04 - commit transaction"),
|
||||||
PERF_TALER_MINTDB_INIT_CMD_SAVE_ARRAY ("04 - deposit array",
|
PERF_TALER_MINTDB_INIT_CMD_SAVE_ARRAY ("04 - deposit array",
|
||||||
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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___
|
||||||
|
@ -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) \
|
||||||
{ \
|
{ \
|
||||||
@ -125,7 +126,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extracts @a _nb_saved items of type @a _save_type
|
* Extracts @a _nb_saved items of type @a _save_type
|
||||||
* from the command @a _label_save during the loop @a _label_loop
|
* from the command @a _label_save during the loop @a _label_loop
|
||||||
*/
|
*/
|
||||||
#define PERF_TALER_MINTDB_INIT_CMD_SAVE_ARRAY(_label, _label_loop, _label_save, _nb_saved) \
|
#define PERF_TALER_MINTDB_INIT_CMD_SAVE_ARRAY(_label, _label_loop, _label_save, _nb_saved) \
|
||||||
@ -142,7 +143,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads @a _nb_saved previously sampled data of type @a _saved_type
|
* Loads @a _nb_saved previously sampled data of type @a _saved_type
|
||||||
* from @a _label_save during the loop @a _label_loop
|
* from @a _label_save during the loop @a _label_loop
|
||||||
*/
|
*/
|
||||||
#define PERF_TALER_MINTDB_INIT_CMD_LOAD_ARRAY(_label, _label_loop, _label_save) \
|
#define PERF_TALER_MINTDB_INIT_CMD_LOAD_ARRAY(_label, _label_loop, _label_save) \
|
||||||
{ \
|
{ \
|
||||||
@ -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) \
|
||||||
{ \
|
{ \
|
||||||
@ -259,7 +260,7 @@
|
|||||||
* The type of data stored
|
* The type of data stored
|
||||||
* in a PERF_TALER_MINTDB_Type
|
* in a PERF_TALER_MINTDB_Type
|
||||||
*/
|
*/
|
||||||
enum PERF_TALER_MINTDB_Type
|
enum PERF_TALER_MINTDB_Type
|
||||||
{
|
{
|
||||||
PERF_TALER_MINTDB_NONE,
|
PERF_TALER_MINTDB_NONE,
|
||||||
PERF_TALER_MINTDB_TIME,
|
PERF_TALER_MINTDB_TIME,
|
||||||
@ -267,16 +268,16 @@ 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
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Storage for a variety of data type
|
* Storage for a variety of data type
|
||||||
*/
|
*/
|
||||||
union PERF_TALER_MINTDB_Memory
|
union PERF_TALER_MINTDB_Memory
|
||||||
{
|
{
|
||||||
struct timespec time;
|
struct timespec time;
|
||||||
struct TALER_MINTDB_Deposit *deposit;
|
struct TALER_MINTDB_Deposit *deposit;
|
||||||
struct TALER_MINTDB_CollectableBlindcoin *blindcoin;
|
struct TALER_MINTDB_CollectableBlindcoin *blindcoin;
|
||||||
struct TALER_MINTDB_Reserve *reserve;
|
struct TALER_MINTDB_Reserve *reserve;
|
||||||
@ -286,12 +287,12 @@ 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,15 +301,19 @@ 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
|
||||||
PERF_TALER_MINTDB_CMD_LOOP,
|
PERF_TALER_MINTDB_CMD_LOOP,
|
||||||
|
|
||||||
// Define the end of a command chain loop
|
// Define the end of a command chain loop
|
||||||
PERF_TALER_MINTDB_CMD_END_LOOP,
|
PERF_TALER_MINTDB_CMD_END_LOOP,
|
||||||
|
|
||||||
@ -335,7 +340,7 @@ enum PERF_TALER_MINTDB_CMD_Name
|
|||||||
|
|
||||||
// Load deposits saved earlier
|
// Load deposits saved earlier
|
||||||
PERF_TALER_MINTDB_CMD_LOAD_ARRAY,
|
PERF_TALER_MINTDB_CMD_LOAD_ARRAY,
|
||||||
|
|
||||||
// Insert a deposit into the database
|
// Insert a deposit into the database
|
||||||
PERF_TALER_MINTDB_CMD_INSERT_DEPOSIT,
|
PERF_TALER_MINTDB_CMD_INSERT_DEPOSIT,
|
||||||
|
|
||||||
@ -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,9 +382,9 @@ 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
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Label of the loop closed by the command
|
* Label of the loop closed by the command
|
||||||
@ -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;
|
||||||
|
|
||||||
@ -458,7 +463,7 @@ struct PERF_TALER_MINTDB_CMD_load_array_details
|
|||||||
* Label of the command where the items were saved
|
* Label of the command where the items were saved
|
||||||
*/
|
*/
|
||||||
const char *label_save;
|
const char *label_save;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A permutation array used to randomize the order the items are loaded in
|
* A permutation array used to randomize the order the items are loaded in
|
||||||
*/
|
*/
|
||||||
@ -467,7 +472,7 @@ struct PERF_TALER_MINTDB_CMD_load_array_details
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data used by the command insert_deposit
|
* Data used by the command insert_deposit
|
||||||
*/
|
*/
|
||||||
struct PERF_TALER_MINTDB_CMD_insert_deposit_details
|
struct PERF_TALER_MINTDB_CMD_insert_deposit_details
|
||||||
{
|
{
|
||||||
|
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user