Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
erp5 erp5
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Labels
    • Labels
  • Merge requests 142
    • Merge requests 142
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Environments
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Jobs
  • Commits
Collapse sidebar
  • nexedi
  • erp5erp5
  • Merge requests
  • !785

Merged
Created Oct 23, 2018 by Arnaud Fontaine@arnauDeveloper

ZODB Components: Modules loaded by one Request were being GC'ed while executing in another Request.

  • Overview 8
  • Commits 1
  • Changes 7

@nexedi

Until this commit, loading a ZODB Component would add it to the current Request object to prevent its reference counter reaching 0 (thus its global being reset to None and then being later GC'ed) when a reset happens in another Request.

This problem was found when investigating testFunctionalConfigurator failure when installing bt5s as requested by the Configurator:

  1. Request R1 calls Zuite_waitForActivities importing extension.erp5.ERP5Zuite (M1). => Add M1 to R1._module_cache_set. => M1 ref counter equals to 2 (sys.modules and R1._module_cache_set references).
  2. R1 terminates and is GC'ed. => M1 ref counter equals to 1 (sys.modules).
  3. Request R2 runs Configurator configuring the Site.
  4. testFunctionalConfigurator calls Zuite_waitForActivities to wait for the Configurator to finish (request R3 which may take ~15 minutes). This calls time.sleep() in a loop where 'time' module is imported at top-level.
  5. R2 installs bt5 triggering reset. => M1 ref counter equals to 0. ===> M1 global variables are reset to None and thus 'time' is set to None raising an Exception in the next call of time.sleep() in the loop.

The easiest way would be to have a hook on sys.modules dict lookup and thus add M1 to R2._module_cache_set when being imported, but this is not supported... Instead create a global cache on erp5.component package.

Tests are passing: https://nexedi.erp5.net/test_result_module/20181023-84CC06B4 .

Assignee
Assign to
Reviewer
Request review from
None
Milestone
None
Assign milestone
Time tracking
Source branch: arnau-TM-components-Request-cache-fix
GitLab Nexedi Edition | About GitLab | About Nexedi | 沪ICP备2021021310号-2 | 沪ICP备2021021310号-7