Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Register
  • Sign in
  • engine engine
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 27
    • Issues 27
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • AURAAURA
  • engineengine
  • Merge requests
  • !11

Rework database session handling

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Lars Kruse requested to merge sumpfralle/aura-engine:lars-93-short-lived-database-sessions into master Jan 22, 2022
  • Overview 2
  • Commits 2
  • Pipelines 1
  • Changes 3

The database session scoping was still an issue, since the currently used contexts are too narrow (causing complications with sqlalchemy's lazy evaluation).

This proposal switches to the request-based database session handling provided by flask-sqlachemy. A new session is created (and closed) for every incoming request.

This should be the proper solution.

But the threading used in the engine code will still cause problems, even with this reduced longevity of database sessions. In the long term we should consider one of the following options:

  • A) abandon the usage of threads (e.g. switching to async or multi-processing instead)
  • B) provide an interface for using thread-local database sessions (e.g. spawn a new database session in new threads and extend the DB.session interface accordingly)

What do you think?

btw: these changes revert the recently introduced lazy='subquery' parameter in some relationship definitions. I am not sure, whether these were related to the recently introduced context-based database sessions (see 70ffd1a0).

Edited Jan 22, 2022 by Lars Kruse
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: lars-93-short-lived-database-sessions