[SERVER-23605] 100% CPU usage in update one field in one document Created: 07/Apr/16 Updated: 22/Feb/22 Resolved: 11/Apr/16 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | WiredTiger, Write Ops |
| Affects Version/s: | 3.2.3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Critical - P2 |
| Reporter: | Ivan Artemov | Assignee: | Kelsey Schubert |
| Resolution: | Done | Votes: | 0 |
| Labels: | query | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Azure VM D2 size |
||
| Attachments: |
|
| Operating System: | ALL |
| Steps To Reproduce: | Fill collection with more than 400.000 documents with many text data (5KB) in some properties. Try to update one field at some object. |
| Participants: |
| Description |
|
I have a simple social crawler written in C# for testing MongoDB performance and decide - use it in another projects. Posts collection have _id index and { "SiteId" : 1, "IsApproved" : -1, "Date" : -1 }I make project to find one with {Id, IsApproved}and UpdateOne with !Approved (see screenshot). Inserting documents fine and my Azure VM (D2 (2 cores Xeon with SSD) CPU costs about 2-8 percent. How I will use database, that only one update costs so many CPU times ? |
| Comments |
| Comment by Hamza Shakir [ 22/Feb/22 ] | ||||||||||||||||||||||
|
I am facing issue. I am streaming stock trades from from alpaca but issue that db usage 100% during streaming my system spceicification: Instance type: t3.xlarge Kindly let me know system requirement for above task. bellow is my piece of code await models.Stocks.updateOne({ symbol: trade.Symbol }, [{ , , { $toDouble: trade.Price }] } }, , { $toDouble:"$price" }] } }, { $toDouble:"$price" }] }, 100] } } } }, | ||||||||||||||||||||||
| Comment by Kelsey Schubert [ 11/Apr/16 ] | ||||||||||||||||||||||
|
Hi ZOXEXIVO, You may be interested in Thank you for your help identifying the cause of this behavior, | ||||||||||||||||||||||
| Comment by Ivan Artemov [ 11/Apr/16 ] | ||||||||||||||||||||||
|
Robert, Thank you! | ||||||||||||||||||||||
| Comment by Ivan Artemov [ 11/Apr/16 ] | ||||||||||||||||||||||
|
Thomas, can you move this issue to C# Driver ? Server works ok, but C# driver work as not expected | ||||||||||||||||||||||
| Comment by Robert Stam [ 11/Apr/16 ] | ||||||||||||||||||||||
|
LINQ queries are always executed as aggregation framework commands. But now that we see what the LINQ query got converted to it is obvious what the problem is. The resulting aggregation framework query pipeline requires a full collection scan. The reason is that it does a projection before a match so no index can be used (the server does not rearrange the order of the pipeline). The LINQ query can be easily rewritten so that it generates an efficient aggregation framework pipeline:
The resulting aggregation framework pipeline now is:
The important change is to filter before projecting. Since the $match stage is now before the $project stage the server would be able to use an index to execute the pipeline more efficiently. | ||||||||||||||||||||||
| Comment by Ivan Artemov [ 10/Apr/16 ] | ||||||||||||||||||||||
|
Hello, Thomas. I find problem!
convert to
I think it is not standart behaviour and we need ask C# Driver developer, why it convert to aggregate query. | ||||||||||||||||||||||
| Comment by Ivan Artemov [ 08/Apr/16 ] | ||||||||||||||||||||||
|
I attach 2 screenshots with system monitors. iostat not available on Windows, but we have Perfrormance Monitor | ||||||||||||||||||||||
| Comment by Kelsey Schubert [ 08/Apr/16 ] | ||||||||||||||||||||||
|
Hi ZOXEXIVO, Thank you for reporting this issue. So we can continue to investigate, can you please provide the complete logs for the affected server? Additionally, can you please execute the following shell script:
This script will collect iostat data each second, and will help us to correlate the CPU numbers to events recorded in the diagnostic.data. After running this script and reproducing this issue, please upload both the iostat.log and the contents of the diagnostic.data to this ticket. Thank you, | ||||||||||||||||||||||
| Comment by Ivan Artemov [ 07/Apr/16 ] | ||||||||||||||||||||||
|
Indexes on Posts collection. |