gRPC clients wait ~20 s on DNS for each connection when serverAddress is a short name

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

メンテナーはふだん 1 日以内に返信

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

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
go, grpc

調査の方向性

Start with the listed dials in core/internal/client/klioclient/grpcclient/connection.go:80 and core/cmd/admin/client.go:43, then trace the openGRPCAPIRepository dial in the Klio Kopia fork. Check how grpc-go's DNS resolver is configured and reproduce with a short serverAddress while watching CoreDNS logs. Done means short-name connections avoid the unused SRV and TXT lookups and connect without the DNS delay.

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

説明

Description

When serverAddress is a short name (for example klio-local.default), each
gRPC dial to the Klio server waits about 20 s before it connects.

The grpc-go dns resolver does two DNS lookups that Klio does not use:

  • SRV _grpclb._tcp.<host>
  • TXT _grpc_config.<host>

The pod has ndots:5, so these names do not match the cluster search domains.
CoreDNS sends them to the upstream DNS server. If the upstream server does not
answer, each lookup takes 10 s (5 s timeout, 2 attempts).

Kopia makes about 10 calls for each backup or restore. Because of this, a
32 MB backup takes 5 min 40 s. With the FQDN, the same backup takes 2 s.

This problem occurs in every environment where the upstream DNS is slow or
blocks SRV/TXT queries. One example is Docker Desktop 4.98.

Affected dials

  • Kopia fork (cloudnative-pg/kopia, branch klio): openGRPCAPIRepository.
    This dial causes most of the delay.
  • core/internal/client/klioclient/grpcclient/connection.go:80 (WAL streaming
    and WAL restore).
  • core/cmd/admin/client.go:43.

How to reproduce

  1. Set serverAddress to a short name, for example klio-local.default.
  2. Make sure that the upstream DNS does not answer TXT or SRV queries.
  3. Run kopia repository connect server from the klio-plugin container.
  4. Look at the CoreDNS logs. You see SRV: ... i/o timeout and
    TXT: ... i/o timeout for the server name.

Expected result

A short serverAddress connects as fast as the FQDN. Klio does not depend on
upstream DNS answers for SRV or TXT records.

Workaround

  • Use the FQDN as serverAddress and add it to the SANs of the server
    certificate.
  • Or set GRPC_ENABLE_TXT_SERVICE_CONFIG=false in the sidecar. This removes
    half of the delay.
主要言語
Go
スター
39
フォーク
10
平均マージ
19時間 58分
マージ済み PR(30日)
175

環境構築

はじめの一歩

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

cloudnative-pg/klio のほかの issue

cloudnative-pg/klio の issue をすべて見る

似ている issue

Go の issue をもっと見る

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

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