[PATCH] D37360: Keep sqlalchemy session separate from database objects

Matthias Braun via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 31 15:35:37 PDT 2017


MatzeB created this revision.
Herald added a subscriber: mcrosier.

SQLAlchemy sessions should be handled independently of the lifetimes of
objects such as V4DB and TestSuiteDB (which basically represent sqlalchemy models).

See also the SQLAlchemy documentation:
http://docs.sqlalchemy.org/en/latest/orm/session_basics.html esp. the
"When do I construct a Session, when do I commit it, and when do I close
it?"; "As a general rule, keep the lifecycle of the session
separate and external from functions and objects that access and/or
manipulate database data. This will greatly help with achieving a
predictable and consistent transactional scope."

This requires a bunch of mechanical code changes to make sure the
session object is passed around separately and a session needs to be
created explicitely now rather than getting a long lived session as part
of V4DB.

Advantages:

- We can construct the DB object and the testsuite table descriptions once when LNT starts. This avoids a bunch of database queries and sqlalchemy model building logic running again for each request.
- We can switch session.rollback() to session.close() in an upcoming commit, avoid countless unnecessary database queries happening on rollback().
- Avoids a bunch of obscure caching effects with long lived sessions helping to clean up LNT code (the cleanup already happened in r312059)
- I hope this will help some of the server instabilities we experience (it's hard to pinpoint the cause though, it may be something different).


Repository:
  rL LLVM

https://reviews.llvm.org/D37360

Files:
  lnt/lnttool/import_data.py
  lnt/lnttool/main.py
  lnt/lnttool/updatedb.py
  lnt/lnttool/viewcomparison.py
  lnt/server/db/fieldchange.py
  lnt/server/db/regression.py
  lnt/server/db/rules/rule_blacklist_benchmarks_by_name.py
  lnt/server/db/rules/rule_update_fixed_regressions.py
  lnt/server/db/rules/rule_update_profile_stats.py
  lnt/server/db/rules_manager.py
  lnt/server/db/search.py
  lnt/server/db/testsuitedb.py
  lnt/server/db/v4db.py
  lnt/server/instance.py
  lnt/server/reporting/analysis.py
  lnt/server/reporting/dailyreport.py
  lnt/server/reporting/runs.py
  lnt/server/reporting/summaryreport.py
  lnt/server/ui/api.py
  lnt/server/ui/app.py
  lnt/server/ui/decorators.py
  lnt/server/ui/profile_views.py
  lnt/server/ui/regression_views.py
  lnt/server/ui/templates/v4_run.html
  lnt/server/ui/views.py
  lnt/tests/builtintest.py
  lnt/tests/nt.py
  lnt/util/ImportData.py
  lnt/util/NTEmailReport.py
  lnt/util/ServerUtil.py
  lnt/util/async_ops.py
  tests/server/db/CreateV4TestSuite.py
  tests/server/db/CreateV4TestSuiteInstance.py
  tests/server/db/ImportV4TestSuiteInstance.py
  tests/server/db/blacklist.py
  tests/server/db/search.py
  tests/server/ui/change_processing.py

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37360.113486.patch
Type: text/x-patch
Size: 151320 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170831/e594a607/attachment-0001.bin>


More information about the llvm-commits mailing list