mongo::client::initialize() c++ legacy driver segfault

785 views
Skip to first unread message

Yan Yan

unread,
Jan 9, 2015, 8:12:58 AM1/9/15
to mongod...@googlegroups.com
I stepped thru the code w/ gdb. It crashed while running mongo::client::initialize(). Strace shows it crashed after opening /dev/random. The 26compat branch worked but the legacy branch failed to work on my centos7. Attached please find the code. The driver version is 4e0f4bd0231244a90f4de431eb6229f53788af42
Thx.

git clone 'https://github.com/mongodb/mongo-cxx-driver.git'
scons -j8 --prefix=$HOME/mongo-client-install --sharedclient install

==> Makefile <==
CXXFLAGS = -std=c++11 -g -O2 -I$$HOME/mongo-client-install/include
LIBS = -L$$HOME/mongo-client-install/lib -lmongoclient -lboost_regex-mt -lboost_thread-mt -lboost_system-mt

run_bson_benchmark: bson_benchmark
./bson_benchmark.sh
bson_benchmark: bson_benchmark.cpp
$(CXX) bson_benchmark.cpp -o bson_benchmark $(CXXFLAGS) $(LIBS)

==> bson_benchmark.cpp <==
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <vector>
#include <random>
#include <thread>
#include <boost/format.hpp>
#ifdef _WIN32
#include <WinSock2.h>
#endif
#include "mongo/client/dbclient.h" // for the driver

using namespace std;
using mongo::be;
using mongo::bo;
using mongo::bob;

int main(int argc, char** argv) {
  string hostColonPort;
  if(argc == 2) {
    hostColonPort = argv[1];
  }
  else {
    hostColonPort = "localhost:27017";
  }
  mongo::client::initialize();
  mongo::DBClientConnection c;
  c.connect(hostColonPort);

  ios_base::sync_with_stdio(false);
  vector<string> fieldnames;

  for (int c = 0; c < 20; ++c) {
    fieldnames.push_back(str(boost::format("price%02d") % c));
  }

  for (int a = 0; true; ++a)
    {
      const mongo::OID generated = mongo::OID::gen();
      bob b;
      b.append("_id", generated);
      //b.appendTimestamp("time");
      b.append("lineno", "lineno");
      b.append("symbol", "symbol");
      b.append("feed", "feed");

      for (int c = 0; c < 20; ++c) {
b.appendNumber(fieldnames[c], (double) 1/(c+1.0));
      }
      bo result = b.obj();

      cout << a << "\n";
      c.insert("test.ticks", result);
    }
}

