Net-Teams, Inc.
HOME | Membership Websites | SMM Solutions | CRM Solutions | Online Training Systems | Publishing | Clients | Guarantee | Log In

ColdFusion - CFTRANSACTION and Failed Inserts Due To Heavy Use

Submitted by Teo Graca | RSS Feed | Add Comment | Bookmark Me!

I was getting primary key violations, even though I was using cftransaction around the select max(id) and the insert sql statements, due to heavy application use - it is a counter used for statistical data for the entire heavily used application. So I sought out some solutions from others and found an article on "ColdFusion 9 ORM and Transactions - It Does Not Mean What You Think it Means." - Although I am looking to upgrade to ColdFusion 9 at some point, these solutions aren't currently available for the application for which I needed the solution.

The two solutions that came to mind were 1. remove the primary key from the counter table, and 2. create a transaction table that could catch the error (cftry, cfcatch) and run the insert in someone else's page load - I opted for the later.


The transaction table doesn't have a primary key, so there are no issues like this with that table. It cues insert transactions on insert failure to the other table, and retries on the next page load - I also added a way to track if it is a first try or subsequent try in the transaction table, in possible cases where the insert fails more than once. This makes sure there is just one successful subsequent retry. On a successful retry, the system deletes the entry from the transaction table.

Here's the algorithm.

if insert fails,
- load into transaction table.
on next page load from anybody, if items in transaction table,
- attempt to insert just one from the transaction table
- if failed, do leave in the transaction table
- if success, delete from transaction table

Although the transaction table has no primary key, the combination of data recorded, one being datetime with accuracy to about 1000th of a second, this approach creates a unique way to id the transaction for subsequent attempt to insert data. And, although this slows the page load down by adding another process, I don't foresee this as much of a problem.

Also, although there is only one transaction attempted per page load, the only point of failure for this technique is when more than half of the initial transactions fail, which would build data into the transaction table faster than in the original table. The current fail rate is not even close to half, more like one in 10,000, so I don't foresee this as an issue until (or if) we get to about 10 million page loads per day. Prior to that, we can simply add more servers to accomodate the heavier use.

ColdFusion 9 ORM and Transactions - It Does Not Mean What You Think it Means. - take a look at this article if you want more details.

Click for Details --> ColdFusion 9 ORM <--


Contact Us
Support and Sales
Contact Us

LinkedIn Recommendation: Martin Connell - President at Coupons for the Hungry, LLC - Teo has an amazing grasp for technology and social media. I believe he could build just about anything when it comes to programming data information and integration systems. Some of his recent programs and systems are truly groundbreaking. It is just a matter of time before his name is going to be uttered in the same breath as Google and Microsoft. Keep up the hard work Teo! - December 15, 2009, Martin was a consultant or contractor to Teo at Net-Teams, Inc.

Welcome!

Search Articles On Net-Teams

Featured [ColdFusion] Articles:
Net-Teams - Helping Businesses Prosper With Custom CRM, SMM and Online Training - Net-Teams, Inc. (NTI) is a technology and marketing firm and offers access to a core set of system t...
The Benefits Of A Membership Program For Your Website - Building membership through your website allows you to automate the acquisition of prospects and cus...
eWorkshop Hosting - The More Effective Way to Build Your Business with Online Ed - More and more companies are using eWorkshops to reach out to customers, prospects and employees. An ...
eWorkshop Publishing From Net-Teams - As many people are discovering, self-publishing is a time consuming venture, which takes time away f...
What is Social Media Management And Why Is It So Critical? - Whether or not you have a customer relationship management (CRM) system in place, there is one key r...

Related Tags (related articles): ColdFusion (3), CFTRANSACTION (1), SQL (3)