Uploaded image for project: 'WiredTiger'
  1. WiredTiger
  2. WT-436

statistics cursors, including bulk load

    • Type: Icon: Task Task
    • Resolution: Done
    • WT2.3.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:

      Michael, in schema/schema_stat.c, there some code:

              /* Process the column groups. */
              for (i = 0; i < WT_COLGROUPS(table); i++) {
                      colgroup = table->cgroups[i];
                      
                      WT_ERR(__wt_buf_fmt(
                          session, buf, "statistics:%s", colgroup->name));
                      ret = __wt_curstat_open(
                          session, buf->data, cfg, &stat_cursor);
                      
                      while ((ret = stat_cursor->next(stat_cursor)) == 0) {
                              WT_ERR(stat_cursor->get_key(stat_cursor, &stat_key));
                              WT_ERR(stat_cursor->get_value(
                                  stat_cursor, &desc, &pvalue, &value));
                              WT_STAT_INCRKV(stats, stat_key, value);
                      }
                      WT_ERR_NOTFOUND_OK(ret);
                      WT_ERR(stat_cursor->close(stat_cursor));
              }
      

      that has a problem – notice we're not checking the return of __wt_curstat_open for an error return, and when we see one, we drop core because stat_cursor is NULL.

      I'm not sure what's supposed to be going on there, but if you use the existing session handle to open up a statistics cursor BEFORE closing the bulk-load cursor in test/format/wts_bulk.c/wts_load(), you hit a problem with this stack, where stat_cursor is NULL:

      0x0000000000469fbd in __curstat_table_init (session=0x800ff0430, 
          uri=0x800e188ab "table:wt", cfg=0x7fffffffe590, cst=0x800e47e80, flags=0)
          at ../src/schema/schema_stat.c:99
      99			while ((ret = stat_cursor->next(stat_cursor)) == 0) {
      (gdb) where
      #0  0x0000000000469fbd in __curstat_table_init (session=0x800ff0430, 
          uri=0x800e188ab "table:wt", cfg=0x7fffffffe590, cst=0x800e47e80, flags=0)
          at ../src/schema/schema_stat.c:99
      WT-1  0x000000000046a2a8 in __wt_schema_stat_init (session=0x800ff0430, 
          uri=0x800e188a0 "statistics:table:wt", cfg=0x7fffffffe590, 
          cst=0x800e47e80, flags=0) at ../src/schema/schema_stat.c:152
      WT-2  0x0000000000455414 in __wt_curstat_init (session=0x800ff0430, 
          uri=0x800e188a0 "statistics:table:wt", cfg=0x7fffffffe590, 
          cst=0x800e47e80, flags=0) at ../src/cursor/cur_stat.c:385
      WT-3  0x000000000045553c in __wt_curstat_open (session=0x800ff0430, 
          uri=0x800e188a0 "statistics:table:wt", cfg=0x7fffffffe590, 
          cursorp=0x7fffffffe718) at ../src/cursor/cur_stat.c:439
      WT-4  0x000000000041d5ff in __wt_open_cursor (session=0x800ff0430, 
          uri=0x800e188a0 "statistics:table:wt", owner=0x0, cfg=0x7fffffffe590, 
          cursorp=0x7fffffffe718) at ../src/session/session_api.c:203
      WT-5  0x000000000041d8b5 in __session_open_cursor (wt_session=0x800ff0430, 
          uri=0x800e188a0 "statistics:table:wt", to_dup=0x0, config=0x0, 
          cursorp=0x7fffffffe718) at ../src/session/session_api.c:243
      WT-6  0x0000000000407154 in wts_stats (session_arg=0x800ff0430, 
          tag=0x5a8b20 "bulk") at ../../../test/format/wts.c:342
      WT-7  0x000000000040740a in wts_load () at ../../../test/format/wts_bulk.c:121
      WT-8  0x00000000004052f3 in main (argc=0, argv=0x7fffffffe8a0)
          at ../../../test/format/t.c:120
      

      I don't have a great recipe to reproduce it, because opening a stat cursor at that point requires some other random changes I haven't committed. I'll try and give you something better if it's not obvious what's supposed to happen here.

      One other hint:

      Breakpoint 1, __wt_curstat_open (session=0x800ff0430, 
          uri=0x801b99000 "statistics:colgroup:wt", cfg=0x7fffffffe590, 
          cursorp=0x7fffffffe388) at ../src/cursor/cur_stat.c:414
      414		WT_DECL_RET;
      (gdb) c
      Continuing.
      
      Program received signal SIGSEGV, Segmentation fault.
      0x0000000000469fbd in __curstat_table_init (session=0x800ff0430, 
          uri=0x800e188cb "table:wt", cfg=0x7fffffffe590, cst=0x800e47e80, flags=0)
          at ../src/schema/schema_stat.c:99
      99			while ((ret = stat_cursor->next(stat_cursor)) == 0) {
      

      Notice that we're opening a column-group statistic, for what must be a default column group, that is, I would have guessed that test/format wouldn't open statistics on any column group?

      But maybe it's the fact that we haven't closed the bulk-load cursor before we try and do this work?

      Open the statistics cursor AFTER closing the bulk-load cursor in that code, and it all works.

            Assignee:
            Unassigned Unassigned
            Reporter:
            keith.bostic@mongodb.com Keith Bostic (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: