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.

Comments

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…

First Hybrid Open-Source RDBMS Powered By Hadoop and Spark

Splice Machine is a novel attempt to merge the best parts of the traditional relational database management systems and their NoSQL counterparts with distributed and in-memory computing based on Hadoop and Spark.

Traditional RDBMS find it tough when faced with massive amounts of data, which they typically handle by scaling up, albeit expensively. Another side effect of the sheer volume of data accumulating from the likes of social media and mobile devices, is that OLTP and OLAP queries carry high performance hits that subsequently have detrimental effects on real time analysis and instant decision making.

full article on i-programmer

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