Chloe icon indicating copy to clipboard operation
Chloe copied to clipboard

Command queuing/ how to make thousands of queries?

Open MeisterLone opened this issue 4 years ago • 2 comments

Hi

I have been using Chloe very successfully, well done. However, if I want to queue lots of simultaneous queries I run into some trouble

       public void deleteAttributes()
        {
            foreach (var attribute in Products.attributes)
            {
                _ = Task.Run(() =>
                {
                    //remove from database
                    _ = Task.Run(() => DB_DeleteProductAttribute(attribute).Wait());
                });
            }
        }
        public async Task<bool> DB_DeleteProductAttribute(product_attribute attribute)
        {
            using (IDbContext context = new MySqlContext(base.GetConnectionMain))
            {
                var rowsChanged = await context.DeleteAsync(attribute);
                return rowsChanged > 0;
            }
        }

It will do some requests but then I quickly run into "All pooled connections are in use" exception inside Chloe. I want deleteAttributes to execute quickly and then the queries should be executed in the background by tasks.. this code used to work fine with Dapper, I dont know how to fix it and would appreciate some advice.

MeisterLone avatar Jun 30 '20 20:06 MeisterLone

What is the configured connection pool value in the database connection string?

shuxinqin avatar Jul 01 '20 01:07 shuxinqin

@shuxinqin I dont have any connection pool value currently configured in the connection string. However shouldnt it use whatever the max pool value is and queue the rest of the commands?

MeisterLone avatar Jul 01 '20 08:07 MeisterLone