Forum OpenACS Q&A: Help! Object Creation Problems!

Collapse
Posted by Roger To on
Hi All,

i have no idea what exactly is the problem, but i occassionaly can't create objects.
I'm building a catalog system and need to be able to create categories, each category i create is a new object. I can create objects on most instances, however occassionally, the system crashes and does not allow me to create a new category even though i haven't created it before!!! I've sifted through the error log file and come up with these two errors:

Error: return: failed to redirect '404': exceeded recursion limit of 3

and

Error: Ns_PgExec: result status: 7 message: ERROR:  Cannot insert a duplicate key into unique index acs_objects_pk

This is despite the fact that the category has not been created before, keeping in mind that the system does still allow me to create categories, however this error occassionally occurs.

Thanks for any help

Collapse
Posted by Simon at TCB on
Hi,

Thats not a lot of information to go on but.....

99 times out of 100, when some gets this problem its usually due to simple code mistake, or a browser caching problem.

Evry object in the system is given a unique object_id and has an entry in the acs_objects table.

Very often, one writes bit of code that does something like

set new_object_id [db_nextval acs_object_id_seq]

This is done in page A lets say, that passed to some other page lets say pages B, for use in inserting at that point.

(I should add this is a bad idea, but does exist)

What that (and similar things) ultimately means is theres a chance for the browser to have cached that object_id value, so a reload, or a back button etc,,. can cause the entry to be re-used, and hence the complaint about unique key violation.

Its also worth noting that this circumstance can often be compounded by caching firewalls. Is it possible your network has such a firewall that may be caching previously used values?

Of course it may just be bad code in the package thats hanging on to an object_id and attempting to insert it again.. dunno without more detail.

Hope that helps

Collapse
Posted by Robert Locke on
I think Simon's on the right track... sounds like a potential caching issue. Are you using a caching proxy server? Can you replicate the problem when you connect directly to the web server?

Check out this thread for more information on this:

https://openacs.org/forums/message-view?message_id=27295

We had a similar issue in the past and it was solved by placing the following two lines in our master template:

ns_set put [ns_conn outputheaders] "Cache-Control" "private"
ns_set put [ns_conn outputheaders] "Expires" "Thu, 01 Jan 1998 07:00:00 GMT" (or some date in the past)

Hope this helps...