Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-5098

mongos process exit codes are haphazard and hardcoded

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Sharding
    • None
    • Sharding
    • ALL

      The source file s/server.cpp contains the main() routine for mongos. When unhappy about command line options or unreachable config servers it will print a message and exit. The exit codes returned are not using the "enum ExitCode" definitions in pch.h, sometimes conflict with those defined exit codes, can be zero when exiting with an error, and are generally just hard coded arbitrary numbers. mongod tries harder to use good exit codes, though it isn't perfect either.

      mongod bad port:

                  if ( cmdLine.port <= 0 || cmdLine.port > 65535 ) {
                      out() << "bad --port number" << endl;
                      dbexit( EXIT_BADOPTIONS );
                  }
      

      mongos bad chunkSize:

              // validate chunksize before proceeding
              if ( csize == 0 ) {
                  out() << "error: need a non-zero chunksize" << endl;
                  return 11;
              }
      

      mongos missing configdb parameter:

          if ( ! params.count( "configdb" ) ) {
              out() << "error: no args for --configdb" << endl;
              return 4;
          }
      

      mongos empty command line:

          if ( argc <= 1 ) {
              usage( argv );
              return 3;
          }
      

      Both mongod and mongos fail config file processing: (should be EXIT_BADOPTIONS or similar)

      mongod:

              if ( ! CmdLine::store( argc , argv , visible_options , hidden_options , positional_options , params ) )
                  return 0;
      

      mongos:

          if ( ! CmdLine::store( argc , argv , options , hidden , positional , params ) )
              return 0;
      

      This is just a sampling of bad exit codes, not a complete inventory. If this gets fixed, the fixer should survey the code for other examples.

            Assignee:
            backlog-server-sharding [DO NOT USE] Backlog - Sharding Team
            Reporter:
            tad Tad Marshall
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: