ITQuants blog

Sophis Risque: how to use the CSRInstrument::MultiSave method?

Jul 30

Written by:
7/30/2013 8:39 AM  RssIcon

After debugging some code, in order to know why the methods CSRInstrument::GetInstance and gApplicationContext->GetCSRInstrument returned null in some cases, I discovered that the method CSRInstrument::MultiSave was used badly. In this case, the instrument was duplicated using the Clone method, setting the instrument code using the SetCode to 0, and using reserveCode in relationship with GetNewCode. The insertion into database was done using the CSRInstrument::MultiSave with a pmModification flag.

Once the instrument inserted in transaction mode, the program tried to book a deal on it, using the CSRTransaction class. Of course, several software triggers already exist, and tests using the new instrument reference id in order to retrieve the CSRInstrument object through GetInstance or GetCSRinstrument are done. These methods returned null pointers, and no test was done on it, generating a crash of the application.

After analysis, the call of CSRinstrument::MultiSave didn't respect the recommandations made by Sophis concerning this method:

It is not committed nor rolled back. You must do this when all of your data is saved.
It is not sent to the other workstations. You must do it by messages - ExecuteAll()

The call of CSREventVector::ExecuteAll was not done. This method inserts the new instrument in the local memory cache on the current process which makes the insertion. The resolution of the bug was done as follow:

adding test in order to not use null pointers :)

adding the call to ExecuteAll

Tags:
Categories: Sophis

Search blog