CGWP

  • Home
  • Log in
  • « ORCID update
  • Log in to CGWP using ORCID »

Nightly DB maintenance

Posted by gregster on 21 Apr 2019 in Activity log

I'm at the point where I need to start thinking about how the nightly update/refresh is going to work.

Each night the DB needs to update the data tables with any vetted rows from the edit schema and refresh the materialized views.
A good SO post  suggests a few things:
1) cron - */30 * * * * psql -d your_database -c "REFRESH MATERIALIZED VIEW CONCURRENTLY my_mv"
2) trigger
3) listen/notify
Of those, only cron is practical as we will do maintenance on a schedule, not based on events.
Downside to cron is that it doesn't know if there have been problems.
As this will be a 2-step process (update data schema / refresh materialized views) our choice with cron is:
1) Ignore failures. If the failure is on the updates any refresh might be wasted.
But, a refresh doesn't take long (90 seconds-ish) so wasting cycles isn't a big deal.
If the failure is on the refresh how do we know? Would we need to do an audit to find discrepancies?
2) Write some code that runs before the view refresh that determines if errors occured during update and takes action (e.g. email and bail)
I also found pg_cron, which might be more elegant. Downside is that it needs to be installed

Note: if cron/psql is the answer, these psql flags will be useful:
-d database name
-c command
-b echo errors to standard or error output
-f filename (i.e. an sql file that contains the commands)
-L log file name
-q quiet

This entry was posted by Greg and filed under Activity log.

CGWP

Development blog for next version of the Canadian Great War Project. The production site is at https://cgwp.uvic.ca/, and the development site is at https://cgwpdev.uvic.ca/ (access controlled)

Some sections of the development site are not explicitly linked via menus. See the post titled "CGWP development URLs" for details.
  • Home
  • Recently
  • Archives
  • Categories
  • Latest comments

Search

Categories

  • All
  • Activity log
  • Discussion
  • Tasks

All blogs

  • Academic
  • AdaptiveDB
  • Admin
  • Announcements
  • CanMys
  • Cascade
  • CGWP
  • ColDesp
  • Depts
  • DVPP
  • Endings
  • HCMC Blogs
  • Landscapes
  • LEMDO
  • Linguistics
  • Maint
  • LondonMap
  • Mariage
  • MoM
  • Moses
  • Pro-D
  • Projects
  • ScanCan
  • HumsSites
  • Wendat

This collection ©2026 by admin • Help • blog software • top hosts