[CSHARP-411] NRE in timer thread Created: 14/Mar/12 Updated: 02/Apr/15 Resolved: 20/Mar/12 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | None |
| Affects Version/s: | 1.4 |
| Fix Version/s: | 1.4 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Aristarkh Zagorodnikov | Assignee: | Robert Stam |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Backwards Compatibility: | Fully Compatible |
| Description |
|
After running for a few minutes doing some DB operations, I attached the debugger and found out there are NREs happening in the background at the following stack trace: It appears that _serverInstance.EndPoint is null for some reason. I'm using git version 77ac96b73b3fe9f4517cc79d3c72c2d87e1bbc9a. |
| Comments |
| Comment by Robert Stam [ 20/Mar/12 ] | |
|
The DNS lookups are now handled slightly differently so that this NullReferenceException no longer occurs. | |
| Comment by Robert Stam [ 15/Mar/12 ] | |
|
Thanks for the extra information. Even though the exception can be explained by a DNS failure to resolve, this is a situation that could happen to anybody and it would be better if it was handled without throwing exceptions, so I will fix that. Knowing the root cause will make it easy to reproduce. | |
| Comment by Aristarkh Zagorodnikov [ 15/Mar/12 ] | |
|
Good thing you mentioned DNS, I checked and found that one of the servers mentioned in the connection string (it's a replica set) had its DNS name spelled wrong. | |
| Comment by Robert Stam [ 15/Mar/12 ] | |
|
Getting a NullReferenceException on that line makes more sense. I'll investigate further. The endPoint is the result of a DNS lookup, which is done once when Connect is called. The timer code doesn't do the Ping if the server state is Disconnected or Disconnecting, but it looks like there is a race condition where the server might be in some other state but has not yet resolved the endPoint address. In a sense this is harmless because the exception is ignored. But annoying nonetheless. | |
| Comment by Aristarkh Zagorodnikov [ 15/Mar/12 ] | |
|
My line 362 is: | |
| Comment by Robert Stam [ 15/Mar/12 ] | |
|
What's at your line number 362 in MongoConnection? I have:
Which couldn't throw a NullReferenceException, and there's another use of the endPoint variable 4 lines earlier which would have thrown a NullReferenceException before reaching this line. |