firebird icon indicating copy to clipboard operation
firebird copied to clipboard

Increase limit for "Too many concurrent executions of the same request"

Open AkulovNikolay opened this issue 1 year ago • 12 comments

Good afternoon I have a procedure that needs to be recursively executed many times. This is not an endless loop. Is it possible to disable protection or increase the limit on the number of executions for "Too many concurrent executions of the same request"?

AkulovNikolay avatar Jan 15 '24 08:01 AkulovNikolay

No without deep engine modification.

But as a rule of thumb every recursion can be turned into iteration. You should consider this way. Perhaps using a temporary table to collect results.

aafemt avatar Jan 15 '24 10:01 aafemt

I need to go up the tree of people from one person to a higher level. And there can be more than 1000 such attachments. Even if I collect record IDs into a temporary table, I will still have to face this error. Or is there some other mechanism?

AkulovNikolay avatar Jan 15 '24 10:01 AkulovNikolay

Did you try to use WHILE loop?

aafemt avatar Jan 15 '24 10:01 aafemt

I'm using a procedure that receives an ID of record as an input parameter. If there is a record at a higher level, then I call the same procedure inside the procedure with the identifier of the record that is higher.

Thanks! I will try to use WHILE loop.

AkulovNikolay avatar Jan 15 '24 11:01 AkulovNikolay

This trivial task don't need recursion:

WHILE (ID IS NOT NULL) DO
 BEGIN
  RESULT = ID;
  SELECT BOSS FROM PEOPLE WHERE ID=:ID INTO :ID;
 END

aafemt avatar Jan 15 '24 11:01 aafemt

Thanks a lot!

AkulovNikolay avatar Jan 16 '24 01:01 AkulovNikolay

That limit serves two goals: (1) prevents infinite (or finite but risky due to possible stack overflow) recursion and (2) prevents resource leaks (query is not released but executed again and again - we had this issue for some system requests in the past -- due to logic bugs). Now it strikes back for real user queries too -- due to compiled statement cache. Perhaps we need to distinguish between these cases and maybe have different limits for them.

dyemanov avatar Feb 06 '24 13:02 dyemanov

Isn't it just a matter of resetting of the counter during retrieval from the cache?

aafemt avatar Feb 06 '24 13:02 aafemt

In the case reported, I guess by some reason in the user code there are many active requests.

Can you show the code involved to cause the error @AkulovNikolay ?

asfernandes avatar Feb 06 '24 15:02 asfernandes

I am gettinng the same error message. Our C# Code uses the classes from '''FirebirdSql.Data.FirebirdClient''' to call a procedure for generating primary keys many times within one transaction to add a lot of rows to a table. So now I wonder how the "concurrent executions of the same request" are counted. Is this counted within one transaction or is there some other "concurrent execution" going on that I do not understand?

Knitschi avatar Jul 31 '24 11:07 Knitschi

It is not about transactions. It is about many active instances of the same requests withing same attachment. Make sure you close cursor (release statement? I don't use C# and may be wrong in details) after use. Consider to ask in https://groups.google.com/g/firebird-net-provider and show your code there.

hvlad avatar Jul 31 '24 14:07 hvlad

It is not about transactions. It is about many active instances of the same requests withing same attachment. Make sure you close cursor (release statement? I don't use C# and may be wrong in details) after use. Consider to ask in https://groups.google.com/g/firebird-net-provider and show your code there.

Thanks for the reply. I am not deep enough into Firebird or the Firebird-Net-Provider to know when a request is activated and deactivated. As a workaround I changed our code that it does not ran as many of the procedure calls which fixed the problem for now. I try to find the strength to bring the problem up in the Firebird-Net-Provider group.

Knitschi avatar Aug 02 '24 06:08 Knitschi