Troubleshooting

Table of contents

  1. Common Issues
    1. Connection Problems
      1. MongoDB Connection Failed
      2. Server Won’t Start
    2. Processing Issues
      1. Long Response Times
      2. Cache Problems
  2. Diagnostic Tools
    1. Log Analysis
    2. MongoDB Diagnostics
    3. Monitor Tool
  3. Performance Optimization
    1. Batch Window Tuning
    2. Cache Management
  4. Getting Help

Common Issues

Connection Problems

MongoDB Connection Failed

ERROR: Failed to connect to MongoDB

Solutions:

  1. Check MongoDB is running:
    docker ps | grep mongodb
    
  2. Verify connection settings:
    echo $MONGO_HOST
    echo $MONGO_PORT
    
  3. Test connection manually:
    mongosh -u $MONGO_USER -p $MONGO_PASSWORD
    

Server Won’t Start

ERROR: address already in use

Solutions:

  1. Check for running instances:
    ps aux | grep batch-gpt
    
  2. Kill existing process:
    kill -9 <PID>
    

Processing Issues

Long Response Times

WARNING: Batch processing exceeding expected duration

Solutions:

  1. Check OpenAI batch status
  2. Verify network connectivity
  3. Review batch window setting:
    echo $COLLATE_BATCHES_FOR_DURATION_IN_MS
    

Cache Problems

ERROR: Failed to cache response

Solutions:

  1. Check MongoDB space:
    db.stats()
    
  2. Verify cache collection:
    use batchgpt
    db.cached_responses.stats()
    

Diagnostic Tools

Log Analysis

# View recent logs
tail -f logs/batch-gpt.log

# Search for errors
grep ERROR logs/batch-gpt.log

MongoDB Diagnostics

# Check collections
use batchgpt
show collections

# View batch status
db.batch_logs.find().sort({timestamp: -1}).limit(1)

Monitor Tool

# Start monitor
./batch-monitor

# Filter for failed batches
# Use arrow keys to navigate to "Failed" tab

Performance Optimization

Batch Window Tuning

  • Start with 5000ms
  • Monitor batch sizes
  • Adjust based on volume:
    export COLLATE_BATCHES_FOR_DURATION_IN_MS=3000  # More frequent, smaller batches
    

Cache Management

  • Regular maintenance
  • Index optimization
  • Storage monitoring

Getting Help

  1. Check documentation
  2. Review GitHub issues
  3. Open new issue with:
    • Error messages
    • Configuration
    • Logs
    • Steps to reproduce