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

schema truncate of an incompletely created table drops core

    • Type: Icon: Task Task
    • Resolution: Done
    • WT1.3
    • Affects Version/s: None
    • Component/s: None

      Michael, this Python test script drops core:

      import wiredtiger, wttest
      
      class test_f(wttest.WiredTigerTestCase):
          # This test drops core. 
          def test_f(self):
              uri = "table:xxx"
              self.session.create(uri,
                  'key_format=i,value_format=SiSS,' +
                  'columns=(record,column2,column3,column4,column5),' +
                  'colgroups=(cgroup1,cgroup2,cgroup3,cgroup4,cgroup5,cgroup6)')
              self.session.truncate(uri, None, None, None)
              self.session.drop(uri, None)
      
      if __name__ == '__main__':
          wttest.run()
      

      The problem is in dropping a table from the schema file: the number of groups in a table is set to 6, but the list of group names isn't filled in (I'm guessing, but have not checked, the names would be filled in by the corresponding session.create calls for the groups).

      (gdb) where
      #0  0x0000000800b98b27 in strlen () from /lib/libc.so.7
      WT-1  0x0000000801ecbac4 in __truncate_table (session=0x8030de3d0, 
          name=0x8030c117a "xxx") at ../src/schema/schema_truncate.c:55
      WT-2  0x0000000801ecbd99 in __wt_schema_truncate (session=0x8030de3d0, 
          uri=0x8030c1174 "table:xxx", cfg=0x7fffffffc6a0)
          at ../src/schema/schema_truncate.c:114
      WT-3  0x0000000801ecd53f in __session_truncate (wt_session=0x8030de3d0, 
          uri=0x8030c1174 "table:xxx", start=0x0, stop=0x0, config=0x0)
          at ../src/session/session_api.c:331
      WT-4  0x0000000801d5f4cf in _wrap_Session_truncate (self=Variable "self" is not available.
      (gdb) frame 1
      WT-1  0x0000000801ecbac4 in __truncate_table (session=0x8030de3d0, 
          name=0x8030c117a "xxx") at ../src/schema/schema_truncate.c:55
      55			if ((tret = __wt_schema_get_btree(session,
      (gdb) l
      50		for (i = 0; i < WT_COLGROUPS(table); i++) {
      51			/*
      52			 * Get an exclusive lock on the handle: it will be released by
      53			 * __wt_conn_btree_close_all.
      54			 */
      55			if ((tret = __wt_schema_get_btree(session,
      56			    table->cg_name[i], strlen(table->cg_name[i]),
      57			    NULL, WT_BTREE_EXCLUSIVE)) != 0) {
      58				WT_TRET(tret);
      59				continue;
      (gdb) p table->ncolgroups
      $1 = 6
      (gdb) p table->cg_name[0]
      $2 = 0x801012f00 "colgroup:xxx:cgroup1"
      (gdb) p table->cg_name[1]
      $3 = 0x0
      

      Keeping WT_COLGROUPS in sync with the actual list might end up being hard – perhaps it would be better to have an inline function that counts through the list each time, looking for the trailing NULL? Or even get rid of WT_COLGROUPS entirely and operate on the list of pointers in all cases? Or maybe ncolgroups shouldn't be set until the names are filled in?

      Anyway, I don't want to hack this without some input from you, please fix this, or let me know what changes you'd prefer.

            Assignee:
            michael.cahill@mongodb.com Michael Cahill (Inactive)
            Reporter:
            keith.bostic@mongodb.com Keith Bostic (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: