Skip to content

Commit cc63641

Browse files
committed
fix(test): watch bottleneck attribution — distinguish server vs local
When wait > 300s, now checks: - Active TCP connections at connect() return → server-side long-poll - No connections + network_sent ≈ 0 → local blocking (checkpoint/reconcile/schema) Previous report incorrectly said 'long-poll' when data shows no TCP connections and zero bytes sent — the 318s is pyturso internal blocking IO (cf. tursodatabase/turso#7349), not waiting for server.
1 parent 35179c7 commit cc63641

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

data/Test/PullDB.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -876,10 +876,23 @@ def _net_monitor():
876876
print(f" ⚠ TCP 重传率偏高 ({total_retrans} 段)")
877877
print(f" 建议: 检查网络链路质量")
878878
elif wait_s > 300:
879-
print(f" ℹ 网络基本正常,瓶颈在 pyturso 内部 long-poll")
880-
print(f" .db 下载: {db_stable_t - db_appeared_t:.1f}s" if db_appeared_t and db_stable_t else "")
879+
# 判断瓶颈在服务端还是本地
880+
# 如果 connect 返回时无 TCP 连接 + network_sent ≈ 0 → 本地阻塞处理
881+
# 如果有活跃 TCP 连接 → 服务端 long-poll
882+
has_active_conn = psutil_end.get("connections") if psutil_ok else None
883+
sent_bytes = stats_info.get("network_sent_bytes", 0) if stats_info else 0
884+
885+
if has_active_conn or sent_bytes > 1024:
886+
bottleneck = "pyturso 服务端 long-poll(等待服务端确认同步)"
887+
else:
888+
bottleneck = "pyturso 本地阻塞处理(checkpoint/reconcile/schema 等)"
889+
890+
print(f" ℹ 网络基本正常,瓶颈在 {bottleneck}")
891+
if db_appeared_t is not None and db_stable_t is not None:
892+
print(f" .db 下载: {db_stable_t - db_appeared_t:.1f}s")
881893
print(f" 等待 sidecar: {wait_s:.1f}s")
882894
print(f" 网络中断: {total_outage_s:.1f}s")
895+
print(f" TCP 连接: {'有' if has_active_conn else '无'} 发包: {sent_bytes / 1024:.1f} KB")
883896
print(f" 建议: 这是 pyturso beta 版本的已知行为")
884897
print(f" 应用层用后台线程 + readiness gate 包容慢启动")
885898
else:

0 commit comments

Comments
 (0)