SE の雑記

SQL Server の情報をメインに Microsoft 製品の勉強内容を日々投稿

Author Archive

Azure Functions で PowerShell 7.0 が使用できるようになりました

leave a comment

アナウンスされていたのかがわかっていないのですが、以前から manually specify powershell version (e.g. 7) という Issue があり、Azure Functions の PowerShell 7.0 のサポートについてディスカッションが行われていました。

The rough ETA for official GA (including portal and tools support) is the beginning of July.

正式な GA は 7 月上旬ということになっていたので、ポータルを確認してみたところ、7.0 を選択できるようになっていました。
image

Windows 上で動作している PowerShell 7.0.0 として認識されていますね。

image

PowerShell 7.0 になると、ForEach-Object に追加された並列実行 が使用できるようになるのがうれしいですね。
(Foreach の Parallel については Example 11: Run slow script in parallel batches 以降の情報も参考になります)

 

Azure Functions の PowerShell のランタイムスタックですが、昔は関数のテンプレートは HTTP / Timger Trigger 程度だったと思っていたのですが、今は使用できるテンプレートが増えており、各種トリガーや Preview で Durable Functions のテンプレートも選択できるようになっています。
image

まだドキュメントは読めていないのですが、Durable Functions Support for PowerShell で Issue が上がっており、Github 上で、How to try Durable PowerShell functions として、チュートリアルが公開されています。

SQL Database 関連の関数を Timer トリガーで作ることは結構あるのですが、それ以外のトリガーは使っていなかったので、色々なトリガーを触ってみないとですね。

 

Visual Studio Code を使用した PowerShell の関数開発でも、PowerShell 7.0 を使用することができるようです。
PowerShell 7.0 を使用するためには、ランタイムバージョンは 3.0 を使用するようにして、次のような設定を行う必要があるようです。

1. Azure Functions Core Tool 3.x をインストールする

npm install -g azure-functions-core-tools@3

2. 「.vscode\settings.json」 の「azureFunctions.projectRuntime」を「~3」に変更
(Core Tool 3.x が入っていれば、デフォルトで ~3 になっていると思います)

3. 「local.settings.json」に「"FUNCTIONS_WORKER_RUNTIME_VERSION": "~7"」を追加

image

これで、VS Code で PowerShell Functions の開発を行った際の PowerShell のバージョンを 7.0 にすることができます。

Written by Masayuki.Ozawa

7月 18th, 2020 at 10:49 pm

Posted in Microsoft Azure

Tagged with

SQL Server / SQL Database パフォーマンスチューニング & トラブルシューティング シリーズ : SOS_SCHEDULER_YIELD の基本的な考え方について

leave a comment

SQL Server / SQL Database で CPU 使用状況が高い場合に発生する「待ち事象」としては、「SOS_SCHEDULER_YIELD」が有名ではないでしょうか。

待ち事象については、sys.dm_os_wait_stats (Transact-SQL) で解説が行われており、SOS_SCHEDULER_YIELD については、次のように解説が行われています。

タスクが、他のタスクの実行にスケジューラを自主的に解放したときに発生します。 この待機中、タスクはクォンタムの更新を待機しています。

 

これはどのようなことを表しているのでしょうか?

本投稿では、SOS_SCHEDULER_YIELD  の基本的な考え方について見ていきます。

Read the rest of this entry »

Written by Masayuki.Ozawa

7月 9th, 2020 at 9:13 pm

CXPACKET が発生している実行中のクエリのリソース情報の取得について

leave a comment

書こう、書こうと思っていながらかけていなかったのですが、What is MaxDOP controlling? という記事が公開されたので、良い機会と思い、CXPACKET が発生している実行中のクエリのリソース情報の取得についてまとめたいと思います。

Read the rest of this entry »

Written by Masayuki.Ozawa

7月 8th, 2020 at 9:57 pm

Data Factory の任意のアクティビティで Key Vault の情報を使用するためにシークレットから情報を取得

leave a comment

Azure Key Vault への資格情報の格納 で解説されていますが、Azure Data Factory (ADF) では、Linked Service を設定する際にパスワードの情報を Key Vault のシークレットから取得することができます。
image

Key Vault のコンテナーに対して、ADF の Managed Identity (マネージド ID) 権限を付与しておくことで、Linked Service としてリンクした Key Vault からシークレットから情報を取得して、Linked Service 内の設定で使用することができます。

これにより、Linked Service でパスワードを入力する必要がなくなり、パスワード変更が発生した場合も Key Vault の情報を変更することで対応ができるようになる等、いくつかのメリットを享受することができます。

Linked Service の情報を設定する際だけでなく、パイプライン内で Key Vault から情報を取得することができるかを試してみたので、メモとして。

今回はサブスクリプション ID を Key Vault のシークレットから取得しているのですが、この程度の情報であれば、パイプライン実行時のパラメーターで指定してもよいと思いますが。

