You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-dev@jackrabbit.apache.org by Robert Munteanu <ro...@apache.org> on 2015/08/28 14:01:48 UTC

Multiple DocumentNodeStores sharing a single DocumentStore

Hi,

I'm looking at LastRevRecoveryAgentTest [1] which uses a shared
document store for two DocumentNodeStore instances. Disposing both node
store instances makes the tests fail, as the document store will be
closed by the first call to dispose() and the second call will fail.

The reason is the following snippet in DocumentNodeStore.dispose() (
full context at [2] ) :

        internalRunBackgroundUpdateOperations();
	
	// other stuff

        store.dispose();

If we have two node stores being shutdown, one of them will call
store.dispose() before the other is able to run its
backgroundUpdateOperations(). For the RDB and Mongo stores, the
connection will be closed. 

Also of interest - the LastRecoveryTest[3] , which has a similar setup,
only uses a shared MemoryDocumentStore and does not have this problem.

I don't think this behaviour exists only in tests, so I'd be interested
to see if there's a solution to this. The only idea that I have is the
DocumentStore instances knowing how many 'users' it has and only
accepting to be disposed when the last 'user' is gone, but that
requires that all 'users' obey this contract.

Thoughts?

Thanks,

Robert


[1]: https://github.com/apache/jackrabbit-oak/blob/1b6e52242be61c162be4
b1f1280d6545cc489d37/oak
-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/LastRevR
ecoveryAgentTest.java#L90-L105

[2]: https://github.com/apache/jackrabbit-oak/blob/1b6e52242be61c162be4
b1f1280d6545cc489d37/oak
-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Document
NodeStore.java#L551-L601

[3]: https://github.com/apache/jackrabbit-oak/blob/1b6e52242be61c162be4
b1f1280d6545cc489d37/oak
-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/LastRevR
ecoveryTest.java#L60

Re: Multiple DocumentNodeStores sharing a single DocumentStore

Posted by Marcel Reutegger <mr...@adobe.com>.
Hi,

I agree with Julian. the way a DocumentNodeStore deals with
the DocumentStore, it currently owns it and therefore closes
the store when it is disposed. this means the test should be
changed.

what we could do is change the contract. the DocumentNodeStore
is only responsible for the underlying store if it wasn't
passed in explicitly to the DocumentMK.Builder.

Regards
 Marcel

On 30/08/15 09:44, "Julian Reschke" wrote:
>On 2015-08-28 14:01, Robert Munteanu wrote:
>> Hi,
>>
>> I'm looking at LastRevRecoveryAgentTest [1] which uses a shared
>> document store for two DocumentNodeStore instances. Disposing both node
>> store instances makes the tests fail, as the document store will be
>> closed by the first call to dispose() and the second call will fail.
>>
>> The reason is the following snippet in DocumentNodeStore.dispose() (
>> full context at [2] ) :
>>
>>          internalRunBackgroundUpdateOperations();
>> 	
>> 	// other stuff
>>
>>          store.dispose();
>>
>> If we have two node stores being shutdown, one of them will call
>> store.dispose() before the other is able to run its
>> backgroundUpdateOperations(). For the RDB and Mongo stores, the
>> connection will be closed.
>>
>> Also of interest - the LastRecoveryTest[3] , which has a similar setup,
>> only uses a shared MemoryDocumentStore and does not have this problem.
>>
>> I don't think this behaviour exists only in tests, so I'd be interested
>> to see if there's a solution to this. The only idea that I have is the
>> DocumentStore instances knowing how many 'users' it has and only
>> accepting to be disposed when the last 'user' is gone, but that
>> requires that all 'users' obey this contract.
>>
>> Thoughts?
>>
>> Thanks,
>>
>> Robert
>
>My understanding is that instances can not be shared, thus this is a bug
>in the test cases.
>
>Best regards, Julian


Re: Multiple DocumentNodeStores sharing a single DocumentStore

Posted by Julian Reschke <ju...@greenbytes.de>.
On 2015-08-28 14:01, Robert Munteanu wrote:
> Hi,
>
> I'm looking at LastRevRecoveryAgentTest [1] which uses a shared
> document store for two DocumentNodeStore instances. Disposing both node
> store instances makes the tests fail, as the document store will be
> closed by the first call to dispose() and the second call will fail.
>
> The reason is the following snippet in DocumentNodeStore.dispose() (
> full context at [2] ) :
>
>          internalRunBackgroundUpdateOperations();
> 	
> 	// other stuff
>
>          store.dispose();
>
> If we have two node stores being shutdown, one of them will call
> store.dispose() before the other is able to run its
> backgroundUpdateOperations(). For the RDB and Mongo stores, the
> connection will be closed.
>
> Also of interest - the LastRecoveryTest[3] , which has a similar setup,
> only uses a shared MemoryDocumentStore and does not have this problem.
>
> I don't think this behaviour exists only in tests, so I'd be interested
> to see if there's a solution to this. The only idea that I have is the
> DocumentStore instances knowing how many 'users' it has and only
> accepting to be disposed when the last 'user' is gone, but that
> requires that all 'users' obey this contract.
>
> Thoughts?
>
> Thanks,
>
> Robert

My understanding is that instances can not be shared, thus this is a bug 
in the test cases.

Best regards, Julian