Skip to content
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

OAK-10758: Proposal: Add system property to control noCursorTimeout in Mongo iterator #1409

Open
wants to merge 2 commits into
base: DetailedGC/OAK-10199
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,19 @@ enum DocumentReadPreference {
private final long maxQueryTimeMS =
Long.getLong("oak.mongo.maxQueryTimeMS", TimeUnit.MINUTES.toMillis(1));

/**
* Flag to control the cursor timeout behavior in MongoDB.
* <p>
* If set to true, the server will not close the cursor if no operations are performed for a certain period of time.
* This can be useful for long running queries or when the client needs to retain the cursor for a longer period.
* </p>
* Default value is false, meaning the server will automatically close idle cursors after a default server-side
* timeout.
* See: https://www.mongodb.com/docs/manual/reference/method/cursor.noCursorTimeout
*/
private final boolean noCursorTimeout =
Boolean.getBoolean("oak.mongo.noCursorTimeout");

/**
* The number of documents to put into one bulk update.
* <p>
Expand Down Expand Up @@ -867,6 +880,10 @@ && canUseModifiedTimeIdx(startValue)) {
result.maxTime(maxQueryTime, TimeUnit.MILLISECONDS);
}

if (noCursorTimeout) {
result.noCursorTimeout(noCursorTimeout);
}

try (MongoCursor<BasicDBObject> cursor = result.iterator()) {
for (int i = 0; i < limit && cursor.hasNext(); i++) {
BasicDBObject o = cursor.next();
Expand Down
Loading