Skip to content

Fix: remove I/O Blocking code on message processing parts #819

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 21 commits into from

Conversation

1yam
Copy link
Member

@1yam 1yam commented Jul 8, 2025

This PR remove I/O blocking operations on parts used by message processing to bring back message parallelization

Related Clickup or Jira tickets : ALEPH-526

Self proofreading checklist

  • Is my code clear enough and well documented
  • Are my files well typed
  • New translations have been added or updated if new strings have been introduced in the frontend
  • Database migrations file are included
  • Are there enough tests
  • Documentation has been included (for new feature)

Changes

This pull request introduces a comprehensive migration from synchronous database session handling to asynchronous session handling across multiple modules in the aleph codebase. The changes aim to improve performance and scalability by leveraging asynchronous operations. The most important changes include replacing DbSessionFactory and DbSession with their asynchronous counterparts, updating session-related method calls to use async with, and modifying database operations to use await.

Migration to Asynchronous Database Sessions:

Core API Entrypoint Updates:

  • Replaced make_engine and make_session_factory with make_async_engine and make_async_session_factory in src/aleph/api_entrypoint.py. Updated session initialization in configure_aiohttp_app to use asynchronous methods. [1] [2]

Chain-Specific Connector Updates:

  • Migrated DbSessionFactory to AsyncDbSessionFactory in src/aleph/chains/bsc.py, src/aleph/chains/connector.py, src/aleph/chains/ethereum.py, and src/aleph/chains/nuls2.py. Updated constructors and session usage within these chain connectors to use asynchronous operations. [1] [2] [3] [4]

Chain Data Service Updates:

  • Migrated DbSessionFactory and DbSession to AsyncDbSessionFactory and AsyncDbSession in src/aleph/chains/chain_data_service.py. Updated methods like add_pending_tx, add_and_publish_pending_tx, and others to use async with for session handling and added await for database operations. [1] [2] [3] [4]

Indexer Reader Updates:

  • Migrated DbSessionFactory and DbSession to AsyncDbSessionFactory and AsyncDbSession in src/aleph/chains/indexer_reader.py. Updated methods such as fetch_range, fetch_new_events, and fetcher to use asynchronous session handling and database operations. [1] [2] [3] [4]

Additional Updates:

  • Updated all database-related calls (e.g., commit, upsert, get_last_height) to use asynchronous versions with await. This ensures consistency and compatibility with the asynchronous session handling across the codebase.

How to test

This PR doesn't add any breaking change, it's just running things in Non I/O blockign way

@1yam 1yam force-pushed the 1yam-no-io-blocking branch 2 times, most recently from 7520d8b to 2f2d36f Compare July 8, 2025 13:01
@1yam 1yam closed this Jul 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant