Ad Widget

Collapse

Postgres checkpoint

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mppdidi
    Junior Member
    • Jul 2014
    • 17

    #1

    Postgres checkpoint

    What is the relationship between the postgres checkpoint and zabbix server application consistency. I am asking about this because zabbix has a dozen of caches. Are Zabbix sql operations always used as a commit ?
  • BDiE8VNy
    Senior Member
    • Apr 2010
    • 680

    #2
    Caches in Zabbix are used to decouple the Zabbix server/proxy processes from the database.

    The history cache is a write-cache and consists of item values received from or collected by items.
    Item values get processed, when being synced from history cache to database and not when written to the cache.
    The asynchronous history synchronization (1-5 seconds) allows to make bulk-INSERTs instead of a single INSERT per item value.
    Further each relevant value gets added to the value cache and therefor does not have to be queried from database later.

    See DCsync_history(), dbcache.c
    Code:
                    DBbegin();
     
                    if (0 != (daemon_type & ZBX_DAEMON_TYPE_SERVER))
                    {
                            DCmass_update_items(history, history_num);
                            DCmass_add_history(history, history_num);
                            DCmass_update_triggers(history, history_num);
                            DCmass_update_trends(history, history_num);
                            DCflush_nextchecks();
     
                            /* processing of events, generated in functions: */
                            /*   DCmass_update_items() */
                            /*   DCmass_update_triggers() */
                            /*   DCflush_nextchecks() */
                            process_events();
                    }
                    else
                    {
                            DCmass_proxy_add_history(history, history_num);
                            DCmass_proxy_update_items(history, history_num);
                    }
     
                    DBcommit();
    The value cache is a read-cache and consists of item values fetched from database to evaluate triggers, aggregated or calculated items.

    However, Zabbix caches have no relation to checkpointing of a datbase. Checkpointing ensures to have all dirty blocks up to a specific commited transaction being properly written to data files.

    In PG this means all dirty blocks from WAL files up to checkpoint time get consistently written to actual data files.
    See http://www.postgresql.org/docs/9.4/s...iguration.html for details what happens during a checkpoint.

    Comment

    • mppdidi
      Junior Member
      • Jul 2014
      • 17

      #3
      Postgres checkpoint

      BDiE8VNy,

      thanks for clarifying this. The initial motivation for this thread was how to backup the postgres zabbix db in a consistant way, with the focus on the zabbix-server. As for now the following example is working just fine:

      Code:
      1) lvrootname=`lvdisplay -c | grep '/root' | cut -d':' -f1 | sed 's/ //g'`
      2) lvbasename=`lvdisplay  -c | grep '/root:' | cut -d':' -f1 | sed 's/ //g' | sed 's/\/root//'`
      3) service zabbix-server stop
      4) sudo su - postgres -c 'psql -c checkpoint'
      5) lvcreate -pr -l 100%FREE -s -n root_snapshot $lvrootname
      6) service zabbix-server start
      7) mount $lvbasename/root_snapshot  /mnt/root_snapshot -o ro
      8) rsync -va --delete /mnt/root_snapshot/ /mnt/backup/rootfs/
      9) umount /mnt/root_snapshot
      10) lvremove -f $lvbasename/root_snapshot
      Is it okay with the zabbix-server when db is restored, to skip 3) and 6) during backup?

      Comment

      • BDiE8VNy
        Senior Member
        • Apr 2010
        • 680

        #4
        Zabbix server and Zabbix proxy are completely stateless. Everything is stored in the one database. So it doesn't care what point in time the database is on start-up of Zabbix server/proxy, as long as the database is in a consistent state.

        Anyhow, I suggest to do the backup by using the Low Level API. This is intended to do an online-backup in a non-intrusive way. Depending how one does the CEHCKPOINT it might become quite aggressive.

        Comment

        • mppdidi
          Junior Member
          • Jul 2014
          • 17

          #5
          Postgres checkpoint

          BDiE8VNy,

          okay, so my backup strategy is consistent for zabbix-server with postgresql.
          thank you for your support .

          Comment

          Working...