Hi,
I am Adding a record to a (large?) 700,000+ records database.
Many times I get a System.TimeoutException on IO.
I have set MySqlCommand.CommandTimeout to 0,
I have set net write timeout and net read timeout to Timeout.Infinite
The following code-snippet is what is executed at the time.
if (sStatus == "Fetching refActor completed")
{
if (Doc.refActors[3].Count == 0)
Doc.refActors[3].Add("");
int nAct = 0;
if (Doc.refActors[2][0] != "")
sqlString = "Select * from Actor where Link='" + Doc.refActors[2][0] + "';";
else
sqlString = "Select * from Actor where NameActor='" + Quotes(Doc.refActors[0][0]) + "';";
conn.Close();
cmd = new MySqlCommand(sqlString, conn);
cmd.CommandTimeout = 0;
conn.Open();
TimeOuts();
s = cmd.ExecuteReader();
try
{
if (!s.Read())
{
LockTable("Actor", conn);
nAct = Doc.GetNewIdActor();
sqlString = "Insert into Actor (IdActor,NameActor,dob,Link,alive,Gender,LifeStory,dod,Completed) values (" +
nAct.ToString() + ",'" + Quotes(Doc.refActors[0][0]) + "','" + Doc.refDateOfBirth + "','" + Doc.refActors[2][0] +
"'," + ((Doc.refDateOfDeath == "1900-01-01") ? "1" : "0") +
"," +
((Doc.rref == "actor") ? "1" : "0") + ",'" +
Quotes(Doc.refActors[3][0]) + "','" + Doc.refDateOfDeath + "',0);";
conn.Close(); <------------ Timeout here
cmd = new MySqlCommand(sqlString, conn);
cmd.CommandTimeout = 0;
conn.Open();
TimeOuts();
cmd.ExecuteNonQuery();
UnlockTable();
}
else
{
sqlString = "Update Actor set dob='" + Doc.refDateOfBirth + "',Link='" + Doc.refActors[2][0] + "',alive=" +
((Doc.refDateOfDeath == "1900-01-01") ? "1" : "0") + ",LifeStory='" +
Quotes(Doc.refActors[3][0]) + "',dod='" + Doc.refDateOfDeath + "' where Link='" +
Doc.refActors[2][0] + "';";
conn.Close();
cmd = new MySqlCommand(sqlString, conn);
cmd.CommandTimeout = 0;
conn.Open();
TimeOuts();
cmd.ExecuteNonQuery();
}
}
catch (MySqlException e9)
{
UnlockTable();
Console.WriteLine(e9.Message);
}
sqlString = "Select * from ActorByRefMovie where IdActor=" + nAct.ToString() + " and MovieId=" +
nRefMovie.ToString() + ";";
conn.Close();
cmd = new MySqlCommand(sqlString, conn);
conn.Open();
s = cmd.ExecuteReader();
if (!s.Read())
sqlString = "Insert into ActorByRefMovie (IdActor,MovieId,Act) values(" + nAct.ToString() + "," +
nRefMovie.ToString() + ",'" + Quotes(Doc.refActors[1][0]) + "');";
else
sqlString = "Update ActorByRefMovie set Act='" + Quotes(Doc.refActors[1][0]) + "' where IdActor=" +
nAct.ToString() + " and MovieId=" + nRefMovie.ToString() + ";";
conn.Close();
cmd = new MySqlCommand(sqlString, conn);
conn.Open();
cmd.ExecuteNonQuery();
Doc.refActors[0].RemoveAt(0);
Doc.refActors[1].RemoveAt(0);
Doc.refActors[2].RemoveAt(0);
if (Doc.refActors[3].Count > 0)
Doc.refActors[3].RemoveAt(0);
// ReclaimMemory();
sStatus = "Fetching refcast completed";
}
The net_timeout are set by
private void TimeOuts()
{
MySqlCommand cmd5;
cmd5 = new MySqlCommand("set net_write_timeout="+Timeout.Infinite.ToString()+"; set net_read_timeout="+Timeout.Infinite.ToString(), conn); // Setting tiimeout on mysqlServer
cmd5.ExecuteNonQuery();
}
Link is the primary key
NameActor is a unique index ascending.
Questions:
Is System.TimeoutException on IO releated to the .Net driver. It is not a MySqlException. But I have set the timeouts to infinite.
The timeout happens on the indicated Close() statement.
In debugging mode it is less likely to happen, even with 2-3 relaese instances running at the same time.
Why does it happen on the Close statement ?
Thanks for any help.
Lambert
I am Adding a record to a (large?) 700,000+ records database.
Many times I get a System.TimeoutException on IO.
I have set MySqlCommand.CommandTimeout to 0,
I have set net write timeout and net read timeout to Timeout.Infinite
The following code-snippet is what is executed at the time.
if (sStatus == "Fetching refActor completed")
{
if (Doc.refActors[3].Count == 0)
Doc.refActors[3].Add("");
int nAct = 0;
if (Doc.refActors[2][0] != "")
sqlString = "Select * from Actor where Link='" + Doc.refActors[2][0] + "';";
else
sqlString = "Select * from Actor where NameActor='" + Quotes(Doc.refActors[0][0]) + "';";
conn.Close();
cmd = new MySqlCommand(sqlString, conn);
cmd.CommandTimeout = 0;
conn.Open();
TimeOuts();
s = cmd.ExecuteReader();
try
{
if (!s.Read())
{
LockTable("Actor", conn);
nAct = Doc.GetNewIdActor();
sqlString = "Insert into Actor (IdActor,NameActor,dob,Link,alive,Gender,LifeStory,dod,Completed) values (" +
nAct.ToString() + ",'" + Quotes(Doc.refActors[0][0]) + "','" + Doc.refDateOfBirth + "','" + Doc.refActors[2][0] +
"'," + ((Doc.refDateOfDeath == "1900-01-01") ? "1" : "0") +
"," +
((Doc.rref == "actor") ? "1" : "0") + ",'" +
Quotes(Doc.refActors[3][0]) + "','" + Doc.refDateOfDeath + "',0);";
conn.Close(); <------------ Timeout here
cmd = new MySqlCommand(sqlString, conn);
cmd.CommandTimeout = 0;
conn.Open();
TimeOuts();
cmd.ExecuteNonQuery();
UnlockTable();
}
else
{
sqlString = "Update Actor set dob='" + Doc.refDateOfBirth + "',Link='" + Doc.refActors[2][0] + "',alive=" +
((Doc.refDateOfDeath == "1900-01-01") ? "1" : "0") + ",LifeStory='" +
Quotes(Doc.refActors[3][0]) + "',dod='" + Doc.refDateOfDeath + "' where Link='" +
Doc.refActors[2][0] + "';";
conn.Close();
cmd = new MySqlCommand(sqlString, conn);
cmd.CommandTimeout = 0;
conn.Open();
TimeOuts();
cmd.ExecuteNonQuery();
}
}
catch (MySqlException e9)
{
UnlockTable();
Console.WriteLine(e9.Message);
}
sqlString = "Select * from ActorByRefMovie where IdActor=" + nAct.ToString() + " and MovieId=" +
nRefMovie.ToString() + ";";
conn.Close();
cmd = new MySqlCommand(sqlString, conn);
conn.Open();
s = cmd.ExecuteReader();
if (!s.Read())
sqlString = "Insert into ActorByRefMovie (IdActor,MovieId,Act) values(" + nAct.ToString() + "," +
nRefMovie.ToString() + ",'" + Quotes(Doc.refActors[1][0]) + "');";
else
sqlString = "Update ActorByRefMovie set Act='" + Quotes(Doc.refActors[1][0]) + "' where IdActor=" +
nAct.ToString() + " and MovieId=" + nRefMovie.ToString() + ";";
conn.Close();
cmd = new MySqlCommand(sqlString, conn);
conn.Open();
cmd.ExecuteNonQuery();
Doc.refActors[0].RemoveAt(0);
Doc.refActors[1].RemoveAt(0);
Doc.refActors[2].RemoveAt(0);
if (Doc.refActors[3].Count > 0)
Doc.refActors[3].RemoveAt(0);
// ReclaimMemory();
sStatus = "Fetching refcast completed";
}
The net_timeout are set by
private void TimeOuts()
{
MySqlCommand cmd5;
cmd5 = new MySqlCommand("set net_write_timeout="+Timeout.Infinite.ToString()+"; set net_read_timeout="+Timeout.Infinite.ToString(), conn); // Setting tiimeout on mysqlServer
cmd5.ExecuteNonQuery();
}
Link is the primary key
NameActor is a unique index ascending.
Questions:
Is System.TimeoutException on IO releated to the .Net driver. It is not a MySqlException. But I have set the timeouts to infinite.
The timeout happens on the indicated Close() statement.
In debugging mode it is less likely to happen, even with 2-3 relaese instances running at the same time.
Why does it happen on the Close statement ?
Thanks for any help.
Lambert