Pause Manager causes events not being uploaded on FlushAndTeardown

オープン
#1,120 コメント 2 件 リアクション 2 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
42/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
cpp
領域
api

調査の方向性

lib/api/LogManagerImpl.cpp の FlushAndTeardown から開始し、lib/tpm/TransmissionPolicyManager.cpp の PauseGuard 関連ロジックを調査します。maxTeardownUploadTimeInSec を 2–5 秒に設定して短時間で終了する testapp のケースを再現し、その後、teardown 中に保留中のリクエストが試行され、キャッシュが排出されるか設定時間が経過した後にアプリが終了することを確認します。

索引モデルが issue の本文から書いたものです。

説明

bug

Problem Description

It seems like a change from 2021 is affecting the FlushAndTeardown sequence:
https://github.com/microsoft/cpp_client_telemetry/pull/829

Steps to reproduce.

  • Set maxTeardownUploadTimeInSec to 2-3-5 seconds.
  • Run a very short-lived testapp.
  • Observe the FlushAndTeardown method spinning aimlessly and not actually uploading.

What is the expected behavior?

Expected behavior is that the 2-3 seconds are spent on trying to upload pending requests. Once there are zero events left, app should unblock and exit. Ideally with evt_stats event turned off, it should be relatively fast exit. Why need to turn evt_stats off - it's an oversubscribed event that'd generate 401/403, thus it's a waste. And should be removed out of the equation.

What is the actual behavior?

SDK spins and doesn't upload anything at the end of the run.

Additional context.

I suspect these pieces of code related to PauseGuard are causing the problem:

https://github.com/microsoft/cpp_client_telemetry/blob/0177277d1dc194a7703ca87d40587b6148608b45/lib/tpm/TransmissionPolicyManager.cpp#L105

Because activity is paused here at the beginning of the FlushAndTeardown method, without actually waiting for events cache to be fully drained:
https://github.com/microsoft/cpp_client_telemetry/blob/0177277d1dc194a7703ca87d40587b6148608b45/lib/api/LogManagerImpl.cpp#L380

Instead of pausing - it's supposed to wait for the amount of time configured. Obviously FlushAndTeardown can't be called on mobile platforms on the main thread. It has to be called on the background thread. Calling this on foreground thread may cause ANR, and app getting killed.

The way it stands, it seems like short-lived apps and processes would experience "data loss", because their events get stuck and not attempted to be uploaded at the end of the short-lived app run.

主要言語
C
スター
102
フォーク
66
平均マージ
3日 10時間
マージ済み PR(30日)
10

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

microsoft/cpp_client_telemetry のほかの issue

microsoft/cpp_client_telemetry の issue をすべて見る

似ている issue

C の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。