[SERVER-5098] mongos process exit codes are haphazard and hardcoded Created: 25/Feb/12  Updated: 06/Dec/22  Resolved: 31/Oct/19

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Tad Marshall Assignee: [DO NOT USE] Backlog - Sharding Team
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-9434 Process exit codes should be between ... Closed
Assigned Teams:
Sharding
Operating System: ALL
Participants:

 Description   

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.


Generated at Thu Feb 08 03:07:54 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.