Skip to main content

Ingres resource limiting : Part3 (inquire_ingres)

The other option left was to capture the error from inside the 4GL code by checking the inquire_ingres error number after each sql statement (which does already,but I had to tweak it to also check for the specific error) and act upon it.

Since all code is grouped in frskeys (meaning that the user must press a key for the code to be activated) the whole error handling had to be shifted inside the frskey code.

Inside the frskey code there can be multiple sql statements and each one can trigger the exception.It might not be the first or second statement but it could be the 5th statement in the chain of execution. Furthermore the 'set maxio' directive is the first statement to be executed when the key is pressed,and must reset back to 'set nomaxio' on exiting or one of the conditions described later are met.

So every sql statement must be checked and the following was added after each one:
inquire_ingres (h_rowcount=rowcount,h_errorno=errorno,h_querytext=querytext,h_errortext=errortext);

When the query requires more resources than permitted then the error is captured and 'propagated' to another 4GL frame which contains the code that does the handling.
That frame prompts the user that the query is too heavy and if execution should continue, despite. If the user answers 'no' then a rollback is issued and the limiter is deactivated with 'set nomaxio' since the directive is session wide and if not deactivated it would hinder the user's work flow.

The problem was that if the user answers 'yes' ,thus ignoring the message and opting to continue with the execution, the code inside the frskey had to be repeated like the user pressing the key another time since the limiter has refused to run the query that triggered the exception and the whole frskey code has to be re-executed ,this time with the limit control deactivated.
Because letting the user re-press the key was not an option since allowing the user the margin for error means that the error will be made eventually,the whole frskey code was wrapped into two labeled while loops.The first loop had the control over if and when the process would be repeated and the inner loop was in charge of the executing the preexisting frskey code.Inside the inner loop each sql statement was been inquired with inquire_ingres and if an error was to occur then the error handling frame was to be called where it would check for if the error equals the generic number 36100 signifying that the resource limit has been exceed.
The handling procedure would then log the actual sql query that gave the error away and the error text (E_QE0203 The estimated nummber of IO requests to run this query (141)\n exceeds the IO limit (80) established for this session. The query is aborted with a fatal error. ) plus the current time and user terminal.
Then it would prompt the user as to continue or not.If not, 'set nomaxio' is reset and no further action is performed hence the user is free to continue with his work.
If the answer is 'yes' then the inner loop is exited and the outer loop re-executes the frskey code from the beginning but this time with 'set nomaxio' set so everything executes fine like it would normally do.

The ESQL error handler called by iiseterr() was used as well as to suppress the default runtime error messages appearing on the user's screen,so he is not introduced to the fact that an error occurred. All he sees is just a prompt for action.


Popular posts from this blog

Serverless JavaScript

We recently joined in an interesting two-hour long conversation about Serverless JavaScript led by Steve Faulkner of Bustle who answered questions on Bustle, the Shep framework, the mindset behind the AWS Lambda infrastructure, and related topics.

The discussion took place on the Sideway conversation-sharing platform on January 6th. Here we present the best takeaways from the session which really should be taken notice of by anyone working on AWS.

Steve Faulkner:
At Bustle we serve over 50 million unique readers per month through a "serverless" architecture based on AWS Lambda and Node.js.  Of course there are still servers but we don't manage them. This shift has allowed us to develop products faster and decreased the cost of our infrastructure. I'll answer any questions about how we made this transition and how it has worked out. I'll also discuss some of the tools and best practises including our open source framework shep

Eran Hammer:
When would you…

Export your Wunderlist tasks with XPath

As brought up in this ProductHunt thread, the news is that Wunderlist is going to be deprecated in favor of the new Microsoft To-Do note taking platform.

This is what Wunderlist support had to say in response to my inquiry on Wunderlist's future:

"Now that the next evolution of Wunderlist is here, in the form of Microsoft To-Do Preview (, Wunderlist will no longer receive any updates or bug fixes and will eventually be retired. It won’t happen in the next few months and we’ll be sure to give our users plenty of notice beforehand. In the meantime, you can continue to use Wunderlist normally. Of course, we’d also love for you to try To-Do and let us know how you like it – and how we can improve it. While Wunderlist will continue to exist alongside To-Do for the time being, support for Wunderlist will eventually be removed. Not to worry, though! We will inform all Wunderlist users prior to shutting down service. You'll have ample opport…

Google's Cloud Spanner To Settle the Relational vs NoSQL Debate?

Cloud Spanner is a new proposition for database as a service that emphatically offers "Relational with NoSQL scaling". Will Google come to dominate yet another market?

Once upon a time there was only one kind of database management system, the RDBMS, "R" for relational. Despite its resilience and trustworthiness, it had its shortcomings; it did not scale well, and the relational model it served proved inadequate in the dawn of the Big Data era for handling massive amounts of schema-less, unstructured data.
For this and a few other reasons, a new breed of DBMS's emerged, one that could handle the avalanche of big data, based on the notion of the key-value pair, and doing so by scaling horizontally. But, in order to become versatile, this new breed of management systems had to forgo the safety of the ACID and the cosiness of SQL, both long term partners of the relational model. full article on i-programmer