-
Notifications
You must be signed in to change notification settings - Fork 43
DOCSP-26368: FAQ entry for state should be open exception #416
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
DOCSP-26368: FAQ entry for state should be open exception #416
Conversation
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.
just a few things!
source/faq.txt
Outdated
@@ -148,6 +148,26 @@ When ``MongoClient.close()`` is called by any thread, the driver | |||
closes all idle sockets and closes all sockets that are in | |||
use as they are returned to the pool. | |||
|
|||
Why does the application throw "IllegalStateException: state should be: open"? |
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.
Suggestion: make the question more oriented around the user
Why does the application throw "IllegalStateException: state should be: open"? | |
Why did I receive an "IllegalStateException: state should be: open" error? |
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.
Thanks, I reworded since "receive" doesn't seem like a common action to describe exceptions.
source/faq.txt
Outdated
You may encounter this exception if you call an operation on a ``MongoClient`` | ||
instance that closed its connections to MongoDB. The connections could be |
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.
Question: Does the client close the connections or does the application close the connections? It could be helpful to clarify the wording here.
You may encounter this exception if you call an operation on a ``MongoClient`` | |
instance that closed its connections to MongoDB. The connections could be | |
You may encounter this exception if you call an operation on a ``MongoClient`` | |
instance with a closed connection to MongoDB. The connections could be |
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.
I'm not sure I understand the question since they both are responsible for the closing of the connection depending on perspective. An application must call the code to instruct the client to close. The client must close the connection when that method is called. Could you clarify what you meant?
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.
I think I meant to ask whether there were times when a client closes a connection on its own, without the application containing/calling the close method. In any case, i think you can keep the wording as is
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.
From what I understand, the client, which I'm assuming is MongoClient, can open and close connections based on load and network state (see How Does Connection Pooling Work in the Java Driver), but when you call an operation, whether a direct one such as ListDatabaseNames() or indirectly such as by calling find() on a MongoCollection, the MongoClient queues it up for the next available connection.
However, if you call close() on the instance, or perhaps another process signals for it to close its connections, it transitions into a state that is no longer "open" and does not accept any further operations.
source/faq.txt
Outdated
instance that closed its connections to MongoDB. The connections could be | ||
closed due to one of the following conditions: |
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.
instance that closed its connections to MongoDB. The connections could be | |
closed due to one of the following conditions: | |
instance that closed its connections to MongoDB. The connections could be | |
closed for one of the following reasons: |
source/faq.txt
Outdated
instance that closed its connections to MongoDB. The connections could be | ||
closed due to one of the following conditions: | ||
|
||
- The ``close()`` method was called on that ``MongoClient`` instance |
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.
Issue: end full sentence list items with periods
- The ``close()`` method was called on that ``MongoClient`` instance | |
- You previously called the ``close()`` method on the ``MongoClient`` instance. |
source/faq.txt
Outdated
closed due to one of the following conditions: | ||
|
||
- The ``close()`` method was called on that ``MongoClient`` instance | ||
- The ``MongoClient`` instance is out of scope |
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 ``MongoClient`` instance is out of scope | |
- The ``MongoClient`` instance is out of scope. |
source/faq.txt
Outdated
- The framework your application uses to manage your MongoDB operations, such | ||
as Spring Boot, has closed the connection automatically. |
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 framework your application uses to manage your MongoDB operations, such | |
as Spring Boot, has closed the connection automatically. | |
- The framework your application uses to manage your MongoDB operations, such | |
as Spring Boot, automatically closed the connection. |
Also suggestion: link to something related to Spring Boot
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.
lgtm!
source/faq.txt
Outdated
|
||
- The ``close()`` method was called on that ``MongoClient`` instance prior | ||
to the operation call. | ||
- Another thread or process closed the connection. This can happen when |
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.
I don't understand what the difference is between the first and second bullet. The only way to "close the connection" is to call the close method on the MongoClient. The difference only seems to be where the close is happening (how close/far it is from the code that is getting the exception, whether in the same thread or a different thread.
Also, it's not possible for another process to directly close a MongoClient. It would have to happen indirectly through communication through a socket, or some signal, etc.
Also, it may be the
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.
I see. I assumed that this response was referring to an executor service operating on a pool of threads. Would you prefer I remove this list item to avoid any confusion? Is there any info you'd like to add? Thanks!
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, please remove. You could point out that often MongoClient instances are singletons that are accessible by multiple threads, and so the code which closes the MongoClient may be distant from the code receiving the exception, perhaps in another thread of execution.
source/faq.txt
Outdated
.. tip:: | ||
|
||
The code that closes the ``MongoClient`` instance may be difficult to | ||
locate in certain cases. The ``MongoClient`` uses the singleton pattern, |
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.
MongoClient doesn't use the singleton pattern itself. It's just that frameworks are often configured to manage these instances as singletons.
* DOCSP-26368: FAQ entry for state should be open exception (cherry picked from commit 0e3f06f)
* DOCSP-26368: FAQ entry for state should be open exception (cherry picked from commit 0e3f06f)
* DOCSP-26368: FAQ entry for state should be open exception (cherry picked from commit 0e3f06f)
* DOCSP-26368: FAQ entry for state should be open exception (cherry picked from commit 0e3f06f)
* DOCSP-26368: FAQ entry for state should be open exception (cherry picked from commit 0e3f06f)
* DOCSP-26368: FAQ entry for state should be open exception (cherry picked from commit 0e3f06f)
* DOCSP-26368: FAQ entry for state should be open exception (cherry picked from commit 0e3f06f)
* DOCSP-26368: FAQ entry for state should be open exception (cherry picked from commit 0e3f06f)
Pull Request Info
PR Reviewing Guidelines
JIRA - https://jira.mongodb.org/browse/DOCSP-26368
Staging - https://docs-mongodbcom-staging.corp.mongodb.com/java/docsworker-xlarge/DOCSP-26368-FAQ-illegalstateexception/faq/#how-do-i-prevent-the--illegalstateexception--state-should-be--open--error-
Self-Review Checklist