Can a Redshift stored procedure executing dynamic SQL use error exception handling to recover work & continue processing?

0

Within a Redshift stored procedure based solution, a table driven data quality assessment feature executes many dynamic SQL statements. In order to support the more complex rule definitions, users can pre-register an SQL statement that feasibly may contain syntax errors leading to a run time exception!

An EXCEPTION WHEN OTHERS clause can catch the failure however because the exception is rethrown on exiting the sub-procedure all the (useful) work performed prior to the exception is rolled back :-(.

Is it possible somehow, having "handled" the exception satisfactorily, to prevent the rethrow (and subsequent rollback) so the procedure can continue evaluating the remaining rules?

My guess this is technically precluded because Redshift stored procedure doesn't support sub-transactions ... and having pre-emptively cancelled the running transaction in order to commence the exception handler transaction - there is no way back? I expect using COMMIT WORK before each EXECUTE only addresses part of the problem given the caller will abend after the (first) exception occurs!

Is there a "state of the art" pattern known that can assist in cracking this use case?

已提問 2 年前檢視次數 1217 次
1 個回答
0
已接受的答案

Thank you for posting your question, as of now Redshift doesn’t support the behavior you are trying to incorporate.
[Trapping errors] (https://docs.aws.amazon.com/redshift/latest/dg/stored-procedure-trapping-errors.html)
[Transaction Management] (https://docs.aws.amazon.com/redshift/latest/dg/stored-procedure-transaction-management.html)

Having said that I have raised a feature request with the service team on your behalf. While I am unable to comment on if/when this feature may get released, I request you to keep an eye on our [What's New] (https://aws.amazon.com/new/?whats-new-content-all.sort-by=item.additionalFields.postDateTime&whats-new-content-all.sort-order=desc&awsf.whats-new-analytics=*all&awsf.whats-new-app-integration=*all&awsf.whats-new-arvr=*all&awsf.whats-new-blockchain=*all&awsf.whats-new-business-applications=*all&awsf.whats-new-cloud-financial-management=*all&awsf.whats-new-compute=*all&awsf.whats-new-containers=*all&awsf.whats-new-customer-enablement=*all&awsf.whats-new-customer%20engagement=*all&awsf.whats-new-database=*all&awsf.whats-new-developer-tools=*all&awsf.whats-new-end-user-computing=*all&awsf.whats-new-mobile=*all&awsf.whats-new-gametech=*all&awsf.whats-new-iot=*all&awsf.whats-new-machine-learning=*all&awsf.whats-new-management-governance=*all&awsf.whats-new-media-services=*all&awsf.whats-new-migration-transfer=*all&awsf.whats-new-networking-content-delivery=*all&awsf.whats-new-quantum-tech=*all&awsf.whats-new-robotics=*all&awsf.whats-new-satellite=*all&awsf.whats-new-security-id-compliance=*all&awsf.whats-new-serverless=*all&awsf.whats-new-storage=*all) and Blog pages for any new feature announcements.

支援工程師
已回答 2 年前
AWS
專家
已審閱 2 年前
  • Thanks - I will monitor the blog and research a work-around / mitigation strategy until then :-). I anticipate this might require engineering for sub-transactions to work - which if provided would greatly enhance stored procedure based applications.

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南