Read the rest of this entry »

Written by Masayuki.Ozawa

7月 8th, 2020 at 7:49 pm

Posted in Data Factory

Tagged with

SQL Database に接続する際の接続フローについて

leave a comment

2020/7/1 に SQL Database で次のような障害が発生しました。

7/1

Azure SQL Database – Japan East – Mitigated (Tracking ID CLCK-LD0)

Summary of Impact: Between 09:30 and 11:15 UTC on 01 Jul 2020, a subset of customers using SQL Database in Japan East may have experienced service connection failures or possible timeouts. Services utilizing SQL Databases may have also been impacted.

Preliminary Root Cause: We determined that instances of a gateway service responsible for handling traffic to and from some SQL Databases became unhealthy. This prevented some connections from completing as expected and caused downstream impact to services leveraging SQL Databases.

Mitigation: We performed a manual restart of the impacted gateways to mitigate the issue.

Next Steps: We will continue to investigate to establish the full root cause and prevent future occurrences. A full Root-Cause Analysis will be provided in the next 72 hours. Stay informed about Azure service issues by creating custom service health alerts: https://aka.ms/ash-videos for video tutorials and https://aka.ms/ash-alerts for how-to documentation.

最終的な RCA (Root Cause Analysis : 根本原因解析) としては、次のような内容が公開されています。

Summary of impact: Between 09:24 and 11:15 UTC on 01 Jul 2020, a subset of customers using Azure SQL Database, Azure SQL Data Warehouse/ Synapse analytics in Japan East may have experienced service connection failures or possible timeouts. Services utilizing SQL Databases may have also been impacted.

Root cause: Connections to Azure SQL Database and related data services go through a load balanced set of front-end nodes (Gateways) that provide directory lookup services and reroute the incoming connections to the intended backend-end nodes hosting the database. For scalability and zone redundancy purposes, there are multiple active SQL Gateway clusters in a region. During this incident, one of the SQL Gateway clusters became unhealthy having an intermittent impact on login availability. A specific network traffic pattern combined with a networking stack configuration on the SQL Gateway instances triggered an imbalance on the CPU processing of new connection requests. The persistence of such CPU imbalance over a long period of time caused high response latency and increased timeouts on connection requests. The error condition propagated across multiple instances of the SQL Gateway cluster in this region, sometimes causing a service restart.

Mitigation: Multiple SQL Gateway instances became healthy upon the triggered service restart. On further investigation, we were able to isolate the specific network pattern and the configuration setting that caused this incident and were able to reconfigure the traffic to prevent a recurrence.

Next Steps: We apologize for the impact to affected customers. We are continuously taking steps to improve the Microsoft Azure platform and our processes to help ensure such incidents do not occur in the future. In this case, this includes (but is not limited to):

  • Fix the underlying issue that causes service restart when such a condition occurs.
  • Improve the alerting logic and add identified telemetry to diagnose this kind of issues faster.
  • Activate a newer SQL Gateway cluster in this region with a more efficient networking stack configuration that reduces the chances of hitting a processing imbalance.

障害の原因としては、「SQL Gateway クラスタ」の一つで問題が発生し、新規接続要求の CPU 処理の問題や、エラーが複数の SQL Gateway クラスターに伝搬しサービスが再起動してしまい、ログインと可用性に断続的に影響を与えたということになっています。

この障害が発生していた際には、既存の接続ついては接続が維持できていたが、新規の接続が許可されないというような状態になっていた環境もあったのではないでしょうか。

障害が発生している最中に、新規の接続を試してみたのですが、SQL Database の論理サーバー名への接続を行おうとしてもタイムアウトが発生 / Pre-Login のフェーズまでは進んだが、そこから先に進むことができず、エラーとなるというような状態となっており、新規の接続を確立することができませんでした。

障害が回復した後に、SQL Database のセッションの状態や起動タイミングを確認してみたところ、データベースについては再起動が行われておらず、いくつかのセッションについては接続が切断されず残ったままとなっていましたので、私の環境については、データベースでは問題は発生しておらず、ゲートウェイ経由での接続のみ問題が発生していたようでした。

 

以前、SQL Database v12 の接続のリダイレクトについて という投稿を書いたのですが、改めて、SQL Database に接続する際には、どのような動作が行われているのかをまとめてみたいと思います。

 

Read the rest of this entry »

Written by Masayuki.Ozawa

7月 7th, 2020 at 10:10 pm

Synapse Analytics の 2020/7 のリリースノートが公開されています

leave a comment

Synapse Analytics の 2020/7 のリリースノートが公開されています。

July 2020

今月の更新内容はこちら。

image

 

行レベルの暗号化 / 互換性レベルの GA / 行レベルセキュリティ (RLS) が新機能となるようですね。

Written by Masayuki.Ozawa

7月 7th, 2020 at 8:30 pm

Posted in Synapse Analytics

Tagged with

