jackrabbit-oak-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Amit Jain <am...@ieee.org>
Subject Re: Jackrabbit Oak DuplicateKeyException
Date Thu, 14 Mar 2019 04:09:26 GMT
Moving to oak-dev from dev

Hi Dmitry,

As explained in [1] the upsert behavior can still throw exceptions in case
of a race condition where 2 inserts try to take place simultaneously. The
behavior pre OAK-7389 was erroneous as it could cause data loss in case of
DataStore garbage collection.
The method updateOne does not throw a DuplicateKeyException but throws
MongoWriteConernException [2] which is a direct subclass. So, the exception
will have to be handled.

Could you please create an issue to discuss this and preferably add your
test in the MongoBlobStoreTest and attach it to the issue.

Thanks
Amit

[1]
https://docs.mongodb.com/manual/reference/method/db.collection.update/#upsert-behavior
[2] https://api.mongodb.com/java/3.3/com/mongodb/DuplicateKeyException.html

On Wed, Mar 13, 2019 at 2:39 PM Dmitry Zakharov <
dmitry.zakharov1981@gmail.com> wrote:

> Dear Jackrabbit Developers,
>
> We are planning to migrate current Jackrabbit Oak version used in our
> application from 1.4.8 to the latest stable version. At the time we started
> evaluation it was 1.8.11.
>
> We have tests that we created for our implementation, some of them perform
> concurrent nodes creation. Unfortunately, they fail with 1.8.11 (see
> stacktrace bellow). It seems to be some race condition because it does not
> happen 100% of the time.
> Nodes that are created in parallel have the same content. If we change the
> content to be different for each node it runs successfully.
> It would be highly appreciated if you could assist us with the issue.
>
> After comparing 1.4.8 and 1.8.11 versions, we discovered that the code at
> o.a.j.o.p.d.m.MongoBlobStore.storeBlock (..) has changed under the
> following revision
>
> https://svn.apache.org/viewvc?view=revision&revision=1828502
> or github
> https://github.com/apache/jackrabbit-oak/commit/012e7529a6b8e34836f2fe22bcab3861b9d7192d#diff-1e1cd3443fc4e611259407cdf0ed6ebcL105
>
> in 1.4.8 DuplicateKeyException is ignored. in 1.8.11 you catch any
> MongoException and wrap it into IOException.
> Amit Jain explained to us that it is not necessary to catch
> DuplicateKeyException anymore, because upsert is used.
>
> However, we now get the exception which is propagated to our layer that
> does not know anything about mongo exceptions.
>
> we have created a small project that reproduces the issue, however, I have
> sent it in the previous email and it was not delivered. I would need
> another way of sending it to you.
>
> some additional info:
>
> we use mongo 3.6 for testing 1.8.11 and our current implementation is
> based on mongo 3.2
>
> we use mongo-java-driver 3.10.1 driver for 1.8.11 testing, and current
> driver version is 3.3.0
>
> how we created db to be used by jackrabbit:
> 	"C:\Program Files\MongoDB\Server\3.6\bin\mongo.exe" -u admin --authenticationDatabase
admin test --eval "db.createUser({user:""test"",pwd:""test"",roles:[{role:""readWrite"",db:""test""},{role:""clusterMonitor"",db:""admin""}]})"
>
> stacktrace:
>
> Caused by: java.io.IOException: Write failed with error code 11000 and
> error message 'E11000 duplicate key error collection: test.blobs index:
> _id_ dup key: { :
> "c3d471c99bd0a96030dc0f8b6951021b1333d4bcb11d8c9e16743a5d8a11cc60" }'
>     at
> org.apache.jackrabbit.oak.plugins.document.mongo.MongoBlobStore.storeBlock(MongoBlobStore.java:103)
> ~[oak-store-document-1.8.11.jar:1.8.11]
>     at
> org.apache.jackrabbit.oak.spi.blob.AbstractBlobStore.convertBlobToId(AbstractBlobStore.java:386)
> ~[oak-blob-1.8.11.jar:1.8.11]
>     at
> org.apache.jackrabbit.oak.spi.blob.AbstractBlobStore.writeBlob(AbstractBlobStore.java:195)
> ~[oak-blob-1.8.11.jar:1.8.11]
>     at
> org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore.createBlob(DocumentNodeStore.java:1865)
> ~[oak-store-document-1.8.11.jar:1.8.11]
>     at
> org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore.createBlob(DocumentNodeStore.java:133)
> ~[oak-store-document-1.8.11.jar:1.8.11]
>     at
> org.apache.jackrabbit.oak.core.MutableRoot.createBlob(MutableRoot.java:326)
> ~[oak-core-1.8.11.jar:1.8.11]
>     at
> org.apache.jackrabbit.oak.plugins.value.jcr.ValueFactoryImpl.createBinaryValue(ValueFactoryImpl.java:296)
> ~[oak-store-spi-1.8.11.jar:1.8.11]
>     at
> org.apache.jackrabbit.oak.plugins.value.jcr.ValueFactoryImpl.createBinary(ValueFactoryImpl.java:288)
> ~[oak-store-spi-1.8.11.jar:1.8.11]
>     ... 40 more
>
> If you need any additional information, please do not hesitate to ask.
> Once again, any assistance is highly appreciated.
>
> thank you in advance.
>
>
> --
> ------------------------------------------------------
> Best Regards,
>
>
> Dmitry Zakharov
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message