1 Reply Latest reply: Jan 15, 2013 3:37 PM by Paula B-Oracle RSS

    Segmentation fault when enabling replication with SQL API


      I've compiled BDB 5.3.21 on Ubuntu 11.04 (x86) with the following configure options:

      ../dist/configure enable-sql enable-sql_compat enable-debug enable-tcl --with-tcl=/usr/lib

      I was able to follow the Replication Usage Examples given in "Getting Started with the SQL APIs" to set up a set of replicated master/client databases.

      However, after I exited out of the dbsql session that started replication on the master database and re-opened the master database with dbsql, executing "pragma replication_initial_master=ON;" followed by "pragma replication=ON;" led to a segmentation fault. gdb showed that the segmentation fault occurred at:

      dbsql> pragma replication=ON;

      Program received signal SIGSEGV, Segmentation fault.
      0x0032d42b in __env_ref_get (dbenv=0x8056ad8, countp=0xbfffd498)
      at ../src/env/env_region.c:772
      772          renv = infop->primary;
      (gdb) list
      767          REGENV *renv;
      768          REGINFO *infop;
      770          env = dbenv->env;
      771          infop = env->reginfo;
      772          renv = infop->primary;
      773          *countp = renv->refcnt;
      774          return (0);
      775     }

      Does anybody know of a solution to this or could this be a bug? Thanks in advance.

      P.S. here's a stack trace:

      (gdb) bt
      #0 0x0032d42b in __env_ref_get (dbenv=0x8056ad8, countp=0xbfffd498)
      at ../src/env/env_region.c:772
      #1 0x001786fc in hasDatabaseConnections (p=0x8056708)
      at ../lang/sql/generated/sqlite3.c:44420
      #2 0x00178a11 in bdbsqlPragmaStartReplication (pParse=0x80648e0,
      pDb=0x80561cc) at ../lang/sql/generated/sqlite3.c:44533
      #3 0x001797f5 in bdbsqlPragma (pParse=0x80648e0,
      zLeft=0x8062e20 "replication", zRight=0x8062dc0 "ON", iDb=0)
      at ../lang/sql/generated/sqlite3.c:44812
      #4 0x001c215d in sqlite3Pragma (pParse=0x80648e0, pId1=0x8064b60,
      pId2=0x8064b70, pValue=0x8064b90, minusFlag=0)
      at ../lang/sql/generated/sqlite3.c:78941
      #5 0x001e5c83 in yy_reduce (yypParser=0x8064b20, yyruleno=256)
      at ../lang/sql/generated/sqlite3.c:96668
      #6 0x001e6761 in sqlite3Parser (yyp=0x8064b20, yymajor=1, yyminor=...,
      pParse=0x80648e0) at ../lang/sql/generated/sqlite3.c:97051
      #7 0x001e7537 in sqlite3RunParser (pParse=0x80648e0,
      zSql=0x80648b8 "pragma replication=ON;", pzErrMsg=0xbfffdba0)
      at ../lang/sql/generated/sqlite3.c:97877
      #8 0x001c730e in sqlite3Prepare (db=0x8056010,
      zSql=0x80648b8 "pragma replication=ON;", nBytes=-1, saveSqlFlag=1,
      ---Type <return> to continue, or q <return> to quit---
      pReprepare=0x0, ppStmt=0xbfffdc8c, pzTail=0xbfffdc88)
      at ../lang/sql/generated/sqlite3.c:80736
      #9 0x001c7739 in sqlite3LockAndPrepare (db=0x8056010,
      zSql=0x80648b8 "pragma replication=ON;", nBytes=-1, saveSqlFlag=1,
      pOld=0x0, ppStmt=0xbfffdc8c, pzTail=0xbfffdc88)
      at ../lang/sql/generated/sqlite3.c:80828
      #10 0x001c7a5e in sqlite3_prepare_v2 (db=0x8056010,
      zSql=0x80648b8 "pragma replication=ON;", nBytes=-1, ppStmt=0xbfffdc8c,
      pzTail=0xbfffdc88) at ../lang/sql/generated/sqlite3.c:80903
      #11 0x0804baf6 in shell_exec (db=0x8056010,
      zSql=0x80648b8 "pragma replication=ON;",
      xCallback=0x804a3c4 <shell_callback>, pArg=0xbfffde14, pzErrMsg=0xbfffdcfc)
      at ../lang/sql/sqlite/src/shell.c:1092
      #12 0x0805030e in process_input (p=0xbfffde14, in=0x0)
      at ../lang/sql/sqlite/src/shell.c:2515
      #13 0x08051453 in main (argc=2, argv=0xbffff3f4)
      at ../lang/sql/sqlite/src/shell.c:2946


      Edited by: snowcrash on Jan 15, 2013 2:16 PM
        • 1. Re: Segmentation fault when enabling replication with SQL API
          Paula B-Oracle
          Thank you for reporting this. I have been able to reproduce this crash in-house.

          You need to specify the replication_initial_master and replication pragmas as part of initially creating your SQL database. The replication_initial_master pragma is not used or needed after the initial database creation at the initial master site. The replication=on pragma is a persistent setting that we remember internally the first time you specify it. This means that after specifying replication=on for the first time on a site, we will automatically restart replication for you in future dbsql sessions when we open the underlying Berkeley DB environment.

          This gives you a very simple workaround: don't respecify replication=on when you reenter dbsql.

          Of course, we shouldn't be crashing on an unnecessary pragma. I have added this to our list of fixes to consider for the future.

          Paula Bingham