Skip to content

git-ai bg run daemon leaks memory (10GB+) via unbounded metrics-upload retry loop on Unauthorized #1765

Closed

Description

@dbasilfid

Summary

The git-ai bg run background daemon grows unbounded in memory (observed 10.2GB RSS, 46% CPU sustained) when the configured api_key is rejected by the metrics telemetry endpoint. The daemon retries the failed upload roughly every 30 seconds indefinitely instead of backing off after a permanent auth failure, and the local metrics backlog grows without bound in the meantime.

Environment

  • git-ai version: 1.6.10
  • OS: macOS (Darwin 25.5.0, arm64, Apple M4 Max, 36GB RAM)
  • Install: fleet-managed deployment (MDM)

Observed behavior

  1. git-ai bg run daemon running in background (auto-started via git hooks / Trace2 integration).
  2. Daemon periodically attempts metrics upload to https://usegitai.com/worker/metrics/upload using the api_key from ~/.git-ai/config.json.
  3. Server responds Unauthorized for every batch.
  4. Daemon retries approximately every 30 seconds, indefinitely:
    INFO metrics upload batch sending min_id=... max_id=... events=NN
    INFO metrics upload batch failed ... error=Generic error: Unauthorized
    WARN telemetry: failed to upload pending metrics e=Generic error: Unauthorized
    
  5. Over ~24 hours this grew metrics-db on disk to 766MB (vs <7MB for the daemon's other sqlite DBs: transcripts-db, notes-db, bash-checkpoints-db), and daemon RSS grew to 10.2GB with sustained ~46% CPU.
  6. git-ai bg shutdown --hard + restart reclaims memory temporarily, but the leak resumes since the underlying auth failure isn't addressed and no backoff is applied.

Additional findings

  • Running git-ai login fixed an unrelated, contradictory login-state issue (git-ai debug said "logged out" while git-ai login said "Already logged in"), but did not fix this leak — the metrics endpoint uses the standalone api_key field, independent of the interactive login session used for notes_backend.
  • Could not disable this telemetry channel client-side:
    • git-ai config set telemetry_oss_disabled true → Error: Unknown config key: telemetry_oss_disabled, despite it being a real, readable field (git-ai config telemetry_oss_disabled returns false).
    • Manually setting "telemetry_oss_disabled": true directly in config.json had no effect after a full daemon restart — the value still reads back as false.

Expected behavior

  • On a persistent auth failure (Unauthorized), the daemon should back off or circuit-break rather than retrying every ~30s forever, and should not let the pending-metrics backlog/memory grow unbounded.
  • telemetry_oss_disabled should be settable via git-ai config set and/or honored from config.json, so users can opt out of this telemetry channel independent of the auth issue.

Impact

10.2GB RAM / 46% CPU sustained on a 36GB machine, contributing to significant system-wide memory pressure alongside normal daily usage.

Activity

  1. deleted a comment from on Jul 9, 2026
  2. svarlamov commented on Jul 9, 2026

    @svarlamov
    Member

    Please do NOT post or download ZIPs in comments (even if you're trying to be helpful). Not referring to OP -- referring to a deleted comment with that nature of content. If you'd like to propose a solution, please open a PR or even direct to a fork that's hosted on GitHub, etc.

    Regarding the issue, we are working on a solution in #1700 and planning to release in the next version. Does removing the API Key address the issue? Just OOC, why are you setting an API Key? There was another comment regarding telemetry_oss_disabled, but that's for open source telemetry -- setting the API Key is for the Git AI proprietary cloud offering -- and does not interact with telemetry_oss_disabled (setting that to false is independent of this memory issue and the API Key)

  3. pinned and unpinned a comment on Jul 9, 2026
  4. Siddhant-K-code commented on Jul 9, 2026

    @Siddhant-K-code
    Contributor

    Hey @dbasilfid, can you run the following commands and share their output!

    # 1. Version
    git-ai --version
    
    # 2. Internal file permissions & sizes
    ls -la ~/.git-ai/internal/
    
    # 3. AI tool transcript sizes
    for dir in ~/.cursor ~/.codex ~/.claude ~/.windsurf ~/.amp ~/.continue ~/.gemini; do
      [ -d "$dir" ] && echo "$dir: $(du -sh "$dir" 2>/dev/null | cut -f1)"
    done
    
    # 4. Metrics DB size
    ls -lh ~/.git-ai/internal/metrics-db
  5. dbasilfid commented on Jul 9, 2026

    @dbasilfid
    Author

    Hey @dbasilfid, can you run the following commands and share their output!

    ~/development  git-ai --version
    1.6.10

    ~/development  ls -la ~/.git-ai/internal/
    total 1704968
    drwxr-xr-x 23 drb-fid staff 736 Jul 8 20:53 .
    drwxr-xr-x 7 drb-fid staff 224 Jul 8 20:46 ..
    drwxr-xr-x@ 23 drb-fid staff 736 May 5 23:06 async-checkpoint-blobs
    -rw-r--r--@ 1 drb-fid staff 7544832 Jul 9 10:34 bash-checkpoints-db
    -rw-r--r--@ 1 drb-fid staff 32768 Jul 8 23:32 bash-checkpoints-db-shm
    -rw-r--r--@ 1 drb-fid staff 4161232 Jul 9 11:00 bash-checkpoints-db-wal
    -rw-------@ 1 drb-fid staff 668 Jul 9 10:25 credentials
    drwxr-xr-x@ 7 drb-fid staff 224 Jul 8 23:32 daemon
    -rw-r--r--@ 1 drb-fid staff 10440704 May 5 23:02 db
    -rw-r--r--@ 1 drb-fid staff 32768 May 5 16:17 db-shm
    -rw-r--r--@ 1 drb-fid staff 4622672 May 6 08:18 db-wal
    drwxr-xr-x@ 8 drb-fid staff 256 Jul 8 20:56 debug-self-checks
    -rw-r--r-- 1 drb-fid staff 36 Mar 19 16:15 distinct_id
    -rw-r--r--@ 1 drb-fid staff 809439232 Jul 9 11:01 metrics-db
    -rw-r--r--@ 1 drb-fid staff 32768 Jul 8 23:32 metrics-db-shm
    -rw-r--r--@ 1 drb-fid staff 14366472 Jul 9 11:01 metrics-db-wal
    -rw-r--r--@ 1 drb-fid staff 626688 Jul 7 17:53 notes-db
    -rw-r--r--@ 1 drb-fid staff 32768 Jul 8 23:32 notes-db-shm
    -rw-r--r--@ 1 drb-fid staff 4124152 Jul 9 10:54 notes-db-wal
    -rw-r--r--@ 1 drb-fid staff 970752 Jul 8 23:44 transcripts-db
    -rw-r--r--@ 1 drb-fid staff 32768 Jul 8 23:32 transcripts-db-shm
    -rw-r--r--@ 1 drb-fid staff 4124152 Jul 9 11:00 transcripts-db-wal
    -rw-r--r--@ 1 drb-fid staff 94 Jul 8 21:56 update_check

    ~/development  for dir in ~/.cursor ~/.codex ~/.claude ~/.windsurf ~/.amp ~/.continue ~/.gemini; do
    [ -d "$dir" ] && echo "$dir: $(du -sh "$dir" 2>/dev/null | cut -f1)"
    done
    /Users/drb-fid/.cursor: 1.8G
    /Users/drb-fid/.codex: 847M
    /Users/drb-fid/.claude: 377M
    /Users/drb-fid/.gemini: 9.6M

    ~/development  ls -lh ~/.git-ai/internal/metrics-db
    -rw-r--r--@ 1 drb-fid staff 772M Jul 9 11:01 /Users/drb-fid/.git-ai/internal/metrics-db

  6. dbasilfid commented on Jul 9, 2026

    @dbasilfid
    Author

    Regarding the issue, we are working on a solution in #1700 and planning to release in the next version. Does removing the API Key address the issue? Just OOC, why are you setting an API Key? There was another comment regarding telemetry_oss_disabled, but that's for open source telemetry -- setting the API Key is for the Git AI proprietary cloud offering -- and does not interact with telemetry_oss_disabled (setting that to false is independent of this memory issue and the API Key)

    Thanks — good to hear #1700 is coming!

    To answer your questions:

    Does removing the API Key address the issue? No. I ran git-ai config unset api_key, verified it was gone from config.json, and hard-restarted the daemon (bg restart --hard). The daemon still attempts metrics uploads to usegitai.com every ~30s and still receives Unauthorized on every batch — this despite git-ai debug showing an active, valid login session (access token auto-refreshing, refresh token valid for months). So the retry/backlog growth continues regardless of whether the key is present.

    Why was an API Key set? I didn't set it myself — git-ai is deployed fleet-wide to developer laptops by my company's admin (managed/MDM install), and the key came provisioned in config.json. It's presumably stale or revoked at the server. I already flagged the bad key to our admin separately, but the client-side symptom (infinite ~30s retries with unbounded backlog growth on a permanent 401) reproduces with or without the key.

    And thanks for the clarification on telemetry_oss_disabled vs. the proprietary cloud path

  7. Siddhant-K-code commented on Jul 10, 2026

    @Siddhant-K-code
    Contributor

    Memory leak issues would be fixed/better after the release of v1.6.12 - #1772 was just merged today!

  8. svarlamov commented on Jul 10, 2026

    @svarlamov
    Member

    Hey @dbasilfid! I just tried to replicate and was not able to -- I do know that there was an issue with this previously though. Do you mind checking if you can still reproduce with v1.6.12?

  9. dbasilfid commented on Jul 10, 2026

    @dbasilfid
    Author

    @svarlamov Confirmed fixed in v1.6.12 — thanks!

    I upgraded from 1.6.11 → 1.6.12 and hard-restarted the daemon. The Unauthorized errors still occur in my environment (my api_key is stale/revoked at the server — a provisioning issue on our MDM side, unrelated to git-ai), so this is actually a good stress test.

    Results on v1.6.12 under sustained upload failures:

    • Daemon RSS stayed flat at ~34MB over 5+ minutes of continuous failed batches.
    • This held even though metrics-db on disk is ~830MB — larger than the 766MB backlog that had previously driven RSS to 10.2GB on v1.6.10.
    • Upload batches now advance monotonically with small event counts, rather than re-loading a growing backlog into memory each retry.

    Closing this out on my end, I appreciate the quick turnaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions