Return-Path: Delivered-To: apmail-jackrabbit-dev-archive@www.apache.org Received: (qmail 79791 invoked from network); 8 Apr 2010 08:52:55 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 8 Apr 2010 08:52:55 -0000 Received: (qmail 69687 invoked by uid 500); 8 Apr 2010 08:52:55 -0000 Delivered-To: apmail-jackrabbit-dev-archive@jackrabbit.apache.org Received: (qmail 69540 invoked by uid 500); 8 Apr 2010 08:52:54 -0000 Mailing-List: contact dev-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list dev@jackrabbit.apache.org Received: (qmail 69523 invoked by uid 99); 8 Apr 2010 08:52:53 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Apr 2010 08:52:53 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of tmueller@day.com designates 207.126.148.85 as permitted sender) Received: from [207.126.148.85] (HELO psmtp.com) (207.126.148.85) by apache.org (qpsmtpd/0.29) with SMTP; Thu, 08 Apr 2010 08:52:44 +0000 Received: from source ([209.85.220.217]) by eu3sys201aob102.postini.com ([207.126.154.11]) with SMTP ID DSNKS72ZRt90yONUsAxwPNistRGek490MuOU@postini.com; Thu, 08 Apr 2010 08:52:24 UTC Received: by fxm9 with SMTP id 9so1900000fxm.4 for ; Thu, 08 Apr 2010 01:52:22 -0700 (PDT) MIME-Version: 1.0 Received: by 10.239.145.78 with HTTP; Thu, 8 Apr 2010 01:52:21 -0700 (PDT) In-Reply-To: References: Date: Thu, 8 Apr 2010 10:52:21 +0200 Received: by 10.239.190.145 with SMTP id x17mr1014157hbh.201.1270716741965; Thu, 08 Apr 2010 01:52:21 -0700 (PDT) Message-ID: Subject: Re: clustered environment, 2 different jvms, TransientFileFactory, storing file blobs in db From: =?ISO-8859-1?Q?Thomas_M=FCller?= To: dev@jackrabbit.apache.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on apache.org Hi, Stefan is right, File.createTempFile() doesn't generate colliding files. However, there is a potential problem with the TransientFileFactory. Consider the following case: - The file "bin-1.tmp" is created (BLOBInTempFile line 51). - The TransientFileFactory adds a PhantomReference "A" in its queue. - BLOBInTempFile.delete() or dispose() is called, the file "bin-1.tmp" is deleted. - A new file is created, and also called "bin-1.tmp" is created (BLOBInTempFile line 51) (that's possible because File.createTempFile can re-use file names). - The TransientFileFactory adds a second PhantomReference "B" in its queue, pointing to a different file with the same name. - The first (only the first) BLOBInTempFile is no longer referenced. - The TransientFileFactory.ReaperThread gets PhantomReference "A" and deletes this file. But the file is still used and referenced ("B"). I'm not sure if this is what is happening in your case, but it is a potential problem. Could you log a bug? There are multiple ways to solve the problem. I think the best solution is to not use File.createTempFile() and instead use our own file name factory (with a random part, and an counter part). Regards, Thomas