-
Notifications
You must be signed in to change notification settings - Fork 414
OAK-9447: Upgrade Mongo java driver to 5.2 #2226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
* OAK-9447 * Conflict with trunk resolved * Conflict resolved * conflict resolved * Reordered imports like original classes and fixed oak-run about new mongodb-driver-sync * Reordered imports like original classes * Upgraded com.mongodb and org.bson versions in Import-Package * Restored original formatting * Restored original import ordering * Restored original import ordering --------- Co-authored-by: raffaega <raffaega@CI00298583> Co-authored-by: raffaega <raffaega@host.docker.internal> Co-authored-by: Raffaele Gambelli <r.gambelli@gmail.com> Co-authored-by: Raffaele Gambelli <raffaele.gambelli@cegeka.com>
Commit-Check ❌
|
This PR will likely contain many commits, so plan it to squash it into a single commit when ready. |
@@ -89,11 +89,11 @@ public void readWriteMode() throws InterruptedException { | |||
assertEquals(WriteConcern.MAJORITY, mem.getWriteConcern()); | |||
|
|||
op = new UpdateOp(list.get(0).getId(), false); | |||
op.set("readWriteMode", "read:nearest, write:fsynced"); | |||
op.set("readWriteMode", "read:nearest, write:w2"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FSYNCED doesn't exist anymore, the correct replacement is W2.
// bimap.put(WriteConcern.REPLICAS_SAFE,"REPLICAS_SAFE"); | ||
bimap.put(WriteConcern.SAFE,"SAFE"); | ||
bimap.put(WriteConcern.ACKNOWLEDGED,"ACKNOWLEDGED"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those WriteConcerns are removed:
- FSYNC_SAFE and JOURNAL_SAFE replaced by JOURNALED
- NORMAL and SAFE replaced by ACKNOWLEDGED
@@ -2361,8 +2364,7 @@ private boolean withClientSession() { | |||
} | |||
|
|||
private boolean secondariesWithinAcceptableLag() { | |||
return getClient().getReplicaSetStatus() == null | |||
|| connection.getStatus().getReplicaSetLagEstimate() < acceptableLagMillis; | |||
return connection.getStatus().getReplicaSetLagEstimate() < acceptableLagMillis; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getStatus() can't be null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getReplicaSetLagEstimate() returns 0 when Mongo is not a replica set.
import static com.mongodb.client.model.Filters.or; | ||
import static com.mongodb.client.model.Projections.include; | ||
import static com.mongodb.client.model.Sorts.ascending; | ||
|
||
import static java.util.Collections.emptyList; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not keeping the old imports ordering because they made no sense.
@@ -99,19 +87,30 @@ | |||
import org.slf4j.LoggerFactory; | |||
|
|||
import com.mongodb.BasicDBObject; | |||
import com.mongodb.ConnectionString; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not keeping the old imports ordering because they made no sense.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new Java driver seems to work correctly with indexing.
Thanks @nfsantos! |
...src/main/java/org/apache/jackrabbit/oak/index/indexer/document/DocumentStoreIndexerBase.java
Outdated
Show resolved
Hide resolved
com.mongodb*;version="[3.8, 4)";resolution:=optional, | ||
org.bson*;version="[3.8, 4)";resolution:=optional, | ||
com.mongodb*;version="[5.2, 5.3)";resolution:=optional, | ||
org.bson*;version="[5.2, 5.3)";resolution:=optional, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we already have version 5.5.0
released for mongo-driver-sync [1]
[1] https://mvnrepository.com/artifact/org.mongodb/mongodb-driver-sync
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but we should test it before allowing it. We can do it in a new PR after this is merged, to avoid further delays on this PR.
...ument/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java
Show resolved
Hide resolved
WriteConcern wc = new MongoClientURI(requireNonNull(uri), builder) | ||
.getOptions().getWriteConcern(); | ||
return !WC_UNKNOWN.equals(wc); | ||
ConnectionString connectionString = new ConnectionString(requireNonNull(uri)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need need to change this behavior here, this might cause an regression.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The behavior is the same: both implementations check whether the URI explicitly sets a writeConcern
. The previous version used a workaround with WC_UNKNOWN
to detect this, but the new API exposes this check directly via getWriteConcern()
.
Since now there is a native method in the driver that does exactly what we need, I don't think we need the workaround anymore.
There are tests that checks this and I introduced a few more test cases in MongoConnectionTest.java to ensure no regressions are introduced.
@@ -155,18 +153,6 @@ public void setUpdateLimit() throws Exception { | |||
assertEquals(17, store.getUpdateLimit()); | |||
} | |||
|
|||
@Test | |||
public void keepAlive() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keepAlive
config is only marked as deprecated not removed. I would suggest to keep these test till we remove that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test checks for getMongoClientOptions().isSocketKeepAlive()
, which doesn't exist at all in modern driver, so this test would have no sense at all.
I marked keepAlive
and all related properties as deprecated just to help to detect any uses in any application using Oak as dependency, to avoid breaking changes, but all those options should be completely removed.
@@ -85,26 +95,6 @@ public void sufficientReadConcern() throws Exception { | |||
sufficientReadConcernSingleNode(ReadConcern.MAJORITY, true); | |||
} | |||
|
|||
@Test | |||
public void socketKeepAlive() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, I would keep this alive till we remove the config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As before, Mongo doesn't have any related isSocketKeepAlive
method anymore. The only way to keep this test is to make it a NOOP test, which doesn't make much sense to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Mongo Java Driver 3.6 it was already deprecated, and in 4.0 removed.
# Conflicts: # oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoVersionGCSupport.java
Starting from base PR created by rgambelli #1761
Some conflicts still need to be resolved before merging