Microsoft MVP アワードを再受賞させていただきました

leave a comment

Microsoft Most Valuable Professional (MVP) アワードを、 Data Platform のカテゴリで今年も再受賞させていただきました。

早いもので、受賞させていただいてからもう 10 年になるのですね。

10 年前は、Windows 以外のプラットフォームで SQL Server を使用することや、PDW (Parallel Data Warehouse / Microsoft Analytics Platform System (APS)) のアーキテクチャを手軽に触ることができるようになるとは全く思っていませんでしたが、SQL Server ベースの環境も様々な進化が行われましたね (しみじみ)

海外の SQL Server の MVP / エンジニアの方の発信している情報と比較して、情報の密度/深度が低く、公式のドキュメント等で発信されている内容を整理したような情報の発信しかできておらず、「このような情報しか発信できていない状態で、コミュニティ活動への貢献と言えるのだろうか?」と悩んだのですが、今年も受賞させていただくことができました。

前回の受賞期間の中では、あまりコミュニティ登壇をする時間が取れず、ブログによる情報発信がメインだったのですが、今年は登壇も少し再開したいかなと。

ぼちぼち、SQL Server / SQL Database だけでなく、Data Platform のスキルを伸ばさなくてはいけない今日この頃ですが、引き続きよろしくお願いいたします。

Written by Masayuki.Ozawa

7月 2nd, 2020 at 7:58 am

Posted in MVP

Tagged with

SQL Server / SQL Database パフォーマンスチューニング & トラブルシューティング シリーズ : SQL Server へのクエリ実行時の「コマンド タイムアウト」の挙動について

leave a comment

本ブログでは、次の投稿で SQL Server へのクエリ実行時の「コマンド タイムアウト」(クエリ タイムアウト) について触れてみました。

 

そもそも「コマンド タイムアウト」とは何なのでしょうか?
上記の投稿では触れていなかった部分についてもまとめておきたいと思います。

Read the rest of this entry »

Written by Masayuki.Ozawa

6月 30th, 2020 at 10:38 pm

Posted in SQL Server

Tagged with

PowerShell (7.0.2) で Microsoft.Data.SqlClient 2.0 を使用する

leave a comment

Released: General Availability of Microsoft.Data.SqlClient 2.0 でアナウンスされましたが、.NET で SQL Server にアクセスするための最新のデータプロバイダーである Microsoft.Data.SqlClient 2.0 がリリースされました。

アナウンスや、リリースノート でも触れられていますが、いくつかの機能が追加されています。

Some of the highlights of new features over the 1.1 release of Microsoft.Data.SqlClient include:

 

PowerShell から新機能の検証をしようと思ったところ、Microsoft.Data.SqlClient 2.0 を使用するのにちょっとハマったので、メモを残しておこうかと。

動作方法がよくわかっていなかったので、”Microsoft.Data. SqlClient is not supported on this platform.” when trying to use it in PowerShell 7.0.2 で助けていただきました (感謝)

Microsoft.Data.SqlClient with PowerShell も参考にさせていただきました。
(本ドキュメントを書かれていた方に Issue でヘルプいただけて感謝、感謝)

Microsoft.Data.SqlClient については Microsoft.Data.SqlClient 名前空間の概要 でドキュメントが公開されていますので、こちらも確認すると良いかと思います。

Read the rest of this entry »

Written by Masayuki.Ozawa

6月 22nd, 2020 at 9:52 pm

Posted in PowerShell,SQL Server

Tagged with ,

SQL Server 側でエラーを取得するための方法

leave a comment

以前、次の投稿を書きました。

これらの投稿では、「アプリケーションからのクエリタイムアウト (コマンドタイムアウト)」を SQL Server 側 (DB サーバーサイド) で取得する方法について記載を行いました。
(本ブログでも何回か書いていますが、クエリのタイムアウトは「アプリケーションから発行された Attention のメッセージにより、SQL Server がクエリをキャンセルする処理」ですので、クエリをタイムアウトさせているのは、SQL Server ではなく、クエリを発行したアプリケーション側の処理となります)

SQL Server に対してクエリを実行する際に発生するのは、クエリタイムアウトだけでなく、様々なエラーがあります。

本投稿では、クエリタイムアウト以外のエラーを SQL Server 側で取得する方法の一例について紹介したいと思います。

クエリのタイムアウトや、クエリの実行の失敗については、クエリ実行側 (アプリケーション側) で取得した方が正確かと思いますので、SQL Server で全てをキャッチするのではなくアプリケーション (または、APM のような仕組み) でエラーを把握した方が良いと思います。
(DB に対してのクエリ実行でエラーが発生すると、SQL Server 側の調査のみで原因を特定してくれという依頼が多いのですよね…。)

Read the rest of this entry »

Written by Masayuki.Ozawa

6月 18th, 2020 at 11:04 pm

Posted in SQL Server

Tagged with