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 139
    • Merge requests 139
  • 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
  • !921

Closed
Created Sep 02, 2019 by Vincent Pelletier@vpelletierOwner
  • Report abuse
Report abuse

Transaction deadline API

  • Overview 30
  • Commits 2
  • Changes 13

With this work, every transaction gets its own deadline, and (only) shorter deadlines can be applied on desired subparts of a transaction.

This prevents performance degradation from keeping a single transaction alive for an unexpected amount of time, which is especially detrimental to InnoDB transaction isolation.

Another application of this API is to provide a time-based limit to a long rendering process where a document-count-based limit would be too hard to quantify. Like for example listing many documents and preparing each for display, which can be achieved using something like (pseudo-code):

result = []
with Deadline(-2): # Reserve 2 seconds at the end of the current deadline to finalise response
  for row in portal_catalog(...): # Should be fast to take advantage of this pattern
    try:
      result.append(produceFullResult(row)) # May be arbitrarily slow
    except TimeoutReachedError:
      result.append(click_here_to_get_more_documents) # Tell user there may be more results
      break
return result # Contains all documents which could be processed until the inner deadline was reached

Checking the current deadline is to be explicitly done, in a few select places:

  • database connectors (this merge request implements this for ZODB & ZMySQLDA)
  • process spawning (document conversion, ...)
  • other network adaptors (sftp, ...)

This approache is not supposed to protect against all cases. Especially, it is not supposed to protect against "while True: pass". This should be fine because:

  • such issues are normally caught while developping, and not on a live production (I do not remember ever discovering such bogus code in production myself, not even caused by complex code or complex code interactions)
  • python's lack of thread preemption at interpreter level would make such implementation complex, intrusive and likely slow

So covering such in-practice-non-existent edge-cases should not be worth the massive effort.

The publisher-based deadline is already in use as a proof-of-concept, and it very successfully reduced the number of runaway transactions on a real-life application.

The CMFActivity-based deadline is not in actualy use yet, as how to choose a duration without causing massive regressions is not clearly identified yet, while user-facing transactions are typically already limited by http proxy's timeout of a few minutes.

To make use of deadlines, ERP5 Software Release must be modified and updated so the proper configuration is generated (there is no merge request for this yet).

Some extra work may be needed to define deadlines in the WSGI publisher.

/cc @georgios.dagkakis @jerome @jm @jp @kazuhiko @romain @seb @tb @yusei

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