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

avoid unlinking the unix domain socket if another process is listening

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: Backlog
    • Component/s: Internal Code, Networking
    • Labels:
      None
    • Sprint:
      Service Arch 2019-07-15, Service Arch 2019-08-12, Service Arch 2019-08-26, Service Arch 2019-09-09, Service Arch 2019-09-23, Service Arch 2019-10-07, Service Arch 2019-10-21
    • Linked BF Score:
      21

      Description

      Currently whenever we bind a unix domain socket we first try to unlink it. This is to avoid a scenario where we crashed and left the old file around (because bind can't succeed if a file is already there).

      Rather than performing that flow, if instead we:

      if (bind()) {
          // we're bound, done!
          return;
      }
       
      if (non_blocking_connect_succeeds_or_fails_with_eagain()) {
          // someone else is listening, go away!
          fassert("address in use");
      }
       
      // there's a file there, but no one listening.  I.e. the old path
      unlink();
      bind();
      return;
      

      Then we can avoid trampling on a running mongod and instead fail the process that's starting up

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated: