MongoDB Cursor Timeouts: getMore and Session Lifecycle
Correlates cursor timeout growth with client consumption, session lifetime, and getMore errors, including the limits of noCursorTimeout.
Operational Safety & Risk Notice
This runbook contains operational intervention steps; several are write-impacting (KILL, terminate, DROP, RESIZE). Verify in a staging environment first, and apply sequentially in production with verification.
1. Symptom & Signals
M57 `db.serverStatus().metrics.cursor.timedOut` sayacı artar; istemci tarafında `CursorNotFound`, getMore hataları veya yarıda kesilmiş batch'ler görülebilir. Tek başına sıfırdan büyük kümülatif sayaç geçmiş olayı gösterir, **delta** izleyin.
2. Business & Technical Impact
Uzun süren arka plan taramaları veya raporlar yarıda kalır; tekrar denemeler ek yük ve yinelenen iş yaratabilir. Her cursor timeout doğrudan uygulama hatası değildir.
3. Diagnosis & Root-Cause Analysis
const c = db.serverStatus().metrics.cursor;
({ open: c.open, timedOut: c.timedOut });Farklı zamanlardaki ölçümleri karşılaştırın; restart ile sayaç sıfırlanabilir.
db.getSiblingDB('admin').aggregate([
{ $currentOp: { allUsers: true, idleConnections: true } },
{ $match: { $or: [ { op: 'getmore' }, { 'command.getMore': { $exists: true } } ] } },
{ $project: { client: 1, appName: 1, ns: 1, secs_running: 1,
'command.getMore': 1, 'command.batchSize': 1 } }
]);4. Remediation & Action Plan
5. Verification & Health Checks
M57'nin **birim zamandaki artışı** düşüyor, yeni getMore hataları yok, açık cursor sayısı baseline'a dönüyor, raporlar eksiksiz ve tekrar üretilebilir biçimde tamamlanıyor.
6. Rollback & Contingency Plan
Uygulama batch/işleme değişikliklerini önceki sürüme döndürün. Kapanan cursor geri açılmaz; sonuçları en son işlenen kayıt/checkpoint'ten idempotent olarak yeniden üretin.