Repository navigation
Permalink
Choose a base ref
{{ refName }}
default
Choose a head ref
{{ refName }}
default
Comparing changes
Choose two branches to see what’s changed or to start a new pull request.
If you need to, you can also or
learn more about diff comparisons.
Open a pull request
Create a new pull request by comparing changes across two branches. If you need to, you can also .
Learn more about diff comparisons here.
base repository: mongodb/mongo-java-driver
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: r4.2.0
Could not load branches
Nothing to show
Loading
Could not load tags
Nothing to show
{{ refName }}
default
Loading
...
head repository: mongodb/mongo-java-driver
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: r4.2.1
Could not load branches
Nothing to show
Loading
Could not load tags
Nothing to show
{{ refName }}
default
Loading
- 13 commits
- 39 files changed
- 3 contributors
Commits on Jan 20, 2021
-
Configuration menu - View commit details
-
Copy full SHA for f51f37a - Browse repository at this point
Copy the full SHA f51f37aView commit details
Commits on Jan 22, 2021
-
Configuration menu - View commit details
-
Copy full SHA for b9ac4a1 - Browse repository at this point
Copy the full SHA b9ac4a1View commit details
Commits on Feb 4, 2021
-
Fix reactive streams batch cursor regression. (#652)
The BatchCursorPublisher now waits for demand to be signalled before creating the cursor. The batch cursor publisher also internally respects the batch size. Its either the configured batch size if set or the amount requested. JAVA-3973
Configuration menu - View commit details
-
Copy full SHA for 3aeacf5 - Browse repository at this point
Copy the full SHA 3aeacf5View commit details -
Make implementations of AsyncAggregateResponseBatchCursor more respon…
…sive to close signals (#654) 1) Change implementations of AsyncAggregateResponseBatchCursor to make them more responsive to close signals AsyncAggregateResponseBatchCursor wraps AsyncQueryBatchCursor. AsyncQueryBatchCursor implements pending cancel functionality. AsyncQueryBatchCursor may enter a pending close state as a result of calling close concurrently with the object being in the pending operation state. AsyncAggregateResponseBatchCursor does not need to duplicate the pending functionality, in fact, it prevented AsyncQueryBatchCursor from receiving close signals while being in the pending operation state. 2) Release resources in AsyncQueryBatchCursor The changes made is this commit appear to be correct from the standpoint of tests, but it is very hard for me to prove that by inspecting the code. There are two reasons: - the reference counting approach used in the code - the presence of multiple places in code where the instance field connectionSource is released, combined with the fact that it is not always retained in the constructor and must be released not more than once per the lifetime of an AsyncQueryBatchCursor object. The following text expresses my thoughts about reference counting and is not directly related to the changes made in this commit. The current approach for reference counting in the driver code is what we may call a release-early approach, similar to the one described in the Netty documentation (https://github.com/netty/netty/wiki/Reference-counted-objects#who-destroys-it). In this approach "the party that accesses a reference-counted object last is also responsible for the destruction of that reference-counted object". The problem with this approach is that it is not structured. "Structured" reference counting. The idea is to try and get our reference counting code closer to following the structured programming approach (https://en.wikipedia.org/wiki/Structured_programming) while fixing a bug: AsyncQueryBatchCursor does not always release a connection when it is not needed anymore. In simple words, the following is desirable: given a place in code where retain/release is called, it should be simple to tell where the corresponding release/retain is called. As a side note, structured programming applied to concurrent code is called structured concurrency. This idea is realized in Kotlin: https://kotlinlang.org/docs/reference/coroutines/basics.html#structured-concurrency, https://elizarov.medium.com/structured-concurrency-722d765aa952 (the article is written by the author of Kotlin coroutines functionality). As much as I would like us to use the structured approach, it is generally speaking not possible to reconcile it with the release-early in the same codebase. In other words, a complete refactoring may be needed to switch to the structured approach. Following is an example demonstrating a situation when synchronous code that was written with the release-early approach behaves differently when combined with the structured approach. Consider the following legacy code in which we want to refactor releaseEarlyLegacyMethod (the only code that will stay unchanged is the releaseEarlyUnchangedCode method): void releaseEarlyLegacyMethod() { ReferenceCounted resource = pool.borrow();//count is 1 /* Since ReleaseEarlyLegacyConsumer is the last party using the resource, it must release the resource. * A reader cannot find the release call corresponding to the borrow call inside the releaseEarlyLegacyMethod method.*/ releaseEarlyUnchangedCode(new ReleaseEarlyLegacyOneTimeConsumer(resource)); } class ReleaseEarlyLegacyOneTimeConsumer implements Runnable { private final ReferenceCounted resource; ReleaseEarlyLegacyOneTimeConsumer(ReferenceCounted resource) { this.resource = resource;//count is 1 } public void run() { try { System.out.println(resource.toString());//count is 1; use the resource } finally {//release the resource because ReleaseEarlyLegacyConsumer.accept is the last party accessing it /* Note that by looking at this release call, a reader cannot easily find the corresponding retain/borrow call. * The corresponding retain/borrow call is not even in this class.*/ resource.release();//count is 0; the resource returns to the pool } } } void releaseEarlyUnchangedCode(Runnable action) { action.run(); ReferenceCounted resource = pool.borrow();//count is 1; succeeds only if the single resource has been returned to the pool try {//use the resource System.out.println(resource.toString());//count is 1 } finally {//release the resource because releaseEarlyUnchangedCode is the last party accessing it resource.release();//count is 0; the resource is returned to the pool } } The pool.borrow call in releaseEarlyUnchangedCode works because the resource is returned to the pool before action.run() returns. Here is the refactored code that uses structured reference counting: void structuredNewMethod() { ReferenceCounted resource = pool.borrow();//count is 1 //a reader can easily find the release call corresponding to the borrow call because it is in the finally block in this method try { releaseEarlyUnchangedCode(new StructuredNewOneTimeConsumer(resource)); } finally { resource.release();//count is 0; the resource returns to the pool } } class StructuredNewOneTimeConsumer implements Runnable { private final ReferenceCounted resource; StructuredNewOneTimeConsumer(ReferenceCounted resource) { this.resource = resource.retain();//count is 2; we store a new reference to the resource } public void run() { try { System.out.println(resource.toString());//count is 2; use the resource } finally {//release the resource because StructuredNewConsumer is not going to use it anymore /* The corresponding retain call is in the constructor of the class because resource is the instance field. * A reader may easily locate it.*/ resource.release();//count is 1 } } } With this new code, the pool.borrow call in releaseEarlyUnchangedCode fails because the resource is not returned to the pool before action.run() returns. It is only returned to the pool before structuredNewMethod returns. Thereby, we have shown that the release-early and the structured approaches are not reconcilable. This would not be a problem if the code was written following the structured approach from the beginning because in that case, releaseEarlyUnchangedCode would have been written differently (using either return-early or structured reference counting definitely affects the structure of the rest of the code). JAVA-3907
Configuration menu - View commit details
-
Copy full SHA for b47b8a0 - Browse repository at this point
Copy the full SHA b47b8a0View commit details
Commits on Feb 10, 2021
-
Configuration menu - View commit details
-
Copy full SHA for 1aa22d9 - Browse repository at this point
Copy the full SHA 1aa22d9View commit details
Commits on Feb 11, 2021
-
Configuration menu - View commit details
-
Copy full SHA for 62885b0 - Browse repository at this point
Copy the full SHA 62885b0View commit details -
Configuration menu - View commit details
-
Copy full SHA for d1ac231 - Browse repository at this point
Copy the full SHA d1ac231View commit details
Commits on Feb 16, 2021
-
Configuration menu - View commit details
-
Copy full SHA for f373b72 - Browse repository at this point
Copy the full SHA f373b72View commit details -
Configuration menu - View commit details
-
Copy full SHA for f44db9c - Browse repository at this point
Copy the full SHA f44db9cView commit details
Commits on Feb 17, 2021
-
Configuration menu - View commit details
-
Copy full SHA for 5620b2a - Browse repository at this point
Copy the full SHA 5620b2aView commit details
Commits on Feb 18, 2021
-
Configuration menu - View commit details
-
Copy full SHA for 0b44199 - Browse repository at this point
Copy the full SHA 0b44199View commit details -
Configuration menu - View commit details
-
Copy full SHA for 45901fa - Browse repository at this point
Copy the full SHA 45901faView commit details -
Configuration menu - View commit details
-
Copy full SHA for 18ce60a - Browse repository at this point
Copy the full SHA 18ce60aView commit details
Loading
This comparison is taking too long to generate.
Unfortunately it looks like we can’t render this comparison for you right now. It might be too big, or there might be something weird with your repository.
You can try running this command locally to see the comparison on your machine:
git diff r4.2.0...r4.2.1