I am trying to create a page (using db_persist) and then edit that same page (again using db_persist) in the same script. I believe I am running into issues because of a related page I have setup.
The basic flow is like this.
When I make the db_persist edit call I get the error "Duplicate entry 'XXX' for key 'PRIMARY'". I tried adding a php sleep call after the initial db_persist create call, to give the database time to catch up, but it didn't seem to help.
Additionally, when this happens, the record created by the first db_persist call seems to disappear. I know it existed, even if only temporarily, because the API I am passing it to records it.
I'm suspecting SQL transaction based issues, but don't know the Couch database code well enough to be sure.
Any help would be greatly appreciated.
Stephen
The basic flow is like this.
- Code: Select all
<db_persist _mode='create' related_page=related_page_id>
<cms:set tran_id=k_last_inserted_id 'global' />
</cms:db_persist>
<cms:external_api_call invoice=tran_id /> //Sets api_tran_date variable
<cms:db_persist _mode='edit' _page_id=tran_id tran_date=api_tran_date>
//Some code here to handle errors and such
</cms:db_persist>
When I make the db_persist edit call I get the error "Duplicate entry 'XXX' for key 'PRIMARY'". I tried adding a php sleep call after the initial db_persist create call, to give the database time to catch up, but it didn't seem to help.
Additionally, when this happens, the record created by the first db_persist call seems to disappear. I know it existed, even if only temporarily, because the API I am passing it to records it.
I'm suspecting SQL transaction based issues, but don't know the Couch database code well enough to be sure.
Any help would be greatly appreciated.
Stephen