log 2019/09/01 続き

Deflake Kestrel low response rate tests (#13532) · aspnet/AspNetCore@725fa34 · GitHub

このテストのコンテクストがわからないので少し見てく。

TestServer は以下。Kestrel 用のテストヘルパーらしい。こいつが TestConnection を作る。

AspNetCore/TestServer.cs at master · aspnet/AspNetCore · GitHub

TestConnection は以下。主要なメソッドは StreamBackedTestConnection が持ってる。

AspNetCore/TestConnection.cs at master · aspnet/AspNetCore · GitHub

StreamBackedTestConnection は以下。このクラスのメソッドが若干厄介で、内部で Assert してるやつがいる。例えば #Receive なんかがそう。

AspNetCore/StreamBackedTestConnection.cs at 68cc5e7846240bacc146854dfc6a175e30ff0f60 · aspnet/AspNetCore · GitHub

つまり PR での以下の部分は、引数が expected value でそれを受けられるかというもの。

Deflake Kestrel low response rate tests (#13532) · aspnet/AspNetCore@725fa34 · GitHub

このコミットでの主要な修正では DateHeaderValueManager という IHeartbeatHandler 実装のクラスが出てきている。internal な class だが興味深い。

AspNetCore/DateHeaderValueManager.cs at master · aspnet/AspNetCore · GitHub


BufferSegment use ArrayPool for over-sized allocs (#13495) · aspnet/AspNetCore@9399f09 · GitHub

Kestrel の PipeWriter のケースでは new byte[] より ArrayPool を使う方が良いということらしい。

docs.microsoft.com

ArrayPool は利用したことがなかったが、調べてみるとパフォーマンス関連でいくつか記事が見つかる。メモリの使い方の効率を上げるためのもののよう。一方で、Rent したら Return することも必要のように見える。


Update advancedRP.md (#14083) · aspnet/AspNetCore.Docs@79d84fd · GitHub

小さなドキュメントの修正


Reset ValueGenerated on owned types mapped to a different table. · aspnet/EntityFrameworkCore@554ec09 · GitHub

ValueGenerated は PK 等で自動生成される値のための属性だが、以下の例だと誤ってついてしまうらしい。

Mapping an owned type to a different table produces an error on SqlServer · Issue #17454 · aspnet/EntityFrameworkCore · GitHub

OrderDetails.OrderId は単なる外部キーのハズだが、これに ValueGenerated.OnAdd が付いてしまうよう。

修正内容の詳しい部分は理解できていないが、ProcessEntityTypeAnnotationChanged というイベント?を用意し、対処している。

生成された値 - EF Core | Microsoft Docs


Throw when deriving from an owned type. · aspnet/EntityFrameworkCore@c38ec37 · GitHub

以下の PR の通り、所有されている ( OwnsOne 等 ) モデルからの派生はできない。これまで一部できてしまっていたのを厳密にした。

Throw when non-owned type is derived from an owned type. · Issue #17429 · aspnet/EntityFrameworkCore · GitHub


Avoid infinite loop when processing InversePropertyAnnotation · aspnet/EntityFrameworkCore@1c5e308 · GitHub

挙動はよくわからないけど、 inverse を複数つけたときに loop し続けてエラーになってしまうケースがあるらしい。

EF Core の場合は inverse は 同じ型で別名の 2 つ以上の navigation がある時に使うって感じなんかな。