Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

What is a clever way

Participant ,
Oct 07, 2010 Oct 07, 2010

To avoid cfquery timeout errors?

Note: I can't do anything to make my db or server faster because its hosted

I am looking for a CF solution to avoid throwing the user a timeout error (which presents them with a custom error page).  What I'd like to do is have some logic try to reload the page x amount of times if it hasn't loaded in say... 20 seconds.

Any ideas?

920
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Oct 07, 2010 Oct 07, 2010

idesdema wrote:

Any ideas?

<cftry><cfcatch> blocks around the offending <cfquery...> block.

Then you can have logic in the <cfcatch...> for database errors retry the code again if you like.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 07, 2010 Oct 07, 2010

I doubt you'll find a clever way, since this is a not-clever problem.

You could try something like this:

<cfset keepGoing = true>

<cfset counter = 1>

<cfloop condition="#keepGoing#">

<cfset counter = counter +1>

<cftry>

<cfquery...>

<cfset keepGoing = false>

<cfcatch>

   ....

<!--- so you don't keep trying forever -->

<cfif counter eq 3>

  <cfset keepGoing = false>

</cfif>

</cfloop>

<cfreturn queryVar>

Definitely not pretty, but it would achieve part of what you want, which is to keep trying. IT does not achieve clever, because it's kind of a dumb problem to have ... sort of like the rats in "Bad Boys II" that keep eating the drug dealer's money: "It's a stupid problem to have, but it's  a problem nonetheless".

Good luck!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 07, 2010 Oct 07, 2010

How do I make the problem not so stupid?  I hate that it happens.  When the server is running the way it should the page load

times are fractions of a second.  Then every once in awhile I run into these errors.  I don't understand.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 07, 2010 Oct 07, 2010

Not only is that not clever, it's ill advised.

If your query times out, immediately sending the same query to the db is asking for trouble.  Without going into details, let's just say that my statement is not based on something I read on the internet somewhere.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 07, 2010 Oct 07, 2010

I think I'll just live with the issue and just continue to scream and hollar at the hosting company.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 07, 2010 Oct 07, 2010
LATEST

I think that's your best approach, aside from seeking out a new host

should they refuse to be interested in helping you

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 07, 2010 Oct 07, 2010

What version of CF are you using? You could use an asynchronous gateway to spawn the query and return to the user. This would prevent the user from getting a timeout.

On the flip side... You should look at optimizing the code to prevent getting timeouts in the first place.

--Dave

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 07, 2010 Oct 07, 2010

CF9 and like I said, the pages load exceptionally fast most of the time.  These aren't complex queries nor are my pages filled with too much code and data.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 07, 2010 Oct 07, 2010

this is on a shared host, right? If so... I'm afraid there probably

isn't much you can do. Inconsistent behavior like this requires

monitoring tools, and they aren't going to give them to you.

I'd say you're now in the position where you have to push them to set

up the tools necessary to monitor and diagnose these kinds of

problems.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources