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

Fix assertion failure when opening DB in readonly mode after unclean shutdown

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • WT10.0.0, 4.4.2, 4.7.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • 5
    • Storage - Ra 2020-08-10, Storage - Ra 2020-08-24

      Hi!

      During internal development we use WiredTiger built with diagnostic enabled (configure --enable-diagnostic).

      And we found that after unclean DB shutdown (due to e.g. application crash) WT aborts on failed assertion when our application tries to open DB in 'readonly' mode.

      Can be seen by slightly modified examples/c/ex_access.c:

      diff -ru wiredtiger-3.2.1/examples/c/ex_access.c wiredtiger-3.2.1.my/examples/c/ex_access.c
      --- wiredtiger-3.2.1/examples/c/ex_access.c     2019-08-27 08:43:05.000000000 +0300
      +++ wiredtiger-3.2.1.my/examples/c/ex_access.c  2020-07-14 12:23:08.000000000 +0300
      @@ -82,9 +82,19 @@
       int
       main(int argc, char *argv[])
       {
      +    char cmd[1024];
      +    WT_CONNECTION *conn;
      +
           home = example_setup(argc, argv);
       
           access_example();
       
      +    sprintf(cmd, "cp %s/WiredTiger.turtle %s/WiredTiger.turtle.set", home, home);
      +
      +    error_check(system(cmd));
      +
      +    error_check(wiredtiger_open(home, NULL, "readonly", &conn));
      +    error_check(conn->close(conn, NULL));
      +
           return (EXIT_SUCCESS);
       }
      

      Run:

      $ ./ex_access 
      Got record: key1 : value1
      [1594720179:473625][21713:0x7fa8ff2be740], connection: __wt_fs_remove, 125: !F_ISSET(S2C(session), WT_CONN_READONLY)
      [1594720179:473675][21713:0x7fa8ff2be740], connection: __wt_abort, 28: aborting WiredTiger library
      Aborted (core dumped)
      

      Under GDB:

      $ libtool --mode=execute gdb ./ex_access
      ...
      (gdb) r
      Starting program: /home/sbn/src/wiredtiger/wiredtiger-3.2.1.my/examples/c/.libs/lt-ex_access 
      ...
      Got record: key1 : value1
      ...
      [1594720258:3681][21832:0x7ffff7fe0740], connection: __wt_fs_remove, 125: !F_ISSET(S2C(session), WT_CONN_READONLY)
      [1594720258:3728][21832:0x7ffff7fe0740], connection: __wt_abort, 28: aborting WiredTiger library
      
      Program received signal SIGABRT, Aborted.
      0x00007ffff6fe1337 in raise () from /lib64/libc.so.6
      (gdb) bt
      #0  0x00007ffff6fe1337 in raise () from /lib64/libc.so.6
      #1  0x00007ffff6fe2a28 in abort () from /lib64/libc.so.6
      #2  0x00007ffff7af9df3 in __wt_abort (session=session@entry=0x604010) at src/os_common/os_abort.c:30
      #3  0x00007ffff7af922c in __wt_fs_remove (durable=false, name=0x7ffff7b9c6a4 "WiredTiger.turtle.set", session=0x604010) at ./src/include/os_fs.i:125
      #4  __wt_remove_if_exists (session=session@entry=0x604010, name=name@entry=0x7ffff7b9c6a4 "WiredTiger.turtle.set", durable=durable@entry=false) at src/os_common/filename.c:85
      #5  0x00007ffff7af7892 in __wt_turtle_init (session=session@entry=0x604010) at src/meta/meta_turtle.c:197
      #6  0x00007ffff7a75e36 in wiredtiger_open (home=<optimized out>, event_handler=event_handler@entry=0x0, config=config@entry=0x401baa "readonly", connectionp=connectionp@entry=0x7fffffffd7b0)
          at src/conn/conn_api.c:2650
      #7  0x000000000040102c in main (argc=<optimized out>, argv=<optimized out>) at ex_access.c:96
      

      As a workaround we remove WiredTiger.turtle.set, but it's not very convenient.

      Thanks!

            Assignee:
            ravi.giri@mongodb.com Ravi Giri
            Reporter:
            Dmitri Shubin Dmitri Shubin
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: