Skip to content

[BUG] MissingGreenlet error prevents all document indexing (Google Drive, ClickUp, file uploads) #720

@scottonamission

Description

@scottonamission

Bug Description

All indexing operations fail with SQLAlchemy MissingGreenlet errors. This affects:

  • Google Drive connector indexing
  • ClickUp connector indexing
  • Manual file uploads

Documents are parsed successfully (Docling completes, embeddings are generated) but fail when attempting to save to the database. This appears to be an async/await issue where database operations are being performed outside the greenlet context in Celery task workers.

Deployment Type

  • SurfSense Cloud (hosted version)
  • Self-hosted version

Steps to Reproduce

  1. Deploy using quick-start Docker command
  2. Go to 'Connectors' and configure Google Drive (or ClickUp, or go to Documents)
  3. Click 'Quick Index' on a connector, OR click 'Upload Documents' and upload a PDF
  4. Go to 'Logs' panel and see indexing task fail
  5. Check Docker logs: docker logs surfsense --tail 100
  6. See MissingGreenlet error

Expected Behavior

Documents should be parsed, embedded, and saved to the database. They should appear in the Documents panel.

Actual Behavior

  • Docling parsing completes successfully
  • Embeddings are generated successfully
  • Database save fails with MissingGreenlet error
  • No documents appear in the Documents panel
  • Subsequent requests show "connection is closed" errors

Screenshots/Videos

N/A - Error is in logs

Environment Information

  • Browser: Chrome 131
  • Operating System: macOS 15.2 (Apple Silicon M4 Max)
  • SurfSense Version: latest Docker image (pulled Jan 20, 2026)

Additional Environment Details (for Self-hosted only)

  • Python Version: 3.12 (per container)
  • Node.js Version: (bundled in container)
  • Database: PostgreSQL with pgvector (bundled in container)
  • Deployment Method: Docker quick-start

Additional Context

This appears to be a classic SQLAlchemy async/await bug. Per SQLAlchemy docs, MissingGreenlet occurs when:

  1. Lazy loading is triggered outside an async context
  2. Session objects are accessed after the async context closes
  3. expire_on_commit=False is not set on AsyncSession

The error originates in Celery task files:

  • document_tasks.py (line 240, 263)
  • file_processors.py (line 1097)
  • google_drive_indexer.py (line 60)

Possibly related to #491 and #268.

Logs/Error Messages

sqlalchemy.exc.MissingGreenlet: greenlet_spawn has not been called; can't call await_only() here. 
Was IO attempted in an unexpected place? 
(Background on this error at: https://sqlalche.me/e/20/xd2s)

File "/app/backend/app/tasks/celery_tasks/document_tasks.py", line 240, in _process_file_upload
File "/app/backend/app/tasks/document_processors/file_processors.py", line 1097, in process_file_in_background
sqlalchemy.exc.MissingGreenlet: greenlet_spawn has not been called; can't call await_only() here.

File "/app/backend/app/routes/search_source_connectors_routes.py", line 1656, in run_google_drive_indexing
File "/app/backend/app/tasks/connector_indexers/google_drive_indexer.py", line 60, in index_google_drive_files
sqlalchemy.exc.PendingRollbackError: This Session's transaction has been rolled back due to a previous exception during flush. Original exception was: greenlet_spawn has not been called

[2026-01-20 17:51:44,881: ERROR/MainProcess] Google Drive indexing completed with errors for connector 1: Folder 'Action Phase Group Support': greenlet_spawn has not been called; can't call await_only() here.

Checklist

  • I have searched existing issues to ensure this is not a duplicate
  • I have provided all the required information above
  • I have added appropriate labels (bug, deployment type)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions