From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.2 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 74557BC0A for ; Fri, 1 Dec 2006 20:13:47 +0100 (CET) Received: from wr-out-0506.google.com (wr-out-0506.google.com [64.233.184.237]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id kB1JDkSi024796 for ; Fri, 1 Dec 2006 20:13:47 +0100 Received: by wr-out-0506.google.com with SMTP id 71so1135481wri for ; Fri, 01 Dec 2006 11:13:46 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=Pcgmjv+eEe+RGCDVFJTQJwTiXlKNUYBW1pT2TliLglK630z4jGpWZov2Xn2A5/k6ZjWI0zmtMe/SNnc783H0R69i5gEZ4PYPh0G4ndGinRazTV0ltxPXR5oILFgKBclLiMHU3+VI9T4vD63nXsSsb/y2P7fcjwtfDoSkD5MOPLQ= Received: by 10.90.78.9 with SMTP id a9mr5640203agb.1165000426091; Fri, 01 Dec 2006 11:13:46 -0800 (PST) Received: by 10.90.115.2 with HTTP; Fri, 1 Dec 2006 11:13:46 -0800 (PST) Message-ID: <875c7e070612011113m7bff7191off88cfda5c708c9e@mail.gmail.com> Date: Fri, 1 Dec 2006 14:13:46 -0500 From: "Chris King" To: "Neal Wang" Subject: Re: [Caml-list] Can GC be BLOCKed? Cc: "The Caml Trade" In-Reply-To: <1965df800612011053x1c442d31if3ef14c5f87ba76d@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <1965df800611291633q4f615df5qaa43dc967ba87d56@mail.gmail.com> <1FB91514-18D1-4502-AF67-C1003EB8636B@mac.com> <1965df800611301607g330f5517saeba25d40c3321ca@mail.gmail.com> <20061201091932.GA29517@furbychan.cocan.org> <1965df800612011053x1c442d31if3ef14c5f87ba76d@mail.gmail.com> X-j-chkmail-Score: MSGID : 45707EEA.000 on discorde : j-chkmail score : X : 0/20 1 X-Miltered: at discorde with ID 45707EEA.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; o'caml:01 wrote:01 caml-list:01 functions:01 functions:01 finalization:01 finalization:01 data:02 data:02 objects:02 locks:03 finalise:04 finalise:04 loading:05 reachable:05 On 12/1/06, Neal Wang wrote: > The problem is that: > When an object is being loaded through an "sql" select stmt, GC is > then invoked to reclaim memory which will in turn call finalise > functions to store some objects into db. At this moment, the db has > been locked by the select stmt, and the storing procedure fails. The > problem is due to sqlite3 doesn't provide row level locks. A simple > solution is to prevent GC from calling finalise functions whenever we > are loading an object into memory. Have you thought about simply postponing the write-back until the database is unlocked? If the finalization function finds that the database is locked, it can place the data to be written into a global queue. (This is possible because finalization functions in O'Caml are allowed to make their data reachable again.) This queue can then be flushed when the database is unlocked. You could easily extend this to support queueing of any operation by queueing functions instead of data. Hope this helps! - Chris King