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

SystemD services depending on mongod will be started before mongo is ready to take connections

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Done
    • Affects Version/s: 3.4.2
    • Fix Version/s: None
    • Component/s: Packaging
    • Environment:
      Centos 7.
    • Operating System:
      ALL
    • Steps To Reproduce:
      Hide

      Make a systemD script that is set to start after mongod.
      When the service is started, mongo won't be ready yet to take connections, causing the service to fail if it depends on that.

      Show
      Make a systemD script that is set to start after mongod. When the service is started, mongo won't be ready yet to take connections, causing the service to fail if it depends on that.

      Description

      I have the following systemD script for my software:

      [Unit]
      Description=LynxChan
      After=mongod.service
       
      [Service]
      ExecStart=/usr/bin/lynxchan
      User=node
      StandardOutput=syslog
      Restart=on-abort
       
      [Install]
      WantedBy=multi-user.target
      

      See "After=mongod.service". Because of that, my software expects mongo to be ready to take connections when it is booted by this init script.

      However, for 3.4, mongo is not ready yet to take connections when my software runs.

      I just tested with 3.2 and everything works as expected, my service is always able to connect to mongo when the system boots.

        Activity

        Hide
        ramon.fernandez Ramon Fernandez added a comment -

        Thanks for your report Stephen Lynx, we can reproduce the behavior you describe and are investigating.

        Show
        ramon.fernandez Ramon Fernandez added a comment - Thanks for your report Stephen Lynx , we can reproduce the behavior you describe and are investigating.
        Hide
        mark.agarunov Mark Agarunov added a comment - - edited

        Hello Stephen Lynx,

        Looking over the unit file you've provided, you may get the desired behavior by adding Requires=mongod.service or Wants=mongod.service to the [Unit] section of your service. The systemd documentation has a bit more info on these parameters.

        Thanks,
        Mark

        Show
        mark.agarunov Mark Agarunov added a comment - - edited Hello Stephen Lynx , Looking over the unit file you've provided, you may get the desired behavior by adding Requires=mongod.service or Wants=mongod.service to the [Unit] section of your service. The systemd documentation has a bit more info on these parameters. Thanks, Mark

          People

          • Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: