You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by Adrien Lamoureux <la...@gmail.com> on 2010/04/07 20:21:52 UTC

clustered environment, 2 different jvms, TransientFileFactory, storing file blobs in db

Hello,

I would normally file a bug on jira, but its very difficult to
setup/reproduce, so I'm looking for insight first on how temp files/blobs
are implemented in jackrabbit.

We currently run 2 different "standalone" instances of jackrabbit version
2.0.0, each in their own JVM and setup the same way in using <cluster>.

Our application connects to one of the standalone instances
remotely(webdavex) for authoring content, and sends publish instructions
(via JMS/activemq) to the other.

The problem though, is that BLOBInTempFile.getStream is occasionaly throwing
: "file backing binary value not found", and one of the instances sometimes
can't read the file.

I've searched and found this information:
http://mail-archives.apache.org/mod_mbox//jackrabbit-dev/200603.mbox/<90...@mail.gmail.com><http://mail-archives.apache.org/mod_mbox//jackrabbit-dev/200603.mbox/%3C90a8d1c00603150237t4c81df4fx178fcd726a93fe@mail.gmail.com%3E>

So apparently, when files are read/written, you create a temporary cache,
but TransientFileFactory runs as a singleton within a single JVM correct?

So can I assume that one of the "singletons", (there will be 2??) will
delete files that were created by the other at some DIFFERENT random time
when the garbage collector runs?

I've also attached your Repository.xml that we use for both (with different
cluster ids of course)


Adrien

Thanks
Is there some way to avoid this??

I've attached our repository.xml for you to look at, both are setup the same
way for e

Thanks.

Re: clustered environment, 2 different jvms, TransientFileFactory, storing file blobs in db

Posted by Titu <pe...@gmail.com>.
Can a file instance be phantom reachable even though it is not deleted ?



Re: clustered environment, 2 different jvms, TransientFileFactory, storing file blobs in db

Posted by Thomas Müller <th...@day.com>.
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

Re: clustered environment, 2 different jvms, TransientFileFactory, storing file blobs in db

Posted by Stefan Guggisberg <st...@gmail.com>.
On Wed, Apr 7, 2010 at 8:21 PM, Adrien Lamoureux
<la...@gmail.com> wrote:
> Hello,
> I would normally file a bug on jira, but its very difficult to
> setup/reproduce, so I'm looking for insight first on how temp files/blobs
> are implemented in jackrabbit.
> We currently run 2 different "standalone" instances of jackrabbit version
> 2.0.0, each in their own JVM and setup the same way in using <cluster>.
> Our application connects to one of the standalone instances
> remotely(webdavex) for authoring content, and sends publish instructions
> (via JMS/activemq) to the other.
> The problem though, is that BLOBInTempFile.getStream is occasionaly throwing
> : "file backing binary value not found", and one of the instances sometimes
> can't read the file.
> I've searched and found this information:
> http://mail-archives.apache.org/mod_mbox//jackrabbit-dev/200603.mbox/<90...@mail.gmail.com>
> So apparently, when files are read/written, you create a temporary cache,
> but TransientFileFactory runs as a singleton within a single JVM correct?

yes

> So can I assume that one of the "singletons", (there will be 2??) will
> delete files that were created by the other at some DIFFERENT random time
> when the garbage collector runs?

no, unless java.io.File#createTempFile invoked from 2 different jvm's
would create
colliding temp files. but that's impossible according to the javadoc [0]:

<quote>
[...] is guaranteed that:
1. The file denoted by the returned abstract pathname did not exist
before this method was invoked
[...]
</quote>

cheers
stefan

[0] http://java.sun.com/javase/7/docs/api/java/io/File.html#createTempFile(java.lang.String,
java.lang.String, java.io.File)

> I've also attached your Repository.xml that we use for both (with different
> cluster ids of course)
>
> Adrien
> Thanks
> Is there some way to avoid this??
> I've attached our repository.xml for you to look at, both are setup the same
> way for e
> Thanks.
>
>