2

Closed

Web application raised error after restart memcacheD

description

I'd make the code as below; It works fine in normal situation. But, I restart memcacheD as failure situation. Then, it raised error. So, I restart my IIS, then it's OK.
Please let me know the resolution.
 
        int top_count = 10;
        string key = "keyname" + top_count.ToString();
 
        object ds = DistCache.Get(key);
        if (ds == null)
        {
            SqlConnection cn = new SqlConnection(connectionString);
            cn.Open();
 
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = cn;
            cmd.CommandText = "dbo.sp";
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandTimeout = 0;
            SqlParameter param = new SqlParameter("@top_count", SqlDbType.Int);
            param.Value = top_count;
 
            cmd.Parameters.Add(param);
            SqlDataAdapter adp = new SqlDataAdapter(cmd);
 
            DataSet dsSet = new DataSet();
            adp.Fill(dsSet);
 
            bool b = DistCache.Add(key, dsSet, 3000);
            if (b == false)
                Response.Write("Error");
 
            cmd.Connection = null;
            cn.Close();
 
            ds = DistCache.Get(key);
        }
        Response.Write(((DataSet)ds).GetXml());
Closed Aug 11, 2010 at 3:09 PM by fahadaz

comments

fahadaz wrote Sep 11, 2009 at 1:43 PM

The problem is with the sockets that are used by memcached client. If memcached dies out. Those sockets will be open until the time out value set in the
web.config is reached. If this value is set as a higher number like a couple of minutes or more it will be stuck till then and after that server will be marked as
dead. If there is only one memcached server in the pool then memcached provider would not work anymore.
  • Fahad