|
А как посмотреть кто использует темпдб на read-only ноде в кластере?
|
|||
---|---|---|---|
#18+
Добрый день. Есть олвейс-он кластер. На реплике разрастается темпдб. А как посмотреть какие именно сессии ее используют? ... |
|||
:
Нравится:
Не нравится:
|
|||
22.11.2021, 14:02 |
|
А как посмотреть кто использует темпдб на read-only ноде в кластере?
|
|||
---|---|---|---|
#18+
Код: sql 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72. 73. 74. 75. 76. 77.
... |
|||
:
Нравится:
Не нравится:
|
|||
22.11.2021, 14:29 |
|
А как посмотреть кто использует темпдб на read-only ноде в кластере?
|
|||
---|---|---|---|
#18+
Gallemar Код: sql 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72. 73. 74. 75. 76. 77.
Да в том-то и дело.... The target database ('Prod') is in an availability group and is currently accessible for connections when the application intent is set to read only. For more information about application intent, see SQL Server Books Online. ... |
|||
:
Нравится:
Не нравится:
|
|||
22.11.2021, 15:01 |
|
А как посмотреть кто использует темпдб на read-only ноде в кластере?
|
|||
---|---|---|---|
#18+
qqq_2, добавьте use master; ... |
|||
:
Нравится:
Не нравится:
|
|||
22.11.2021, 15:11 |
|
А как посмотреть кто использует темпдб на read-only ноде в кластере?
|
|||
---|---|---|---|
#18+
Gallemar qqq_2, добавьте use master; ошибка та же. ... |
|||
:
Нравится:
Не нравится:
|
|||
22.11.2021, 15:17 |
|
А как посмотреть кто использует темпдб на read-only ноде в кластере?
|
|||
---|---|---|---|
#18+
qqq_2, не верю. Покажи целиком какой запрос ты выполняешь. ... |
|||
:
Нравится:
Не нравится:
|
|||
22.11.2021, 15:24 |
|
А как посмотреть кто использует темпдб на read-only ноде в кластере?
|
|||
---|---|---|---|
#18+
Gallemar qqq_2, не верю. Покажи целиком какой запрос ты выполняешь. Я бы хотел тоже не верить, но факт есть факт. ... |
|||
:
Нравится:
Не нравится:
|
|||
22.11.2021, 15:32 |
|
А как посмотреть кто использует темпдб на read-only ноде в кластере?
|
|||
---|---|---|---|
#18+
а такой если выполнить? -- space used in Tempdb: use master; select t1.session_id /*, t1.request_id*/ , task_alloc_GB = cast((t1.task_alloc_pages * 8./1024./1024.) as numeric(10,1)) , task_dealloc_GB = cast((t1.task_dealloc_pages * 8./1024./1024.) as numeric(10,1)) , host= case when t1.session_id <= 50 then 'SYS' else s1.host_name end , s1.login_name , s1.status , s1.last_request_start_time , s1.last_request_end_time , s1.row_count , s1.transaction_isolation_level , query_text= coalesce((SELECT SUBSTRING(text, t2.statement_start_offset/2 + 1, (CASE WHEN statement_end_offset = -1 THEN LEN(CONVERT(nvarchar(max),text)) * 2 ELSE statement_end_offset END - t2.statement_start_offset)/2) FROM sys.dm_exec_sql_text(t2.sql_handle)) , 'Not currently executing') , query_plan=(SELECT query_plan from sys.dm_exec_query_plan(t2.plan_handle)) from (Select session_id, request_id , task_alloc_pages=sum(internal_objects_alloc_page_count + user_objects_alloc_page_count) , task_dealloc_pages = sum (internal_objects_dealloc_page_count + user_objects_dealloc_page_count) from sys.dm_db_task_space_usage group by session_id, request_id) as t1 left join sys.dm_exec_requests as t2 on t1.session_id = t2.session_id and t1.request_id = t2.request_id left join sys.dm_exec_sessions as s1 on t1.session_id=s1.session_id where t1.session_id > 50 -- ignore system unless you suspect there's a problem there and t1.session_id <> @@SPID -- ignore this request itself order by t1.task_alloc_pages DESC; GO ... |
|||
:
Нравится:
Не нравится:
|
|||
22.11.2021, 15:43 |
|
А как посмотреть кто использует темпдб на read-only ноде в кластере?
|
|||
---|---|---|---|
#18+
Gallemar а такой если выполнить? -- space used in Tempdb: use master; select t1.session_id /*, t1.request_id*/ , task_alloc_GB = cast((t1.task_alloc_pages * 8./1024./1024.) as numeric(10,1)) , task_dealloc_GB = cast((t1.task_dealloc_pages * 8./1024./1024.) as numeric(10,1)) , host= case when t1.session_id <= 50 then 'SYS' else s1.host_name end , s1.login_name , s1.status , s1.last_request_start_time , s1.last_request_end_time , s1.row_count , s1.transaction_isolation_level , query_text= coalesce((SELECT SUBSTRING(text, t2.statement_start_offset/2 + 1, (CASE WHEN statement_end_offset = -1 THEN LEN(CONVERT(nvarchar(max),text)) * 2 ELSE statement_end_offset END - t2.statement_start_offset)/2) FROM sys.dm_exec_sql_text(t2.sql_handle)) , 'Not currently executing') , query_plan=(SELECT query_plan from sys.dm_exec_query_plan(t2.plan_handle)) from (Select session_id, request_id , task_alloc_pages=sum(internal_objects_alloc_page_count + user_objects_alloc_page_count) , task_dealloc_pages = sum (internal_objects_dealloc_page_count + user_objects_dealloc_page_count) from sys.dm_db_task_space_usage group by session_id, request_id) as t1 left join sys.dm_exec_requests as t2 on t1.session_id = t2.session_id and t1.request_id = t2.request_id left join sys.dm_exec_sessions as s1 on t1.session_id=s1.session_id where t1.session_id > 50 -- ignore system unless you suspect there's a problem there and t1.session_id <> @@SPID -- ignore this request itself order by t1.task_alloc_pages DESC; GO Точно такая же ошибка. ... |
|||
:
Нравится:
Не нравится:
|
|||
22.11.2021, 18:00 |
|
А как посмотреть кто использует темпдб на read-only ноде в кластере?
|
|||
---|---|---|---|
#18+
В SQL Server наверное редко используется кластер и ошибку подобную мало кто встречал ((( ... |
|||
:
Нравится:
Не нравится:
|
|||
22.11.2021, 18:01 |
|
А как посмотреть кто использует темпдб на read-only ноде в кластере?
|
|||
---|---|---|---|
#18+
qqq_2 Gallemar а такой если выполнить? -- space used in Tempdb: use master; select t1.session_id /*, t1.request_id*/ , task_alloc_GB = cast((t1.task_alloc_pages * 8./1024./1024.) as numeric(10,1)) , task_dealloc_GB = cast((t1.task_dealloc_pages * 8./1024./1024.) as numeric(10,1)) , host= case when t1.session_id <= 50 then 'SYS' else s1.host_name end , s1.login_name , s1.status , s1.last_request_start_time , s1.last_request_end_time , s1.row_count , s1.transaction_isolation_level , query_text= coalesce((SELECT SUBSTRING(text, t2.statement_start_offset/2 + 1, (CASE WHEN statement_end_offset = -1 THEN LEN(CONVERT(nvarchar(max),text)) * 2 ELSE statement_end_offset END - t2.statement_start_offset)/2) FROM sys.dm_exec_sql_text(t2.sql_handle)) , 'Not currently executing') , query_plan=(SELECT query_plan from sys.dm_exec_query_plan(t2.plan_handle)) from (Select session_id, request_id , task_alloc_pages=sum(internal_objects_alloc_page_count + user_objects_alloc_page_count) , task_dealloc_pages = sum (internal_objects_dealloc_page_count + user_objects_dealloc_page_count) from sys.dm_db_task_space_usage group by session_id, request_id) as t1 left join sys.dm_exec_requests as t2 on t1.session_id = t2.session_id and t1.request_id = t2.request_id left join sys.dm_exec_sessions as s1 on t1.session_id=s1.session_id where t1.session_id > 50 -- ignore system unless you suspect there's a problem there and t1.session_id <> @@SPID -- ignore this request itself order by t1.task_alloc_pages DESC; GO Точно такая же ошибка. Не верю. Проверяю в аналогичных условиях. Такая ошибка при попытке сделать запрос к неслужебной бд ... |
|||
:
Нравится:
Не нравится:
|
|||
22.11.2021, 18:46 |
|
А как посмотреть кто использует темпдб на read-only ноде в кластере?
|
|||
---|---|---|---|
#18+
qqq_2, Tak moget poprobovat ustanovit context "intent is set to read only" v connect SSMS? ... |
|||
:
Нравится:
Не нравится:
|
|||
22.11.2021, 19:43 |
|
А как посмотреть кто использует темпдб на read-only ноде в кластере?
|
|||
---|---|---|---|
#18+
ПалЪ СанычЪ qqq_2, Tak moget poprobovat ustanovit context "intent is set to read only" v connect SSMS? Как вариант, хотя должно работать и без этого. ... |
|||
:
Нравится:
Не нравится:
|
|||
22.11.2021, 20:00 |
|
А как посмотреть кто использует темпдб на read-only ноде в кластере?
|
|||
---|---|---|---|
#18+
ПалЪ СанычЪ qqq_2, Tak moget poprobovat ustanovit context "intent is set to read only" v connect SSMS? либо так. либо в запросе вытереть кусок про получение плана запроса ... |
|||
:
Нравится:
Не нравится:
|
|||
22.11.2021, 20:09 |
|
А как посмотреть кто использует темпдб на read-only ноде в кластере?
|
|||
---|---|---|---|
#18+
ПалЪ СанычЪ qqq_2, Tak moget poprobovat ustanovit context "intent is set to read only" v connect SSMS? Спасибо, так сработало. ... |
|||
:
Нравится:
Не нравится:
|
|||
22.11.2021, 21:19 |
|
А как посмотреть кто использует темпдб на read-only ноде в кластере?
|
|||
---|---|---|---|
#18+
Gallemar ПалЪ СанычЪ qqq_2, Tak moget poprobovat ustanovit context "intent is set to read only" v connect SSMS? Как вариант, хотя должно работать и без этого. Без этого не хочет. А подскажите, как этот параметр в SQLAgent вставить? ... |
|||
:
Нравится:
Не нравится:
|
|||
22.11.2021, 21:20 |
|
А как посмотреть кто использует темпдб на read-only ноде в кластере?
|
|||
---|---|---|---|
#18+
Подскажите как в sqlcmd впихнуть context intent is set to read only ? ... |
|||
:
Нравится:
Не нравится:
|
|||
24.11.2021, 19:30 |
|
А как посмотреть кто использует темпдб на read-only ноде в кластере?
|
|||
---|---|---|---|
#18+
qqq_2 Подскажите как в sqlcmd впихнуть context intent is set to read only ? Нашел -K ReadOnly ... |
|||
:
Нравится:
Не нравится:
|
|||
24.11.2021, 19:35 |
|
А как посмотреть кто использует темпдб на read-only ноде в кластере?
|
|||
---|---|---|---|
#18+
В общем, мне надо сохранить куда-то резальтат этого скрипта, а как не пойму, ведь БД на реплики в реадонли и туда ничего не пишется :( ... |
|||
:
Нравится:
Не нравится:
|
|||
24.11.2021, 19:36 |
|
А как посмотреть кто использует темпдб на read-only ноде в кластере?
|
|||
---|---|---|---|
#18+
qqq_2 В общем, мне надо сохранить куда-то резальтат этого скрипта, а как не пойму, ведь БД на реплики в реадонли и туда ничего не пишется :( сделай экспорт результата в csv ... |
|||
:
Нравится:
Не нравится:
|
|||
24.11.2021, 20:53 |
|
А как посмотреть кто использует темпдб на read-only ноде в кластере?
|
|||
---|---|---|---|
#18+
qqq_2 В общем, мне надо сохранить куда-то резальтат этого скрипта, а как не пойму, ведь БД на реплики в реадонли и туда ничего не пишется :( сохранить можно - в темпдб (до рестарта) - в master/msdb - через линкед-сервер куда-то еще ... |
|||
:
Нравится:
Не нравится:
|
|||
24.11.2021, 21:07 |
|
А как посмотреть кто использует темпдб на read-only ноде в кластере?
|
|||
---|---|---|---|
#18+
Gallemar qqq_2 В общем, мне надо сохранить куда-то резальтат этого скрипта, а как не пойму, ведь БД на реплики в реадонли и туда ничего не пишется :( сделай экспорт результата в csv Так и сделал. ... |
|||
:
Нравится:
Не нравится:
|
|||
26.11.2021, 15:57 |
|
А как посмотреть кто использует темпдб на read-only ноде в кластере?
|
|||
---|---|---|---|
#18+
komrad qqq_2 В общем, мне надо сохранить куда-то резальтат этого скрипта, а как не пойму, ведь БД на реплики в реадонли и туда ничего не пишется :( сохранить можно - в темпдб (до рестарта) - в master/msdb - через линкед-сервер куда-то еще Через линкед не получилось. Но вопрос уже не в этом. ... |
|||
:
Нравится:
Не нравится:
|
|||
26.11.2021, 15:58 |
|
А как посмотреть кто использует темпдб на read-only ноде в кластере?
|
|||
---|---|---|---|
#18+
В общем, проблема такая: Когда дико начинает рости tempdb (с 1 Гб до 200Гб за пол часа), этот скрипт: 22399145 Не показывает ни одной сессии, которая бы как-либо сильно использовала tempdb. Т.е. я его выполнил во время роста раз 10 и он ни разу не показал использование темп БД более 100мб. Суммарно по всем сессия мож 200Мб и было, но не больше. Скажите, как увидеть кто же использует tempdb в действительности? Пока есть версия что это связано с репкой и где-то там для служебных нужд может использоваться уровень изоляции транзакций снэпшот... но в сессия везде рид коммитет показывает ( ... |
|||
:
Нравится:
Не нравится:
|
|||
26.11.2021, 16:02 |
|
А как посмотреть кто использует темпдб на read-only ноде в кластере?
|
|||
---|---|---|---|
#18+
qqq_2, посмотрите, может у вас version store место отъедает https://thesurfingdba.weebly.com/my-version-store-is-huge.html ... |
|||
:
Нравится:
Не нравится:
|
|||
26.11.2021, 16:13 |
|
А как посмотреть кто использует темпдб на read-only ноде в кластере?
|
|||
---|---|---|---|
#18+
qqq_2, tempdb используется для хранения версий строк, может это как-то связано с RCSI, не знаю точно. ... |
|||
:
Нравится:
Не нравится:
|
|||
26.11.2021, 16:18 |
|
А как посмотреть кто использует темпдб на read-only ноде в кластере?
|
|||
---|---|---|---|
#18+
Владислав Колосов qqq_2, tempdb используется для хранения версий строк, может это как-то связано с RCSI, не знаю точно. А как можно проверить? ... |
|||
:
Нравится:
Не нравится:
|
|||
26.11.2021, 16:23 |
|
А как посмотреть кто использует темпдб на read-only ноде в кластере?
|
|||
---|---|---|---|
#18+
komrad qqq_2, посмотрите, может у вас version store место отъедает https://thesurfingdba.weebly.com/my-version-store-is-huge.html Не открывается ссылочка. Если у вас открывается, можете сюда скапировать текст? ... |
|||
:
Нравится:
Не нравится:
|
|||
26.11.2021, 16:24 |
|
А как посмотреть кто использует темпдб на read-only ноде в кластере?
|
|||
---|---|---|---|
#18+
кстати, непноятно почему она растет, если БД в реадонли... ... |
|||
:
Нравится:
Не нравится:
|
|||
26.11.2021, 16:25 |
|
А как посмотреть кто использует темпдб на read-only ноде в кластере?
|
|||
---|---|---|---|
#18+
qqq_2 komrad qqq_2, посмотрите, может у вас version store место отъедает https://thesurfingdba.weebly.com/my-version-store-is-huge.html Не открывается ссылочка. Если у вас открывается, можете сюда скапировать текст? содержимое My Version Store is huge!!!! Are you using Read Committed Snapshot isoloation? We are and it is blowing up our TempDB. I began to investigate why TempDB is growing so large especially on some of my production servers. I found that our main prod databases are using Read Committed Snapshot Isolation or (RCSI). This isolation level changes the type of concurrency that SQL Server will use. By default SQL Server uses pessimistic locking mean writers block readers and readers block writers. RCSI is optimistic blocking, much like Oracle or Postgres. RCSI creates a version store. The version store contains the committed rows which is how a SELECT operation does not get blocked when another UPDATE/DELETE is operating on the same row, because the SELECT reads the row from the version store, instead of the actual base table. When you enable this, the row has to be stored somewhere and tempdb happens to be the place. A row is maintained in the version store when there are transactions operating on that row in question. When the transaction is committed, the row is cleaned up from the version store tables. Row versions must be stored for as long as an active transaction needs to access it. Once every minute, a background thread removes row versions that are no longer needed and frees up the version space in tempdb. A long-running transaction prevents space in the version store from being released if it meets any of the following conditions: • It uses row versioning-based isolation. • It uses triggers, MARS, or online index build operations. • It generates row versions. We are using two of the three conditions . The below query tells us how big the Version Store has grown. The Version store is 557 GBs which is over 10 times large than the prod database. I tried to do a row count to see how many rows were in the version store. I let it run for a couple hours and it never returned any results. SQL Dude helped with some of this content http://thesqldude.com/2012/05/15/monitoring-tempdb-space-usage-and-scripts-for-finding-queries-which-are-using-excessive-tempdb-space/ SELECT SUM (user_object_reserved_page_count)*8/1024.0/1024.0 as user_obj_GB, SUM (internal_object_reserved_page_count)*8/1024.0/1024.0 as internal_obj_GB, SUM (version_store_reserved_page_count)*8/1024.0/1024.0 as version_store_GB, SUM (unallocated_extent_page_count)*8/1024.0/1024.0 as freespace_GB, SUM (mixed_extent_page_count)*8/1024.0/1024.0 as mixedextent_GB FROM sys.dm_db_file_space_usage Continuing to look into the issue, I kept seeing queries with this statement, Implicit_Transactions. The default for SQL Server is Set Implicit_Transactions off. Below is from Microsoft Books Online regarding this issue. When ON, SET IMPLICIT_TRANSACTIONS sets the connection into implicit transaction mode. When OFF, it returns the connection to autocommit transaction mode. When a connection is in implicit transaction mode and the connection is not currently in a transaction, executing any of the following statements starts a transaction: ALTER TABLE FETCH REVOKE BEGIN TRANSACTION GRANT SELECT CREATE INSERT TRUNCATE TABLE DELETE OPEN UPDATE DROP I wanted to see if there any active transations. This is tricky when using RCSI as sometime active transactions will not show up with the usual tools such as DBCC opentran The below query shows us active transactions and active transactions being used by RCSI. select t.transaction_id,t.name,t.transaction_type, t.transaction_state, s.transaction_id,s.session_id, s.elapsed_time_seconds/60/60.0 as hours_tran_has_been_open, p.status, p.cmd from sys.dm_tran_active_transactions t join sys.dm_tran_active_snapshot_database_transactions s on t.transaction_id = s.transaction_id join sys.sysprocesses p on p.spid = s.session_id If Implicit_Transactions is being set to ON and connections to the database are not being closed this will cause the version store to grow which causes TempDB to grow which will either fill the disk or cause performance issue being that the version store is so large. Here is another great article on this https://www.red-gate.com/simple-talk/sql/performance/read-committed-snapshot-isolation-high-version_ghost_record_count/ ... |
|||
:
Нравится:
Не нравится:
|
|||
26.11.2021, 16:26 |
|
А как посмотреть кто использует темпдб на read-only ноде в кластере?
|
|||
---|---|---|---|
#18+
qqq_2 кстати, непноятно почему она растет, если БД в реадонли... например: запрос читает большую таблицу, которую модифицируют на первичной реплике при этом, версии читаемых данных переливаются в tempdb ... |
|||
:
Нравится:
Не нравится:
|
|||
26.11.2021, 16:31 |
|
|
start [/forum/topic.php?all=1&fid=46&tid=1684056]: |
0ms |
get settings: |
11ms |
get forum list: |
11ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
166ms |
get topic data: |
12ms |
get forum data: |
2ms |
get page messages: |
64ms |
get tp. blocked users: |
2ms |
others: | 13ms |
total: | 287ms |
0 / 0 |