{"id":1640,"date":"2012-12-03T07:58:55","date_gmt":"2012-12-03T09:58:55","guid":{"rendered":"http:\/\/fabriciolima.net\/blog\/?p=1640"},"modified":"2016-07-24T10:32:38","modified_gmt":"2016-07-24T13:32:38","slug":"database-mirroring-tempo-failover-hs-with-automatic-failover-com-timeout","status":"publish","type":"post","link":"https:\/\/fabriciolima.net\/blog\/2012\/12\/03\/database-mirroring-tempo-failover-hs-with-automatic-failover-com-timeout\/","title":{"rendered":"Database Mirroring &#8211; Tempo Failover &#8211; HS With Automatic Failover com Timeout"},"content":{"rendered":"<p>Ol\u00e1 Pessoal,<\/p>\n<p>A ideia desse teste \u00e9 verificar o tempo que o Database Mirroring leva para fazer um failover autom\u00e1tico de uma inst\u00e2ncia para o outra utilizando esse Operation mode, entretanto, agora a op\u00e7\u00e3o set partner timeout 60 ser\u00e1 utilizada.<\/p>\n<p>Inst\u00e2ncias participantes dos testes:<\/p>\n<p>1 &#8211; Instancia5\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211; Servidor Principal, referenciado no texto por Servidor A<br \/>\n2 &#8211; Instancia5\\INST1\u00a0\u00a0\u00a0 &#8211; Servidor Mirror, referenciado no texto por Servidor B<\/p>\n<p>Nome da database espelhada: Mirror1<\/p>\n<p>Script de cria\u00e7\u00e3o da tabela Teste:<\/p>\n<p>CREATE TABLE [dbo].[Teste](<br \/>\n[Cod] [int] IDENTITY(1,1) NOT NULL,<br \/>\n[Data] [datetime] NULL,<br \/>\n[Texto] [varchar](4000) NULL)<\/p>\n<p>Loop de insert do teste:<br \/>\nwhile 1=1<br \/>\nbegin<br \/>\nif exists (select null<br \/>\nfrom sys.databases<br \/>\nwhere name = &#8216;MIRROR1&#8217; and state_desc = &#8216;ONLINE&#8217;)<br \/>\ninsert into mirror1..Teste(texto)<br \/>\nselect @@servername<br \/>\nend<\/p>\n<p>Com um database mirroring configurado com o modo High Safety with Automatic Failover, foram executadas cinco queries com loops infinitos de Inserts.<\/p>\n<p>Antes de parar o servi\u00e7o do SQL Server, alterei uma configura\u00e7\u00e3o do mirror com o comando:<br \/>\nalter database Mirror1 set partner timeout 60<\/p>\n<p>Conferindo a configura\u00e7\u00e3o:<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/www.fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-15.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1923\" title=\"Figura 1\" src=\"https:\/\/www.fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-15.png\" alt=\"\" width=\"751\" height=\"202\" srcset=\"https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-15.png 851w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-15-300x81.png 300w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-15-768x207.png 768w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-15-700x188.png 700w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-15-410x110.png 410w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-15-100x27.png 100w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-15-275x74.png 275w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-15-20x5.png 20w\" sizes=\"auto, (max-width: 751px) 100vw, 751px\" \/><\/a><\/p>\n<p>Em seguida, foi parado o servi\u00e7o do SQL Server do servidor A simulando um poss\u00edvel problema.<\/p>\n<p>Como a query do loop possui uma verifica\u00e7\u00e3o que s\u00f3 realiza o insert quando a database est\u00e1 ONLINE, esse loop tamb\u00e9m ficou sendo executado no servidor B para que assim que a database ficasse online, um insert fosse feito nessa tabela.<\/p>\n<p>Assim, como a coluna Texto possui o nome do servidor onde o insert foi executado, \u00e9 poss\u00edvel medir o tempo de failover entre as duas instancias. Para isso, foi verificado quando a coluna Texto troca o nome do servidor e com isso \u00e9 poss\u00edvel saber a \u00faltima inser\u00e7\u00e3o em um ambiente e a primeira inser\u00e7\u00e3o em outro ambiente.<\/p>\n<p>Segue o resultado encontrado:<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/www.fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-24.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1924\" title=\"Figura 2\" src=\"https:\/\/www.fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-24.png\" alt=\"\" width=\"590\" height=\"169\" srcset=\"https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-24.png 635w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-24-300x86.png 300w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-24-410x118.png 410w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-24-100x29.png 100w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-24-275x79.png 275w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-24-20x6.png 20w\" sizes=\"auto, (max-width: 590px) 100vw, 590px\" \/><\/a><\/p>\n<p>Comparando as duas colunas do tipo datetime, temos que o tempo do failover autom\u00e1tico foi de <strong>1.9 segundos<\/strong>.<\/p>\n<p>Como pode ser verificado, o tempo de 60 segundos de timeout n\u00e3o fez diferen\u00e7a no tempo de failover.<\/p>\n<p>No link ( <a href=\"http:\/\/technet.microsoft.com\/en-us\/library\/cc917681.aspx\" target=\"_blank\">http:\/\/technet.microsoft.com\/en-us\/library\/cc917681.aspx<\/a> ), temos a seguinte informa\u00e7\u00e3o:<\/p>\n<p>Failure is detected: The failure is detected by the mirror and the witness. Hard failures (such as server power failure) are detected quickly (typically in around 1 second). Soft failures (such as storage failure) take a bit longer to detect. The default timeout for communication (a ping message) between the principal, the mirror, and the witness is 10 seconds. The timeout can be modified by using the ALTER DATABASE SET PARTNER TIMEOUT command. If the principal doesn\u2019t respond (to the ping message) within the timeout period, it is considered to be down. If you change the timeout setting, it is a best practices recommendation to set it to 10 seconds or higher. Setting it to lower than 10 seconds may result in false failures under heavily loaded or sporadic network conditions.<\/p>\n<p>No link (<a href=\"http:\/\/www.sqlmag.com\/blog\/sql-server-questions-answered-28\/sql-server\/why-isnt-the-mirroring-partner-timeout-working-137113\" target=\"_blank\">http:\/\/www.sqlmag.com\/blog\/sql-server-questions-answered-28\/sql-server\/why-isnt-the-mirroring-partner-timeout-working-137113<\/a> ), temos a seguinte informa\u00e7\u00e3o:<\/p>\n<p>The mirroring partner timeout only comes into play if the mirror server doesn&#8217;t get a response from the principal server at all\u2014in other words, <strong>if the Windows server hosting the principal SQL Server instance is offline for some reason<\/strong>. If the Windows server is still available, but SQL Server is offline, the principal Windows server will respond to the mirror server, saying that the principal SQL Server instance is offline. This lets the mirror server initiate a failover (as long as it gets quorum with the witness server, of course).<\/p>\n<p>Conclus\u00e3o: A op\u00e7\u00e3o SET PARTNER TIMEOUT s\u00f3 funciona quando as databases est\u00e3o em servidores diferentes, pois se apenas o servi\u00e7o do SQL Server parar, ela n\u00e3o serve para nada. \u00c9 necess\u00e1ria uma falha no Windows para o tempo de timeout ser utilizado.<\/p>\n<p>At\u00e9 o Pr\u00f3ximo Post sobre Database Mirroring.<\/p>\n<p>Artigos relacionados:<\/p>\n<p><a href=\"https:\/\/www.fabriciolima.net\/blog\/2012\/05\/15\/serie-de-posts-sobre-database-mirroring\/\" target=\"_blank\">S\u00e9rie de Posts sobre Database Mirroring<\/a><\/p>\n<p><a href=\"https:\/\/www.fabriciolima.net\/blog\/2012\/05\/15\/database-mirroring-como-alterar-o-operation-mode\/\" target=\"_blank\">Database Mirroring \u2013 Como alterar o Operation Mode<\/a><\/p>\n<p><a href=\"https:\/\/www.fabriciolima.net\/blog\/2012\/05\/23\/database-mirroring-testes-operation-mode-high-performance-parte-1\/\" target=\"_blank\">Database Mirroring \u2013 Operation Mode High Performance \u2013 Parte 1<\/a><\/p>\n<p><a href=\"https:\/\/www.fabriciolima.net\/blog\/2012\/05\/28\/database-mirroring-operation-mode-high-performance-parte-2\/\" target=\"_blank\">Database Mirroring \u2013 Operation Mode High Performance \u2013 Parte 2<\/a><\/p>\n<p><a href=\"https:\/\/www.fabriciolima.net\/blog\/2012\/05\/31\/database-mirroring-operation-mode-high-performance-parte-3\/\" target=\"_blank\">Database Mirroring &#8211; Operation Mode High Performance &#8211; Parte 3<\/a><\/p>\n<p><a rel=\"bookmark\" href=\"https:\/\/www.fabriciolima.net\/blog\/2012\/06\/27\/database-mirroring-operation-mode-high-safety-without-failover-parte-1\/\" target=\"_blank\">Database Mirroring \u2013 Operation Mode High Safety Without Failover \u2013  Parte 1<\/a><\/p>\n<p><a rel=\"bookmark\" href=\"https:\/\/www.fabriciolima.net\/blog\/2012\/06\/29\/database-mirroring-operation-mode-high-safety-without-failover-parte-2\/\" target=\"_blank\">Database Mirroring \u2013 Operation Mode High Safety Without Failover \u2013  Parte 2<\/a><\/p>\n<p><a href=\"https:\/\/www.fabriciolima.net\/blog\/2012\/10\/31\/database-mirroring-operation-mode-high-safety-with-automatic-failover\/\" target=\"_blank\">Database Mirroring \u2013 Operation Mode High Safety with Automatic Failover<\/a><\/p>\n<p><a href=\"https:\/\/www.fabriciolima.net\/blog\/2012\/11\/08\/database-mirroring-tempo-failover-hs-without-automatic-failover\/\" target=\"_blank\">Database Mirroring \u2013 Tempo Failover \u2013 HS Without Automatic Failover<\/a><\/p>\n<p><b>Gostou desse Post?<\/b><\/p>\n<p>Cadastre seu e-mail para receber novos Posts e curta minha <a href=\"https:\/\/www.facebook.com\/FabricioLimaSolucoesemBancodeDados\/\" target=\"_blank\">P\u00e1gina no Facebook<\/a> para receber Dicas de Leituras e Eventos sobre SQL Server.<\/p>\n<p>Abra\u00e7os,<\/p>\n<p>Fabr\u00edcio Lima<\/p>\n<p>MCITP \u2013 Database Administrator<\/p>\n<p>Consultor e Instrutor SQL Server<\/p>\n<p>Trabalha com SQL Server desde 2006<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ol\u00e1 Pessoal, A ideia desse teste \u00e9 verificar o tempo que o Database Mirroring leva para fazer um failover autom\u00e1tico de uma inst\u00e2ncia para o outra utilizando esse Operation mode, entretanto, agora a op\u00e7\u00e3o set partner timeout 60 ser\u00e1 utilizada. Inst\u00e2ncias participantes dos testes: 1 &#8211; Instancia5\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211; Servidor Principal, referenciado no texto por Servidor [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[3,280],"tags":[604,606,391,23,607,372,613,611,612,610,608,616,49,33,50,34,605,609,614,615],"class_list":["post-1640","post","type-post","status-publish","format-standard","hentry","category-administracao-de-bd","category-virtual-pass-br","tag-alta-disponibilidade","tag-database-mirror","tag-database-mirroring","tag-dba","tag-espelhamento-de-banco-de-dados","tag-high-availability","tag-high-performance","tag-high-safety-with-automatic-failover","tag-high-safety-without-automatic-failover","tag-operation-mode","tag-perda-de-dados","tag-safety","tag-sql","tag-sql-server","tag-sql-server-2005","tag-sql-server-2008","tag-sql-server-mirror","tag-sql-server-online","tag-sys-database_mirroring","tag-witness"],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/posts\/1640","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/comments?post=1640"}],"version-history":[{"count":0,"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/posts\/1640\/revisions"}],"wp:attachment":[{"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/media?parent=1640"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/categories?post=1640"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/tags?post=1640"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}