Quantcast
Viewing all articles
Browse latest Browse all 2504

Custom Processes CPHP saving new answer is sometimes slow, or hangs (11 Comments)

Topic by RobertP

Content

I am using custom processes for the incident_update event.  Given a certain status, the php code creates a new answer object, fills in some fields, copies the incident thread notes to the answer question, and saves the new answer.  

Sometimes, the new answer gets created, but is relatively slow.  But subsequent new answer saves happen relatively quickly.

For example - I have a test incident with 5 thread notes.  In the log entries below, I copied the test incident to a new incident and saved.  I then changed the incident status to Submit PR (which will cause the event code to create the answer), turned off Send on Save, and saved the incident again.  I did this three times in a row, which should create a new answer with the identical data.  As you can see in the first cycle, it took almost 2.79 seconds to save the new answer.  But the second and third cycles, it only took ..32 seconds and .13 seconds for the answer save.  

Although I don't catch any exceptions and can't find any log messages anywhere, I think this delay sometimes causes the incident_update event to exceed 5 seconds and it fails to complete my incident_update event handler.

Is this initial delay caused by some sort of caching of the answer table?  i.e. the first save doesn't have a cached answer table?

Is there any way I could speed up this initial save?

Could this be concurrent transaction problem?  i.e. the answer table locked for another answer create or answer update?  Do I need to worry about table locking or concurrency with custom processes?

By the way, after the answer is created, the code creates a task entry to link the incident to the answer.

12-19-2012 14:24:05.55 Incident_Update Event Handler == Incident 121219-000001 / 63257 ==
14:24:05.57  Getting notes
14:24:05.59  Got 5 notes
14:24:05.61 Saving new answer
14:24:08.40 Saving new answer finished
14:24:08.40 Saving new task
14:24:08.42 Task created : 8978
14:24:08.42 [63257] Created new answer [12914]
 
12-19-2012 14:24:58.78 Incident_Update Event Handler == Incident 121219-000002 / 63258 ==
14:24:58.80  Getting notes
14:24:58.82  Got 5 notes
14:24:58.84 Saving new answer
14:24:59.16 Saving new answer finished
14:24:59.16 Saving new task
14:24:59.17 Task created : 8979
14:24:59.17 [63258] Created new answer [12915]
 
12-19-2012 14:26:40.10 Incident_Update Event Handler == Incident 121219-000003 / 63259 ==
14:26:40.12  Getting notes
14:26:40.13  Got 5 notes
14:26:40.15 Saving new answer
14:26:40.28 Saving new answer finished
14:26:40.28 Saving new task
14:26:40.28 Task created : 8980
14:26:40.29 [63259] Created new answer [12916]
 
Some times when this process fails, my log entries look like:
12-18-2012 23:39:49.55 Incident_Update Event Handler == Incident 121218-000037 / 64298 ==
23:39:49.84  Getting notes
23:39:49.84  Got 1 notes
23:39:49.89 Saving new answer
<< and no further log entries after this.  so I'm thinking this is hitting the 5 second limit. >>
 
The timing code around my answer save is in the code block below.
 
 

 

Code Block


Viewing all articles
Browse latest Browse all 2504

Trending Articles