Sql-server – Sql server cpu usage is 140%

linuxsql serverUbuntu

I run Sql server instance and a dot.net core app on the same server for a while and today is the first time I came across with this issue, my website doesn't get data from the server and it gets this error:

There is insufficient system memory in resource pool 'internal' to run
this query. Error: 596, Severity: 21, State: 1. (Params:). The error
is printed in terse mode because there was error during formatting.
Tracing, ETW, notifications etc are skipped. A severe error occurred
on the current command. The results, if any, should be discarded.

and this error as well:

Timeout expired. The timeout period elapsed prior to completion of
the operation or the server is not responding.

The sql server version:

Microsoft SQL Server 2017 (RTM-CU16) (KB4508218) – 14.0.3223.3 (X64)
Jul 12 2019 17:43:08 Copyright (C) 2017 Microsoft Corporation
Express Edition (64-bit) on Linux (Ubuntu 16.04.6 LTS)

I typed the top command and I got this:

It used to work fine for more than 3 months without any error.
How can I find out what is causing Sql server to use all this cpu all of a sudden?

Best Answer

You should familiarize yourself more with top - it shows > 100% because it displays this data as a percentage of a single CPU and presumably you have more than one of those.

I'd recommend a more robust monitoring setup for your SQL Server. The MS CAT team has a good article on how to do this for SQL Server on Linux.

Finally, stop running your application and SQL Server on the same host. Your error is actually concerning a lack of memory, of which you are probably capping SQL Server from using and/or it is competing with the application for. More resource contention issues like this are probable in the future with keeping both on the same host, as well as security concerns, patching difficulties, and more.