From b988ccea014a5238bd13adcc7c808723b1ef16d1 Mon Sep 17 00:00:00 2001 From: rich Date: Thu, 7 Dec 2006 15:46:54 +0000 Subject: [PATCH] Lock pages table during editing to avoid bogus 404 errors appearing briefly when a page is edited. --- scripts/lib/cocanwiki_pages.ml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/lib/cocanwiki_pages.ml b/scripts/lib/cocanwiki_pages.ml index 4d17f62..baba26e 100644 --- a/scripts/lib/cocanwiki_pages.ml +++ b/scripts/lib/cocanwiki_pages.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: cocanwiki_pages.ml,v 1.11 2006/08/17 09:11:31 rich Exp $ + * $Id: cocanwiki_pages.ml,v 1.12 2006/12/07 15:46:54 rich Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -210,12 +210,12 @@ let save_page r dbh hostid ?user model = page_emails_url_cn, links_from_cn, recently_visited_url_cn deferred"; - (* Mark the old page as deleted. NB. There is a small race - * condition here because PostgreSQL doesn't do isolation - * properly. If a user tries to visit this page between the - * delete and the creation of the new page, then they'll get - * a page not found error. (XXX) + (* Lock the pages table to avoid bogus 404 errors. The + * lock is released at the end of the current transaction. *) + PGSQL(dbh) "lock table pages"; + + (* Mark the old page as deleted. *) PGSQL(dbh) "update pages set url_deleted = url, url = null where hostid = $hostid and id = $model_id"; -- 1.8.3.1