[DOCS-4551] serverStatus counts duplicate key errors as inserts Created: 17/Dec/14 Updated: 16/Mar/15 Resolved: 18/Dec/14 |
|
| Status: | Closed |
| Project: | Documentation |
| Component/s: | manual |
| Affects Version/s: | None |
| Fix Version/s: | v1.3.15 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | William Cross | Assignee: | Sam Kleinman (Inactive) |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
OSX 10.9 |
||
| Participants: | |
| Days since reply: | 9 years, 8 weeks, 6 days ago |
| Description |
|
serverStatus is counting duplicate key errors as inserts. This is bad because a client might think that they are inserting documents when they're not. Steps to reproduce:
|
| Comments |
| Comment by Scott Hernandez (Inactive) [ 18/Dec/14 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There are lots of types of "operations" but don't conflate replication operations with command/crud operations. Sometimes when you know lots it can be confusing but when you don't then the docs actually do make more sense. We can def. cleanup terminology and be more consistent and concise, and many times the tools/driver docs are wrong/inconsistent. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by William Cross [ 18/Dec/14 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
scotthernandez, thank you for helping to point this out and clarify things. I have to disagree, though, when you say that the documentation is clear; first, it's easy to look at the documentation about mongostat and serverStatus opcounters and not see that comment on metrics (This is exactly what happened to me). Also, keep in mind that terms like "operations" and "document access and modification patterns" aren't obviously distinct to the reader; why shouldn't an operation mean something that resulted in a write? After all, only writes get recorded in our operations log. If we look elsewhere, docs say the following about mongostat (which draws its data from ServerStatus): "inserts And here's opcounters: "The opcounters document reports the number of operations this MongoDB instance has processed:" It seems to me that a lot of functionality is getting treated vaguely here, and I think this is a situation where our documentation could really add some clarity for users. The more I dig into this, the stronger I'm feeling about it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Scott Hernandez (Inactive) [ 18/Dec/14 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
If you want to know how many documents are effected you should look at the document counters. Operations are things that go across the network, the driver issues to the server... http://docs.mongodb.org/manual/reference/command/serverStatus/#serverStatus.metrics.document The docs seem pretty clear wrt operations versus document writes. However, what you have actually shown here is output from sharded cluster via a mongos instance, which reports operation that the mongos instance passed to shards, so you probably want to consider that as well – as I suspect you probably wanted to talk about the storage instances... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by William Cross [ 18/Dec/14 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
dan@10gen.com, just to clarify, this happens for both duplicate key errors and for update attempts that do not result in document modification (as the new document is the same as the old). So it sounds like this is the behavior we want, and this is now a docs issue? If so, I will move the ticket to Docs so that our documentation is clear about this behavior. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Daniel Pasette (Inactive) [ 18/Dec/14 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
This is a bit subtle. Users are not supposed to be using the counters for real "counts", they're meant to help users understand the health of the system. In most cases, hitting a duplicate key error is almost equivalent to doing the actual insert as far as the system is concerned. If the stat was not incremented, users could equally think the server was doing nothing. The common case is that duplicate keys are relatively rare and don't need to be accounted for specially. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by William Cross [ 18/Dec/14 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Backwards revising the ticket so that the server people can see the issue more quickly. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Michael O'Brien [ 18/Dec/14 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
william.cross done. thanks! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by William Cross [ 18/Dec/14 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I suggest moving this to server, per your comment. It looks like mongostat is correctly displaying the information it's getting. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by William Cross [ 18/Dec/14 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
It looks like db.serverStatus() does increment once per attempted insert, which can vary depending on when the first error occurs for an ordered bulk insert:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by William Cross [ 18/Dec/14 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Agreed, the issue is present in serverStatus(), and this is likely where mongostat is getting its data. I also see the same issue happening for updates that don't result in document modification:
I note that the docs seem to be naive to this behavior; they're saying it counts inserts/updates. I also see this in 2.6.6, btw. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Michael O'Brien [ 17/Dec/14 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
This is likely due to the server's implementation of serverStatus(), which is where mongostat gets the opcounters from. |