Intermittent Error: Invalid attempt to Read when reader is closed.
Intermittent Error: Invalid attempt to Read when reader is closed.
This error happens in our production system frequently but is not consistent. We have checked connections and network. No problems were identified. Also, the call stack is not available as the logging is minimal being production. If there is any bug in the code regarding the reader closing etc..., we would see the problem consistently. Interestingly, the reader is loading one row only. It is puzzling why the reader would close prematurely. Can you help?
Re: Intermittent Error: Invalid attempt to Read when reader is closed.
Please check your code: is it possible that the same connection object is used in several threads simultaneously?
The PgSqlConnection instance is not guaranteed to be thread safe. You should avoid using the same PgSqlConnection in several threads at the same time. It is recommended to open a new connection per thread and to close it when the work is done.
The PgSqlConnection instance is not guaranteed to be thread safe. You should avoid using the same PgSqlConnection in several threads at the same time. It is recommended to open a new connection per thread and to close it when the work is done.