* feat: db.begin(read_only=True)
You can now start read only transaction by passing read only flag. Read
only transactions prevent any query that is of "WRITE" type like
insert/delete/update.
(cherry picked from commit 5e86e1f192)
* feat: allow reads during maintenance_mode
To reduce downtime reading from main db server during maintenance_mode
can be allowed. This lets users browse desk, static sites or any other
pages while ensuring that no writes happen to DB.
refactor: use read replica if available
(cherry picked from commit 5beccd8802)
* fix: always explicitly start a new transaction
Active read only transaction can be aborted by doing a commit and then
issuing queries. This prevents such edge cases.
(cherry picked from commit 4389447148)
* fix: dont renew session during read only mode
(cherry picked from commit 5922c0ea35)
* feat: wrap read only mode SQL errors
(cherry picked from commit f96505fae0)
* fix: defer logging during read only mode
Deferred:
- Error log
- view log
- web page view
Disable:
- "_seen" tracking used on list view to highlight unseen docs.
- "seen" on error log.
- dashboard chart last ts caching
(cherry picked from commit 55617b9e86)
* fix: ensure deferred insert are flushed during update
(cherry picked from commit 98b57f6a1a)
* fix: remove ad-hoc maintenance mode implementation
(cherry picked from commit e1253e8299)
* feat(UX): Disable write actions in read-only Desk
I won't be covering each and every aspect of desk that shouldn't work in
read only mode. This just handles major interactions and assumes that
user will get a hint about why other things aren't working.
Changes:
- Add read only badge on navbar.
- Disable forms
- Disable new doc creation
(cherry picked from commit 1ec03dacff)
* test: add api tests for read only mode
(cherry picked from commit 7f316fa427)
* feat(ux): `no-indicator-dot` for indicator pills
Adding this class will disable indicator's tiny dot added before text.
(cherry picked from commit f6c548c7b9)
* refactor: remove dead flag db.read_only
This was added in last DB refactor but it does nothing, it was probably
supposed to do something with the connection pool but to best of my
knowledge "read only" is not a property of a connection.
It can be achieved with users who only have read access, that however
isn't implemented anywhere.
Removing this for now.
(cherry picked from commit ea7fbb2c10)
# Conflicts:
# frappe/database/__init__.py
* fix(UX): show read only mode warning on web pages
(cherry picked from commit 06d888126b)
* perf: duplicate database initialization (#18049)
* fix: don't attempt to delete session during read only session
* fix: error handling without user set
* chore: conflicts
Co-authored-by: Ankush Menat <ankush@frappe.io>