[JAVA-775] getLastError should ensure db.requestStart has been called Created: 28/Feb/13 Updated: 25/Jun/13 Resolved: 25/Jun/13 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Ben McCann | Assignee: | Unassigned |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Description |
|
I've been using MongoDB for quite a long time and didn't know about db.requestStart() until this past week. If you're going to call getLastError than it seems like it would be nice to ensure that db.requestStart() has been called. This could be an optional feature to not break existing code. Or an even better question is why is getLastError a separate command? That has always seemed very odd to me. Why not just add an option where the original request can return the error in the response? Then you would save a network round-trip. |
| Comments |
| Comment by Jeffrey Yemin [ 25/Jun/13 ] |
|
That's correct, and we are going to deprecate it in the next release and remove it in 3.0. |
| Comment by Ben McCann [ 28/Feb/13 ] |
|
Hmmm. Interesting. I'm not sure I quite understand yet though. Are you saying that with a write concern that the write request response will return whether there was an error and that you don't need an extra round-trip to see if there was an error? Is there some reason that getLastError hasn't been deprecated if you never need it? |
| Comment by Jeffrey Yemin [ 28/Feb/13 ] |
|
In practice, you should never need to call DB.getLastError or WriteResult.getLastError. Instead, use the WriteConcern that you want when you do the write. If you do, then the getLastError call will be effectively piggy-backed on to the write operation, regardless of whether you use requestStart. You can set WriteConcern at many levels, from MongoOptions, MongoClient/Mongo, DB, DBCollection, all the way down to individual write operations. |