I have a suggestion to improve the usability of perlmonks.org. The recent availability problems have highlighted an issue with CGI processes being chopped. If this is happening part way through processing a posted form, partial results are ensuing.

At the browser end, we see this as a time out. Most of us when we see this, click refresh to re-post. This is resulting in duplicate entries.

My proposed solution is to add a couple of hidden fields:

<input type="hidden" name="sessionID" value="12345"> <input type="hidden" name="requestID" value="45678">

The sessionID is generated when you log in - may have a special value for the Anonymous Monk.

The requestID is bumped up for each input form.

The CGI script will be able to detect duplicates and know what to do. If the entries are identical, it throws one away (it doesn't matter which as they are identical. Otherwise, it takes the longer entry, as this is more likely to be complete.

See also How do I decode a CGI form?, and idempotent definition

Replies are listed 'Best First'.
Re: Adding idempotency to the monastery
by vladb (Vicar) on Feb 26, 2002 at 21:20 UTC
    It happend to me a few times where I ended up making duplicate post (I felt so ashamed ;/). I guess injecting a special 'unique' requestID for each potential post may be one good way of avoiding adding a duplicate post. However, i'm not sure if it would work for all cases. For example, for some of my lenghtier posts I would type my message up in xemacs and copy/paste it over to 'new node' form for posting. This also is helpful when perlmonks.org post process breaks in the middle of its job (such as when the server is timed out or etc). In such cases, I simply go back to empty form and repeat my copy/paste/submit steps. There was one particular occassion where I produced a duplicate post that way.

    My thinking is this could have been eliminated had the server checked whether I had already made a post bearing, say, similar title within a short time span (say 1 hour or so). I'm not sure if this check should 'cause any further server loads, from where I sit it shouldn't ;-).

    Also, there's yet another issue that may crop up with hidden form fields. This is especially true for server scripts/pages that are marked to never be cached. In this case, hitting 'Back' button would still cause the page to refresh (effectively loosing previous data). Therefore, we might have to consider including the requestID value right inside the URL. This way the URL is always there, and everyone is happy ;).


    "There is no system but GNU, and Linux is one of its kernels." -- Confession of Faith