Asp.Net Core - The configured user limit (128) on the number of inotify instances has been reached

asp.net-core entity-framework-core inotify ubuntu

Question

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.

1
2
4/18/2017 2:40:21 PM

Popular Answer

The best solution I found so far is to increase the fs.inotify.max_user_instances in /etc/sysctl.conf by running this command:

echo fs.inotify.max_user_instances=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

Source: https://github.com/dotnet/aspnetcore/issues/8449#issuecomment-512275929

1
3/17/2020 6:10:28 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow