GPT Connector Live State Investigation — 2026-05-13
title: GPT Connector Live State Investigation — 2026-05-13 date: 2026-05-13 investigator: Claude Code (Opus 4.7) priority: P0 mode: Investigation during reported failure window schema_version_active: gpt-agent-data-2026-05-12.1 mcp_schema_hash: 5f13902e975a prompt_source: knowledge/dev/laws/dieu44-trien-khai/prompts/gpt-connector-live-state-investigation-2026-05-13.md
GPT Connector Live State Investigation — 2026-05-13
1. Kết luận ngắn
VPS hoàn toàn healthy tại thời điểm điều tra (2026-05-13 ~05:25–05:28 UTC, 07:25–07:30 CEST).
- Không có dấu hiệu cạn kiệt tài nguyên, không OOM, không worker restart, không upstream error.
- Cả MCP path (Claude dùng) và REST path (GPT dùng) đều trả 200 OK trên các probe trực tiếp từ VPS.
- Không tìm thấy bất kỳ event nào trên VPS giải thích pattern "chạy tốt → tự nhiên hỏng" mà người dùng mô tả.
→ Bằng chứng này củng cố root-cause đã xác định ngày 2026-05-12: lỗi nằm ngoài VPS, tại OpenAI action-gateway của Custom GPT (request không bao giờ rời được hạ tầng OpenAI). Xem knowledge/current-state/reports/gpt-agent-data-connector-recurrence-root-cause-2026-05-12.md.
2. Phase 1 — Snapshot tài nguyên
free -h:
total used free shared buff/cache available
Mem: 11Gi 4.0Gi 4.1Gi 142Mi 4.1Gi 7.7Gi
Swap: 2.0Gi 0B 2.0Gi
| Container | CPU% | MEM USAGE / LIMIT | MEM% | PIDs |
|---|---|---|---|---|
| incomex-agent-data | 1.54% | 1.444 GiB / 2.5 GiB | 57.75% | 42 |
| incomex-nginx | 0.00% | 30.46 MiB / 256 MiB | 11.90% | 9 |
| incomex-directus | 2.61% | 159.3 MiB / 1 GiB | 15.56% | 31 |
| incomex-qdrant | 0.72% | 129.9 MiB / 1 GiB | 12.69% | 32 |
| incomex-nuxt | 0.00% | 86.15 MiB / 512 MiB | 16.83% | 11 |
| postgres | 0.05% | 247.1 MiB / 2 GiB | 12.07% | 14 |
| uptime-kuma | 2.26% | 162.6 MiB / 11.68 GiB | 1.36% | 26 |
- Uptime: 89 ngày 20 giờ. Load average: 0.33 / 0.33 / 0.39.
- Disk
/: 50 GiB / 96 GiB (52%). - Swap đã dùng: 0B trên 2 GiB cấp phát.
- dmesg OOM: không có entry nào.
3. Phase 1b — Uvicorn workers
uvicorn agent_data.server:app --host 0.0.0.0 --port 8000 --workers 2
└── master PID 773732 (uptime since 2026-05-12)
├── resource_tracker PID 773783
├── worker 1 PID 773784 (CPU 3%, runtime 47m20s CPU)
└── worker 2 PID 774182 (CPU 3%, runtime 59m13s CPU)
- Master + 2 workers như cấu hình. Cả 2 worker đều healthy, CPU đều nhau, không có dấu hiệu kẹt.
docker inspect:RestartCount=0,StartedAt=2026-05-12T04:14:27Z,FinishedAt=0001-01-01(chưa từng dừng).
4. Phase 2 — Nginx upstream status
/var/log/nginx/error.log: 0 entries matchupstream|timeout|connect.*refused|no live(trong toàn bộ file)./var/log/nginx/access.log200 lines gần nhất: toàn bộ là 200 / 304 / 101. Không có 502, 504, 499, 503.
5. Phase 3 — Agent Data internals
- 2 giờ logs gần nhất chỉ chứa INFO lines:
connector_call wrapper=healthCheck/get_document/get_document_for_rewrite ... status=200,Qdrant probe OK,PostgreSQL probe OK. - ERROR duy nhất trong 6h:
2026-05-13 04:13:22 vector_sync_error2026-05-13 04:17:02 vector_sync_error2026-05-13 04:17:02 Failed to delete vector for knowledge/dev/laws/dieu44-trien-khai/design/p3d-birth-system-b3f1c-c-directus-nuxt-dot-scheduler-design.md: timed out→ Đây là Qdrant DELETE timeout trên một path duy nhất, KHÔNG nằm trên đường GPT → agent-data (GPT chỉ gọi search / get / list / mcp).
- Qdrant logs: không có error/compaction/oom/slow.
- PostgreSQL logs: có chuỗi deadlock detected trên
relation 44273(=meta_catalog) cứ ~10–30 phút (04:00, 04:20, 04:30, 04:40, 05:20 UTC). Hai process Directus đang tranhAccessExclusiveLock↔ShareLocktrên cùng tuple. Không liên quan tới GPT connector path (agent-data dùng PG cho changelog, không cho serving GPT request).
6. Phase 4 — Live probes
curl https://vps.incomexsaigoncorp.vn/api/health
Request 1: HTTP 200, 1.240s
Request 2: HTTP 200, 1.219s
Request 3: HTTP 200, 1.308s
Request 4: HTTP 200, 1.275s
Request 5: HTTP 200, 1.571s
Health payload trả về:
{"status":"healthy","version":"0.1.0","langroid_available":true,
"services":{"qdrant":{"status":"ok","latency_ms":6.6,"last_error":null},
"postgres":{"status":"ok","latency_ms":0.6},
"openai":{"status":"ok","latency_ms":0.0}},
"data_integrity":{"document_count":2827,"vector_point_count":5785,
"ratio":2.05,"sync_status":"warning"}}
MCP path:
POST /api/mcp method=initialize → 200, 114ms
POST /api/mcp method=tools/list → 200, 78ms
- REST
/healthchậm hơn (1.2 s) vì payload chạy đủ 3 probe Qdrant + PG + OpenAI mỗi lần. - MCP path nhanh (<120 ms). Nếu khách GPT thực sự gọi tới được VPS thì timing thừa ngân sách.
7. Phase 5 — Connection pool / concurrent requests
ss -tn state establishedtrong incomex-nginx: 0 (giữa các probe).ss -tn state established | grep :8000trong agent-data: 0.- Cấu hình:
worker_processes auto;,worker_connections 1024;.
→ Hệ thống đang idle, hoàn toàn không có hiện tượng pool exhaustion.
8. Phase 6 — Timeline correlation
- 6h gần nhất, agent-data ERROR/CRITICAL/Traceback: chỉ 2 vector_sync_error đã liệt kê ở Phase 3.
docker events6h: chỉ là health-probeexec_create/exec_start/exec_die(mọi exitCode=0). Không có eventdie,oom,kill,restartcho bất kỳ container nào.- Container restart count toàn cụm:
- agent-data: 25h uptime, 0 restart.
- nuxt: 15h uptime.
- postgres: 3 tuần uptime.
- nginx / directus / qdrant: 4 ngày – 7 tuần uptime.
9. Đối chiếu với giả thuyết ban đầu
Giả thuyết mạnh nhất từ prompt là "tài nguyên VPS cạn kiệt dần (memory leak, worker stuck, pool exhausted)". Bằng chứng phủ định cả 3:
| Giả thuyết | Bằng chứng |
|---|---|
| Memory leak / OOM | dmesg không có OOM, agent-data 57.75% mem ổn định, swap 0B, RestartCount=0 sau 25h uptime |
| Worker stuck | Cả 2 worker đều có CPU non-zero, MCP probe trả về <120 ms, REST probe nhất quán 1.2 s |
| Connection pool exhausted | 0 connection đang established lúc đo; nginx error log không có upstream timeout |
→ Giả thuyết "VPS resource exhaustion" không phù hợp với pattern "chạy tốt → tự nhiên hỏng → đổi phiên GPT vẫn lỗi". Nếu thật sự là resource exhaustion thì sau khi user nghỉ ngơi tài nguyên phải phục hồi và lần dùng tiếp theo phải chạy lại bình thường — nhưng user báo "đổi phiên GPT mới vẫn lỗi", tức trạng thái lỗi gắn với phía gọi (OpenAI), không gắn với VPS.
10. Hypothesis kế tiếp (cho lần điều tra sau)
Vì VPS được loại trừ, các giả thuyết còn lại tập trung phía OpenAI action-gateway:
- Schema cache sticky theo Custom GPT (không theo phiên user): gateway cache schema cũ (rest_schema_hash=aaec3d401df2) cho đến khi rebuild; rebuild xảy ra theo cơ chế nội bộ OpenAI không deterministic từ phía VPS.
- Auth/session token gateway-side: action-gateway giữ token kết nối tới
/api/openapi.yamlhoặc tới chuỗi MCP và hết hạn theo TTL nội bộ → request không rời được gateway. - OpenAI region/edge routing flap: edge node bị degrade, không gọi được tới
vps.incomexsaigoncorp.vn.
Tất cả 3 đều khớp với hiện tượng "ChatGPT-User egress = 0 tại nginx" đã ghi nhận trong project_gpt_action_gateway_stuck.md.
11. Khuyến nghị hành động
- Không restart container nào — không có triệu chứng cần đụng tới.
- Khi GPT báo lỗi lần kế tiếp, chạy ngay 30s diagnostic:
Nếu = 0 → xác nhận gateway-side stuck → user mở phiên GPT mới (recovery duy nhất hiện có).ssh root@38.242.240.89 'docker logs incomex-nginx --since 10m 2>&1 | grep ChatGPT-User | wc -l' - Tách lo lắng: hai issue khác cần xử lý riêng (KHÔNG phải nguyên nhân GPT lỗi):
- PG deadlock cyclic trên
meta_catalog— 2 Directus changelog flow tranhAccessExclusiveLock. Cần xem lại serialization hai flow. - Qdrant DELETE timeout trên path
knowledge/dev/laws/dieu44-trien-khai/design/p3d-birth-system-b3f1c-c-directus-nuxt-dot-scheduler-design.md— vector_sync_error 2 lần liên tiếp. Cần kiểm tra: document tồn tại trong AD nhưng vector chưa drop được?data_integrity.sync_statusđang làwarning.
- PG deadlock cyclic trên
12. Final fields
investigation_during_failure_window=unknown_user_did_not_confirm_active_failure_at_probe_time
total_ram_mb=11264
agent_data_mem_mb=1479
agent_data_mem_percent=57.75
uvicorn_workers_alive=2
uvicorn_master_present=true
nginx_upstream_errors_2h=0
oom_events_found=0
worker_restart_events=0
container_restart_events_6h=0
slow_requests_found=0
response_time_health_ms=1322
response_time_mcp_initialize_ms=114
response_time_mcp_tools_list_ms=78
nginx_established_connections=0
postgres_deadlocks_6h=5
postgres_deadlock_relation=meta_catalog
qdrant_vector_count=5785
agent_data_document_count=2827
agent_data_sync_status=warning
vector_sync_errors_6h=2
root_cause_pattern=UNKNOWN_VPS_HEALTHY
root_cause_consistent_with=OPENAI_ACTION_GATEWAY_STUCK_2026-05-12
GPT Connector Live State Investigation | P0 | 2026-05-13 | VPS healthy, không phải nguồn của pattern "chạy tốt → tự nhiên hỏng".