==> strace.log <==
execve("./bson_benchmark", ["./bson_benchmark"], [/* 38 vars */]) = 0
brk(0)                                  = 0x1df5000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f8741a8a000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/home/user01/mongo-client-install/lib/tls/x86_64/libmongoclient.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/home/user01/mongo-client-install/lib/tls/x86_64", 0x7fffe8161130) = -1 ENOENT (No such file or directory)
open("/home/user01/mongo-client-install/lib/tls/libmongoclient.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/home/user01/mongo-client-install/lib/tls", 0x7fffe8161130) = -1 ENOENT (No such file or directory)
open("/home/user01/mongo-client-install/lib/x86_64/libmongoclient.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/home/user01/mongo-client-install/lib/x86_64", 0x7fffe8161130) = -1 ENOENT (No such file or directory)
open("/home/user01/mongo-client-install/lib/libmongoclient.so", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0000\255\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=19223894, ...}) = 0
mmap(NULL, 3350792, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f8741538000
mprotect(0x7f8741663000, 2097152, PROT_NONE) = 0
mmap(0x7f8741863000, 28672, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x12b000) = 0x7f8741863000
mmap(0x7f874186a000, 264, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f874186a000
close(3)                                = 0
open("/home/user01/mongo-client-install/lib/libboost_regex-mt.so.1.53.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=150801, ...}) = 0
mmap(NULL, 150801, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f8741a65000
close(3)                                = 0
open("/lib64/libboost_regex-mt.so.1.53.0", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@\266\4\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1060600, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f8741a64000
mmap(NULL, 3154480, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f8741235000
mprotect(0x7f8741331000, 2093056, PROT_NONE) = 0
mmap(0x7f8741530000, 32768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xfb000) = 0x7f8741530000
close(3)                                = 0
open("/home/user01/mongo-client-install/lib/libboost_thread-mt.so.1.53.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/lib64/libboost_thread-mt.so.1.53.0", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\260\267\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=94304, ...}) = 0
mmap(NULL, 2188504, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f874101e000
mprotect(0x7f8741033000, 2093056, PROT_NONE) = 0
mmap(0x7f8741232000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x14000) = 0x7f8741232000
close(3)                                = 0
open("/home/user01/mongo-client-install/lib/libboost_system-mt.so.1.53.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/lib64/libboost_system-mt.so.1.53.0", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\320\22\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=15592, ...}) = 0
mmap(NULL, 2109688, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f8740e1a000
mprotect(0x7f8740e1d000, 2093056, PROT_NONE) = 0
mmap(0x7f874101c000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7f874101c000
close(3)                                = 0
open("/home/user01/mongo-client-install/lib/libstdc++.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/lib64/libstdc++.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\20\265\5\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=991744, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f8741a63000
mmap(NULL, 3171360, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f8740b13000
mprotect(0x7f8740bfc000, 2093056, PROT_NONE) = 0
mmap(0x7f8740dfb000, 40960, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xe8000) = 0x7f8740dfb000
mmap(0x7f8740e05000, 82976, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f8740e05000
close(3)                                = 0
open("/home/user01/mongo-client-install/lib/libm.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/lib64/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\260T\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1141552, ...}) = 0
mmap(NULL, 3150168, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f8740811000
mprotect(0x7f8740912000, 2093056, PROT_NONE) = 0
mmap(0x7f8740b11000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x100000) = 0x7f8740b11000
close(3)                                = 0
open("/home/user01/mongo-client-install/lib/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/lib64/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360*\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=88720, ...}) = 0
mmap(NULL, 2184192, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f87405fb000
mprotect(0x7f8740610000, 2093056, PROT_NONE) = 0
mmap(0x7f874080f000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x14000) = 0x7f874080f000
close(3)                                = 0
open("/home/user01/mongo-client-install/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\34\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=2107600, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f8741a62000
mmap(NULL, 3932736, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f874023a000
mprotect(0x7f87403f0000, 2097152, PROT_NONE) = 0
mmap(0x7f87405f0000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1b6000) = 0x7f87405f0000
mmap(0x7f87405f6000, 16960, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f87405f6000
close(3)                                = 0
open("/home/user01/mongo-client-install/lib/libpthread.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/lib64/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\240l\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=141616, ...}) = 0
mmap(NULL, 2208864, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f874001e000
mprotect(0x7f8740034000, 2097152, PROT_NONE) = 0
mmap(0x7f8740234000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16000) = 0x7f8740234000
mmap(0x7f8740236000, 13408, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f8740236000
close(3)                                = 0
open("/home/user01/mongo-client-install/lib/librt.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/lib64/librt.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\300\"\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=44048, ...}) = 0
mmap(NULL, 2128952, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f873fe16000
mprotect(0x7f873fe1d000, 2093056, PROT_NONE) = 0
mmap(0x7f874001c000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6000) = 0x7f874001c000
close(3)                                = 0
open("/home/user01/mongo-client-install/lib/libicuuc.so.50", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/lib64/libicuuc.so.50", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\240!\5\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1539384, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f8741a61000
mmap(NULL, 3641312, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f873fa9d000
mprotect(0x7f873fc01000, 2097152, PROT_NONE) = 0
mmap(0x7f873fe01000, 69632, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x164000) = 0x7f873fe01000
mmap(0x7f873fe12000, 16352, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f873fe12000
close(3)                                = 0
open("/home/user01/mongo-client-install/lib/libicui18n.so.50", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/lib64/libicui18n.so.50", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\20\206\t\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=2091952, ...}) = 0
mmap(NULL, 4183008, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f873f69f000
mprotect(0x7f873f88e000, 2097152, PROT_NONE) = 0
mmap(0x7f873fa8e000, 57344, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ef000) = 0x7f873fa8e000
mmap(0x7f873fa9c000, 992, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f873fa9c000
close(3)                                = 0
open("/home/user01/mongo-client-install/lib/libicudata.so.50", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/lib64/libicudata.so.50", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0p\5\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=20789896, ...}) = 0
mmap(NULL, 22884400, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f873e0cb000
mprotect(0x7f873f49e000, 2093056, PROT_NONE) = 0
mmap(0x7f873f69d000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x13d2000) = 0x7f873f69d000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f8741a60000
open("/home/user01/mongo-client-install/lib/libdl.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/lib64/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\320\16\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=19512, ...}) = 0
mmap(NULL, 2109744, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f873dec7000
mprotect(0x7f873deca000, 2093056, PROT_NONE) = 0
mmap(0x7f873e0c9000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7f873e0c9000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f8741a5f000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f8741a5e000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f8741a5c000
arch_prctl(ARCH_SET_FS, 0x7f8741a5c740) = 0
mprotect(0x7f87405f0000, 16384, PROT_READ) = 0
mprotect(0x7f873e0c9000, 4096, PROT_READ) = 0
mprotect(0x7f873f69d000, 4096, PROT_READ) = 0
mprotect(0x7f8740b11000, 4096, PROT_READ) = 0
mprotect(0x7f874080f000, 4096, PROT_READ) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f8741a5b000
mprotect(0x7f8740dfb000, 32768, PROT_READ) = 0
mprotect(0x7f8740234000, 4096, PROT_READ) = 0
mprotect(0x7f873fe01000, 65536, PROT_READ) = 0
mprotect(0x7f873fa8e000, 49152, PROT_READ) = 0
mprotect(0x7f874001c000, 4096, PROT_READ) = 0
mprotect(0x7f874101c000, 4096, PROT_READ) = 0
mprotect(0x7f8741232000, 8192, PROT_READ) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f8741a59000
mprotect(0x7f8741530000, 20480, PROT_READ) = 0
mprotect(0x7f8741863000, 24576, PROT_READ) = 0
mprotect(0x611000, 4096, PROT_READ)     = 0
mprotect(0x7f8741a8b000, 4096, PROT_READ) = 0
munmap(0x7f8741a65000, 150801)          = 0
set_tid_address(0x7f8741a5ca10)         = 6455
set_robust_list(0x7f8741a5ca20, 24)     = 0
rt_sigaction(SIGRTMIN, {0x7f8740024780, [], SA_RESTORER|SA_SIGINFO, 0x7f874002d130}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {0x7f8740024810, [], SA_RESTORER|SA_RESTART|SA_SIGINFO, 0x7f874002d130}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
brk(0)                                  = 0x1df5000
brk(0x1e16000)                          = 0x1e16000
futex(0x7f8740e1796c, FUTEX_WAKE_PRIVATE, 2147483647) = 0
futex(0x7f8740e17978, FUTEX_WAKE_PRIVATE, 2147483647) = 0
clock_getres(CLOCK_MONOTONIC, {0, 1})   = 0
open("/dev/urandom", O_RDONLY)          = 3
read(3, "\260\10EUI\255R\246\27v\262\245+\342\323\31-kB\26\261)\270\366\276.H\312\241\215@7"..., 8191) = 8191
close(3)                                = 0
--- SIGSEGV {si_signo=SIGSEGV, si_code=SI_KERNEL, si_addr=0} ---
+++ killed by SIGSEGV (core dumped) +++

Andrew Morrow

unread,
Jan 9, 2015, 10:04:08 AM1/9/15
to mongod...@googlegroups.com

Hi -

Thanks for the report. A few questions and comments to help us sort out what is going wrong:

- What githash did you get when you cloned the repository?

- I notice that you are compiling your application with --std=c++11, but it does not appear that you are building the driver in C++11 mode as well. Could you try adding --c++11 to the driver build flags? Also, please note that building C++11 applications against a system boost compiled in C++03 mode may or may not function correctly.

- You do not appear to be checking the return value of the call to mongo::client::initialize, which you must do to ensure that it is OK before continuing to use the driver.

- While the strace output is useful, it doesn't provide a stack trace at the time of the crash. Could you re-run your application under GDB and provide the results of the 'where' command after it crashes?

We appreciate your taking the time to test the legacy driver.

Thanks,
Andrew


--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/8cdafbcd-41a5-48bc-b245-3b011d517bc6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Yan Yan

unread,
Jan 9, 2015, 10:48:29 AM1/9/15
to mongod...@googlegroups.com
githash=4e0f4bd0231244a90f4de431eb6229f53788af42
mongo::Status ret = mongo::client::initialize(); // The program crashed before returning a mongo::Status

Compiling the client w/o -std=c++11 or w/ -std=c++03 leads to a bunch of errors. Compiling with -std=c++11 or -std=c++0x results in no errors. I am not sure if the boost that come with centos7 was compiled with -std=anything.

make -k -B
g++ bson_benchmark.cpp -o bson_benchmark -g -O2 -Wno-deprecated-declarations -I$HOME/mongo-client-install/include \
-L$HOME/mongo-client-install/lib -lmongoclient -lboost_regex-mt -lboost_thread-mt -lboost_system-mt
In file included from /usr/include/c++/4.8.2/random:35:0,
                 from bson_benchmark.cpp:5:
/usr/include/c++/4.8.2/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support fo\
r the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -s\
td=gnu++11 compiler options.
 #error This file requires compiler and library support for the \
  ^
bson_benchmark.cpp: In function ‘int main(int, char**)’:
bson_benchmark.cpp:53:7: warning: name lookup of ‘c’ changed [enabled by default]
       c.insert("test.ticks", result);
       ^
bson_benchmark.cpp:27:29: warning:   matches this ‘c’ under ISO standard rules [enabled by default]
   mongo::DBClientConnection c;
                             ^
bson_benchmark.cpp:47:16: warning:   matches this ‘c’ under old rules [enabled by default]
       for (int c = 0; c < 20; ++c) {
                ^
make: *** [bson_benchmark] Error 1
make: Target `run_bson_benchmark' not remade because of errors.



------------------------------------------------------------
scons -j8 --prefix=$HOME/mongo-client-install --sharedclient --c++11 install
I have added "--c++11" to compile the driver. The client has ran w/o crashing. The client cpu utilization has increased 26%. The client cpu utilization was 6% when I used the 26compat driver.

------------------------------------------------------------
gdb session with optimized code

user01@centos7 ~/mongodbTest
$ gdb ./bson_benchmark
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-51.el7
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
Reading symbols from /home/user01/mongodbTest/bson_benchmark...done.
(gdb) break main
Breakpoint 1 at 0x4042b0: file bson_benchmark.cpp, line 18.
(gdb) run
Starting program: /home/user01/mongodbTest/./bson_benchmark
n[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Breakpoint 1, main (argc=1, argv=0x7fffffffe378) at bson_benchmark.cpp:18
18      int main(int argc, char** argv) {
(gdb) n
20        if(argc == 2) {
(gdb)
19        string hostColonPort;
(gdb)
20        if(argc == 2) {
(gdb)
24          hostColonPort = "localhost:27017";
(gdb)
26        mongo::client::initialize();
(gdb)

Program received signal SIGSEGV, Segmentation fault.
0x00000000004009d8 in ?? ()
(gdb) where
#0  0x00000000004009d8 in ?? ()
#1  0x0000000000406c4f in ~_Function_base (this=0x7fffffffe028, __in_chrg=<optimized out>)
    at /usr/include/c++/4.8.2/functional:2030
#2  ~function (this=0x7fffffffe028, __in_chrg=<optimized out>) at /usr/include/c++/4.8.2/functional:2174
#3  mongo::client::Options::~Options (this=0x7fffffffdff0, __in_chrg=<optimized out>)
    at /home/user01/mongo-client-install/include/mongo/client/options.h:32
#4  0x0000000000404352 in main (argc=<optimized out>, argv=<optimized out>) at bson_benchmark.cpp:26
(gdb)

------------------------------------------------------------
gdb session w/ --dbg=on
How can I show the the <optimized out> part? I have removed -O from g++ already.

user01@centos7 ~/mongodbTest
$ gdb ./bson_benchmark
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-51.el7
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
Reading symbols from /home/user01/mongodbTest/bson_benchmark...done.
(gdb) break main
Breakpoint 1 at 0x4042b0: file bson_benchmark.cpp, line 18.
(gdb) run
Starting program: /home/user01/mongodbTest/./bson_benchmark
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Breakpoint 1, main (argc=1, argv=0x7fffffffe378) at bson_benchmark.cpp:18
18      int main(int argc, char** argv) {
(gdb) n
20        if(argc == 2) {
(gdb)
19        string hostColonPort;
(gdb)
20        if(argc == 2) {
(gdb)
24          hostColonPort = "localhost:27017";
(gdb)
26        mongo::client::initialize();
(gdb)

Program received signal SIGSEGV, Segmentation fault.
0x00000000004009d8 in ?? ()
(gdb) where
#0  0x00000000004009d8 in ?? ()
#1  0x0000000000406c4f in ~_Function_base (this=0x7fffffffe028, __in_chrg=<optimized out>)
    at /usr/include/c++/4.8.2/functional:2030
#2  ~function (this=0x7fffffffe028, __in_chrg=<optimized out>) at /usr/include/c++/4.8.2/functional:2174
#3  mongo::client::Options::~Options (this=0x7fffffffdff0, __in_chrg=<optimized out>)
    at /home/user01/mongo-client-install/include/mongo/client/options.h:32
#4  0x0000000000404352 in main (argc=<optimized out>, argv=<optimized out>) at bson_benchmark.cpp:26
(gdb)

Andrew Morrow

unread,
Jan 9, 2015, 12:41:59 PM1/9/15
to mongod...@googlegroups.com
On Fri, Jan 9, 2015 at 10:48 AM, Yan Yan <lamh...@gmail.com> wrote:
githash=4e0f4bd0231244a90f4de431eb6229f53788af42
mongo::Status ret = mongo::client::initialize(); // The program crashed before returning a mongo::Status

Yes, I was just pointing out a flaw in the client code that could lead to other crashes down the line if not corrected.

On a similar note, you should avoid using the "mongo::be", "mongo::bo", and "mongo::bob" typedefs because they are likely to be removed before the legacy driver GA ships.

 

Compiling the client w/o -std=c++11 or w/ -std=c++03 leads to a bunch of errors. Compiling with -std=c++11 or -std=c++0x results in no errors. I am not sure if the boost that come with centos7 was compiled with -std=anything.

Correct, the client code is clearly dependent on C++11 due to the <random> header, so you will need to compile both the client and the mongo C++ driver in C++11 mode.
 


------------------------------------------------------------
scons -j8 --prefix=$HOME/mongo-client-install --sharedclient --c++11 install
I have added "--c++11" to compile the driver. The client has ran w/o crashing.

Wonderful. So the crash appears to have been caused by using a C++03 built driver with a C++11 application. Are there any other problems you would need help with?

 
The client cpu utilization has increased 26%. The client cpu utilization was 6% when I used the 26compat driver.

I'm unclear on what you are saying here. Generally, higher utilization of some resource is good. Are you saying that the legacy driver is faster than 26compat, or slower, or that it uses more CPU to do the same work, or that given the same CPU quota, it performs 26% more operations?

Also, are you benchmarking 26compat in C++11 mode as well?

Please let me know what else we can do to help.

Thanks,
Andrew


Yan Yan

unread,
Jan 9, 2015, 8:26:26 PM1/9/15
to mongod...@googlegroups.com
26compat driver compiled WITH --c++11
client cpu = 6% x 4 = 24%
server cpu = 360%
80k tps 100% insert workload

legacy driver compiled WITH --c++11
client cpu = 30% x 4 = 120%
server cpu = 280%
27k tps at 100% insert workload <-- much slower

Andrew Morrow

unread,
Jan 10, 2015, 10:27:59 AM1/10/15
to mongod...@googlegroups.com

Hi -

Can you provide the source code for the benchmark that is generating those numbers? We are of course interested in any performance regression in the driver.

However, please be aware that in 26compat, the default is to use unacknowledged writes, while the legacy branch uses acknowledged writes by default. All modern MongoDB drivers now use default acknowledged writes, and adding this support to the C++ driver was one of the primary goals of the legacy-1.0.0 release:


Since the 26compat and legacy drivers have different defaults, it is important when benchmarking to ensure that your benchmark is using a consistent acknowledgement model for writes.

On the legacy branch, you can select a different write concern for your insert by passing an instance of the mongo::WriteConcern class to the insert method. On the 26compat branch, you must use the getLastError function to accomplish something similar.

Thanks,
Andrew


--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.

Yan Yan

unread,
Jan 11, 2015, 1:33:55 AM1/11/15
to mongod...@googlegroups.com
I have got it. We have some wonderful support here ^_^

c.insert("test.ticks", result); // 27k tps in legacy driver, 80k tps in 26compat
c.insert("test.ticks", result, 0, &mongo::WriteConcern::unacknowledged); // 80k tps
c.insert("test.ticks", result, 0, &mongo::WriteConcern::acknowledged); // 27k tps
Reply all
Reply to author
Forward
0 new messages