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

core dump if database directory is removed

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

      If you remove the database home directory, we core dump. You can reproduce this one with this change to examples/c/ex_access.c:

      diff --git a/examples/c/ex_access.c b/examples/c/ex_access.c
      index 522db56..2f5ac99 100644
      --- a/examples/c/ex_access.c
      +++ b/examples/c/ex_access.c
      @@ -90,6 +90,14 @@ main(void)
              }
              /*! [access example cursor list] */
       
      +        /*Delete dir*/
      +        ret = system("rm -rf WT_HOME");
      +        if (ret != 0) {
      +            fprintf(stderr, "Error deleting WT_HOME %s: %s\n",
      +                    home, wiredtiger_strerror(ret));
      +            return (ret);
      +        }
      +
              /*! [access example close] */
              ret = conn->close(conn, NULL);
              /*! [access example close] */
      

      Here's the stack:

      (gdb) where
      #0  0x000000080094f1c4 in __wt_page_modify_init (session=0x80302a000, page=0x0)
          at btree.i:289
      WT-1  0x000000080094e909 in __checkpoint_worker (session=0x80302a000, cfg=0x0, 
          is_checkpoint=0) at src/txn/txn_ckpt.c:863
      WT-2  0x000000080094ed1e in __wt_checkpoint_close (session=0x80302a000, force=0)
          at src/txn/txn_ckpt.c:993
      WT-3  0x000000080089e633 in __wt_conn_btree_sync_and_close (session=0x80302a000, 
          force=0) at src/conn/conn_dhandle.c:273
      WT-4  0x000000080089fc84 in __wt_conn_dhandle_discard_single (
          session=0x80302a000, final=1) at src/conn/conn_dhandle.c:654
      WT-5  0x00000008008a029c in __wt_conn_dhandle_discard (session=0x80302a000)
          at src/conn/conn_dhandle.c:725
      WT-6  0x00000008008a2f1f in __wt_connection_close (conn=0x803019000)
          at src/conn/conn_open.c:120
      WT-7  0x000000080089683d in __conn_close (wt_conn=0x803019000, config=0x0)
          at src/conn/conn_api.c:713
      WT-8  0x0000000000400ce7 in main () at ex_access.c:102
      

      What's happening is that we get into __wt_conn_dhandle_discard, close down everything but the metadata file, and then hit this clause:

      /* Close the metadata file handle. */
      while ((dhandle = SLIST_FIRST(&conn->dhlh)) != NULL)
              WT_WITH_DHANDLE(session, dhandle,
                  WT_TRET(__wt_conn_dhandle_discard_single(session, 1)));
      

      The close fails because we can't update the turtle file:

      [1417696420:695595][98257:0x803006400], file:WiredTiger.wt, sweep-server: WT_HOME/WiredTiger.turtle.set: No such file or directory
      
      (gdb) where
      #0  0x000000080090294c in __wt_open (session=0x80302a000, 
          name=0x80095e624 "WiredTiger.turtle.set", ok_create=1, exclusive=1, 
          dio_type=16, fhp=0x7fffffffd258) at src/os_posix/os_open.c:123
      WT-1  0x00000008008fd554 in __wt_turtle_update (session=0x80302a000, 
          key=0x8030280e0 "file:WiredTiger.wt", 
          value=0x80306ef00 "allocation_size=4KB,app_metadata=,block_allocation=best,block_compressor=,cache_resident=0,checkpoint=(WiredTigerCheckpoint.1=(addr=\"018481e465184bda8581e4ecee3cf38080808681e4c63c7418e25fc0e20fc0\",ord"...)
          at src/meta/meta_turtle.c:302
      WT-2  0x00000008008fb2c1 in __wt_metadata_update (session=0x80302a000, 
          key=0x8030280e0 "file:WiredTiger.wt", 
          value=0x80306ef00 "allocation_size=4KB,app_metadata=,block_allocation=best,block_compressor=,cache_resident=0,checkpoint=(WiredTigerCheckpoint.1=(addr=\"018481e465184bda8581e4ecee3cf38080808681e4c63c7418e25fc0e20fc0\",ord"...)
          at src/meta/meta_table.c:131
      WT-3  0x00000008008f9741 in __ckpt_set (session=0x80302a000, 
          fname=0x8030280e0 "file:WiredTiger.wt", 
          v=0x80301b500 "checkpoint=(WiredTigerCheckpoint.1=(addr=\"018481e465184bda8581e4ecee3cf38080808681e4c63c7418e25fc0e20fc0\",order=1,time=1417696385,size=12288,write_gen=4)),checkpoint_lsn=(1,0)") at src/meta/meta_ckpt.c:122
      

      and then we loop, trying the close again, and things go bad.

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

              Created:
              Updated:
              Resolved: