I'm experiencing an odd issue. A couple times a day I get this error:
Code:
"Error establishing database connection: Database driver for "viper_db" is "sqlite" and should be "mysql".
However my database is most definitely setup as mysql in databases.cfg. The error goes away as soon as the map changes and the plugin reloads, at least for several hours until the error crops up again.
It looks to me like it is no longer seeing that my config file has "viper_db" set as the value of the "viper_db_config" CVAR and is perhaps falling back to the default connection which is SQLite.
The relevant code is:
PHP Code:
public OnPluginStart()
{
//Create Commands
RegAdminCmd("sm_viperstart", Command_ViperStart, ADMFLAG_RCON, "sm_viperstart [starts Viper system]");
RegAdminCmd("sm_viperstop", Command_ViperStop, ADMFLAG_RCON, "sm_viperstop [stops Viper system]");
//Debug Commands
RegAdminCmd("sm_viperscores", Command_ViperScores, ADMFLAG_RCON, "sm_vipersscores [debug Viper system command to show scores]");
RegAdminCmd("sm_viperscores_save", Command_ViperScoresSave, ADMFLAG_RCON, "sm_vipersscores_save [debug command to submit scores to database immediately]");
//Hook End Events
HookEvent("player_death", Event_PlayerDeath);
HookEvent("gg_win", Event_GGWin);
HookEvent("cs_win_panel_match", Event_CSWinPanelMatch);
//Create CVars
viper_db_hndl = CreateConVar("viper_db_config", "default", "Database configuration to use for Viper Tournament System", FCVAR_PLUGIN);
viper_table_name_hndl = CreateConVar("viper_table_config", "viper_events", "MySQL table to use for Viper Tournament System Events", FCVAR_PLUGIN);
viper_matches_table_name_hndl = CreateConVar("viper_matches_table_config", "viper_event_matches", "MySQL table to use for Viper Tournament System Match Data. Don't change unless necessary.", FCVAR_PLUGIN);
viper_weapons_table_name_hndl = CreateConVar("viper_weapons_table_config", "viper_event_weapons", "MySQL table to use for Viper Tournament System Weapons Data. Don't change unless necessary.", FCVAR_PLUGIN);
viper_players_table_name_hndl = CreateConVar("viper_players_table_config", "viper_event_players", "MySQL table to use for Viper Tournament System Player Data. Don't change unless necessary.", FCVAR_PLUGIN);
viper_event_name_hndl = CreateConVar("viper_event_name", "Viper Tournament", "The human readable name for the event to be used.", FCVAR_PLUGIN);
//viper_debug_hndl = CreateConVar("viper_debug", "0", "The human readable name for the event to be used.", FCVAR_PLUGIN, true, 0, true, 1);
//Monitor CVar changes and execute accompanying functions
HookConVarChange(viper_db_hndl, OnViperDBChange);
HookConVarChange(viper_table_name_hndl, OnViperDBChange);
HookConVarChange(viper_matches_table_name_hndl, OnViperDBChange);
HookConVarChange(viper_weapons_table_name_hndl, OnViperDBChange);
HookConVarChange(viper_players_table_name_hndl, OnViperDBChange);
HookConVarChange(viper_event_name_hndl, OnViperEventNameChange);
//Execute config file, or create if it does not exist.
AutoExecConfig(true, "viper");
//Load table names into global vars for use by functions
GetConVarString(viper_db_hndl, db_config, sizeof(db_config));
GetConVarString(viper_table_name_hndl, viper_table_name, sizeof(viper_table_name));
GetConVarString(viper_matches_table_name_hndl, viper_matches_table_name, sizeof(viper_matches_table_name));
GetConVarString(viper_weapons_table_name_hndl, viper_weapons_table_name, sizeof(viper_weapons_table_name));
GetConVarString(viper_players_table_name_hndl, viper_players_table_name, sizeof(viper_players_table_name));
//viper_debug_bool = GetConVarBool(viper_debug_hndl);
//Set stats to recordable
viper_stats_yet_recorded_bool = false;
//Connect to database
ConnectDB();
}
PHP Code:
public ConnectDB()
{
// Verify that the configuration is defined in databases.cfg
if (!SQL_CheckConfig(db_config)) {
Viper_LogError("Database configuration \"%s\" does not exist", db_config);
}
// Attempt to establish a connection
SQL_TConnect(Callback_SQL_OnConnect, db_config);
}
PHP Code:
public OnViperDBChange(Handle:cvar, const String:oldVal[], const String:newVal[])
{
GetConVarString(viper_db_hndl, db_config, sizeof(db_config));
GetConVarString(viper_table_name_hndl, viper_table_name, sizeof(viper_table_name));
GetConVarString(viper_matches_table_name_hndl, viper_matches_table_name, sizeof(viper_matches_table_name));
GetConVarString(viper_weapons_table_name_hndl, viper_weapons_table_name, sizeof(viper_weapons_table_name));
GetConVarString(viper_players_table_name_hndl, viper_players_table_name, sizeof(viper_players_table_name));
ConnectDB();
PrepareDB();
}
And the errors I am seeing are:
Code:
L 05/01/2012 - 16:05:41: SourceMod error session started
L 05/01/2012 - 16:05:41: Info (map "aim_ag_texture_city_advanced") (file "errors_20120501.log")
L 05/01/2012 - 16:05:41: [SM] Native "SQL_ReadDriver" reported: Invalid database Handle 1/0 (error: 4)
L 05/01/2012 - 16:05:41: [SM] Displaying call stack trace for plugin "viper.smx":
L 05/01/2012 - 16:05:41: [SM] [0] Line 124, /home/groups/sourcemod/upload_tmp/phpaKQm7v.sp::PrepareDB()
L 05/01/2012 - 16:05:41: [SM] [1] Line 488, /home/groups/sourcemod/upload_tmp/phpaKQm7v.sp::OnViperDBChange()
L 05/01/2012 - 16:05:41: [viper.smx] Error establishing database connection: Database driver for "viper_db" is "sqlite" and should be "mysql".
L 05/01/2012 - 16:05:41: [SM] Plugin encountered error 25: Call was aborted
L 05/01/2012 - 16:05:41: [SM] Native "SetFailState" reported: FATAL: Error establishing database connection: Database driver "viper_db" is "sqlite" and should be "mysql".
L 05/01/2012 - 16:05:41: [SM] Displaying call stack trace for plugin "viper.smx":
L 05/01/2012 - 16:05:41: [SM] [0] Line 129, /home/groups/sourcemod/upload_tmp/phpaKQm7v.sp::PrepareDB()
L 05/01/2012 - 16:05:41: [SM] [1] Line 116, /home/groups/sourcemod/upload_tmp/phpaKQm7v.sp::Callback_SQL_OnConnect()
L 05/01/2012 - 16:18:48: Error log file session closed.