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

avoid unlinking the unix domain socket if another process is listening

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Internal Code, Networking
    • Labels:
      None
    • Service Arch
    • 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
    • 21

      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

            Assignee:
            backlog-server-servicearch [DO NOT USE] Backlog - Service Architecture
            Reporter:
            mira.carey@mongodb.com Mira Carey
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated: