the asp.net core MVC report error after certain times of query to the mysql database (on Ubuntu 14.04/16.04) with the following message: "The configured user limit (128) on the number of inotify instances has been reached." It can be identified that the error was raised because of the controller opened too many files and exceeded the limits of iNotify setting (in the /proc/sys/fs/inotify/max_user_instances). But I was just baffled when the ASP.NET opened files on each http request and why it doesn't close the file properly? Any one encounted this issue too? Remarks: I was using Mysql.data.core and mysql.data.entityframeworkcore provider.
private static string classiferstring = "sports,outdoor,startup,pets,child,adult,elderly";
[AllowAnonymous]
[HttpGet]
public async Task<object> Classify([FromQuery] string classifyword)
{
string[] classifers = classiferstring.Split(',');
if (!classifers.Contains(classifyword))
{
return new
{
status = 0,
info = "WrongClassifier",
Data = ""
};
}
try
{
var predata = await (from d in _context.descriptor
join a in _context.combination on d.ID equals a.ID
select new ProductsVM
{
CREATETIME = a.CREATETIME,
ID = a.ID,
COMPANY = a.COMPANY,
NAME = a.NAME,
PRICE = a.PRICE,
TYPE = a.TYPE,
HEADPHOTO = a.HEADPHOTO,
REMARK = a.REMARK,
Tags = d.Tags,
Classifier = d.Classifier,
OriginName = d.OriginName,
Briefing = d.Briefing
}).ToListAsync();
var data = (from x in predata
where x.Classifier.Contains(classifyword.ToLower())
select x).ToList();
if(predata.Count<=0)
{
return new
{
status = 2,
info = "NoResult",
Data = ""
};
}else
{
return new
{
status = 1,
info = "Success",
Data = data
};
};
}
catch(Exception e)
{
return new
{
status = 0,
info = "Error",
Data = e.Message
};
}
}
Please notice the exception was raised only in the try/catch code block instead of immediately after the action is invokded.
Many thanks if anyone has some clue to resolve this problem.
MySqlConnection
and except for that, is agnostic about any database. i.e. pomello mysql driver doesn't have these issues with connection being closed after each query, which clearly indicates the bad quality of Oracles MySQL Provider for EF Core – Hasa