Thread: Another pg_autovacuum patch

Another pg_autovacuum patch

From
"Matthew T. O'Connor"
Date:
In working through a pg_autovacuum problem with Joe Conway (which turned
out to be the same problem reported by Cott Lang which the previous
patch resolved) a new bug was uncovered when running with a debug level
of greater than 1.

This patch resolves this new found bug and fixes some of the other
debugging output to be more consistent.

Please apply to both HEAD and the 7.4 branch.


Matthew T. O'Connor


*** ./pg_autovacuum.c.orig    2004-03-16 23:30:18.372862648 -0500
--- ./pg_autovacuum.c    2004-03-16 23:17:41.187613298 -0500
***************
*** 359,377 ****
  void
  print_table_info(tbl_info * tbl)
  {
!     sprintf(logbuffer, "  table name:     %s.%s", tbl->dbi->dbname, tbl->table_name);
      log_entry(logbuffer);
      sprintf(logbuffer, "     relid: %u;   relisshared: %i", tbl->relid, tbl->relisshared);
      log_entry(logbuffer);
      sprintf(logbuffer, "     reltuples: %f;  relpages: %u", tbl->reltuples, tbl->relpages);
      log_entry(logbuffer);
!     sprintf(logbuffer, "     curr_analyze_count:  %li; cur_delete_count:   %li",
              tbl->curr_analyze_count, tbl->curr_vacuum_count);
      log_entry(logbuffer);
!     sprintf(logbuffer, "     ins_at_last_analyze: %li; del_at_last_vacuum: %li",
              tbl->CountAtLastAnalyze, tbl->CountAtLastVacuum);
      log_entry(logbuffer);
!     sprintf(logbuffer, "     insert_threshold:    %li; delete_threshold    %li",
              tbl->analyze_threshold, tbl->vacuum_threshold);
      log_entry(logbuffer);
      fflush(LOGOUTPUT);
--- 359,377 ----
  void
  print_table_info(tbl_info * tbl)
  {
!     sprintf(logbuffer, "  table name: %s.%s", tbl->dbi->dbname, tbl->table_name);
      log_entry(logbuffer);
      sprintf(logbuffer, "     relid: %u;   relisshared: %i", tbl->relid, tbl->relisshared);
      log_entry(logbuffer);
      sprintf(logbuffer, "     reltuples: %f;  relpages: %u", tbl->reltuples, tbl->relpages);
      log_entry(logbuffer);
!     sprintf(logbuffer, "     curr_analyze_count: %li; curr_vacuum_count: %li",
              tbl->curr_analyze_count, tbl->curr_vacuum_count);
      log_entry(logbuffer);
!     sprintf(logbuffer, "     last_analyze_count: %li; last_vacuum_count: %li",
              tbl->CountAtLastAnalyze, tbl->CountAtLastVacuum);
      log_entry(logbuffer);
!     sprintf(logbuffer, "     analyze_threshold: %li; vacuum_threshold: %li",
              tbl->analyze_threshold, tbl->vacuum_threshold);
      log_entry(logbuffer);
      fflush(LOGOUTPUT);
***************
*** 678,694 ****
  void
  print_db_info(db_info * dbi, int print_tbl_list)
  {
!     sprintf(logbuffer, "dbname: %s Username %s Passwd %s", dbi->dbname,
!             dbi->username, dbi->password);
      log_entry(logbuffer);
!     sprintf(logbuffer, " oid %u InsertThresh: %li  DeleteThresh: %li", dbi->oid,
!             dbi->analyze_threshold, dbi->vacuum_threshold);
      log_entry(logbuffer);
      if (dbi->conn != NULL)
!         log_entry(" conn is valid, we are connected");
      else
!         log_entry(" conn is null, we are not connected.");

      fflush(LOGOUTPUT);
      if (print_tbl_list > 0)
          print_table_list(dbi->table_list);
--- 678,706 ----
  void
  print_db_info(db_info * dbi, int print_tbl_list)
  {
!     sprintf(logbuffer, "dbname: %s", (dbi->dbname) ? dbi->dbname : "(null)");
      log_entry(logbuffer);
!
!     sprintf(logbuffer, "  oid: %u", dbi->oid);
      log_entry(logbuffer);
+
+     sprintf(logbuffer, "  username: %s", (dbi->username) ? dbi->username : "(null)");
+     log_entry(logbuffer);
+
+     sprintf(logbuffer, "  password: %s", (dbi->password) ? dbi->password : "(null)");
+     log_entry(logbuffer);
+
      if (dbi->conn != NULL)
!         log_entry("  conn is valid, (connected)");
      else
!         log_entry("  conn is null, (not connected)");

+     sprintf(logbuffer, "  default_analyze_threshold: %li", dbi->analyze_threshold);
+     log_entry(logbuffer);
+
+     sprintf(logbuffer, "  default_vacuum_threshold: %li", dbi->vacuum_threshold);
+     log_entry(logbuffer);
+
      fflush(LOGOUTPUT);
      if (print_tbl_list > 0)
          print_table_list(dbi->table_list);
***************
*** 935,941 ****
      log_entry(logbuffer);
      sprintf(logbuffer, "  args->port=%s", (args->port) ? args->port : "(null)");
      log_entry(logbuffer);
!     sprintf(logbuffer, "  args->user=%s", (args->user) ? args->user : "(null)");
      log_entry(logbuffer);
      sprintf(logbuffer, "  args->password=%s", (args->password) ? args->password : "(null)");
      log_entry(logbuffer);
--- 947,953 ----
      log_entry(logbuffer);
      sprintf(logbuffer, "  args->port=%s", (args->port) ? args->port : "(null)");
      log_entry(logbuffer);
!     sprintf(logbuffer, "  args->username=%s", (args->user) ? args->user : "(null)");
      log_entry(logbuffer);
      sprintf(logbuffer, "  args->password=%s", (args->password) ? args->password : "(null)");
      log_entry(logbuffer);
***************
*** 1007,1013 ****
      db_list = init_db_list();
      if (db_list == NULL)
          return 1;
!
      if (check_stats_enabled(((db_info *) DLE_VAL(DLGetHead(db_list)))) != 0)
      {
          log_entry("Error: GUC variable stats_row_level must be enabled.");
--- 1019,1025 ----
      db_list = init_db_list();
      if (db_list == NULL)
          return 1;
!
      if (check_stats_enabled(((db_info *) DLE_VAL(DLGetHead(db_list)))) != 0)
      {
          log_entry("Error: GUC variable stats_row_level must be enabled.");
*** ./TODO.orig    2004-03-13 14:50:13.000000000 -0500
--- ./TODO    2004-03-13 14:51:27.000000000 -0500
***************
*** 1,6 ****
--- 1,8 ----
  Todo Items for pg_autovacuum client
  --------------------------------------------------------------------------

+ _Add Startup Message (with datetime stamp) to Logfile when starting and logging
+
  _create a FSM export function and see if I can use it for pg_autovacuum

  _look into possible benifits of pgstattuple contrib work


Re: Another pg_autovacuum patch

From
Joe Conway
Date:
Matthew T. O'Connor wrote:
> This patch resolves this new found bug and fixes some of the other
> debugging output to be more consistent.
>
> Please apply to both HEAD and the 7.4 branch.

Bruce, if you'd like, I'll apply this one. I plan to test it out tonight
or tomorrow.

Thanks,

Joe


Re: Another pg_autovacuum patch

From
Bruce Momjian
Date:
Joe Conway wrote:
> Matthew T. O'Connor wrote:
> > This patch resolves this new found bug and fixes some of the other
> > debugging output to be more consistent.
> >
> > Please apply to both HEAD and the 7.4 branch.
>
> Bruce, if you'd like, I'll apply this one. I plan to test it out tonight
> or tomorrow.

OK, it is in the queue until you apply it.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: Another pg_autovacuum patch

From
Bruce Momjian
Date:
Patch applied to HEAD and 7.4.X.  Thanks.

---------------------------------------------------------------------------



Matthew T. O'Connor wrote:
> In working through a pg_autovacuum problem with Joe Conway (which turned
> out to be the same problem reported by Cott Lang which the previous
> patch resolved) a new bug was uncovered when running with a debug level
> of greater than 1.
>
> This patch resolves this new found bug and fixes some of the other
> debugging output to be more consistent.
>
> Please apply to both HEAD and the 7.4 branch.
>
>
> Matthew T. O'Connor
>
>


>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
>                http://archives.postgresql.org

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073