Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-33

add a set_oid_fuzz(int) method

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 0.4
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      C / any platform
    • Fully Compatible

      Ahh, sorry, i misunderstood your usecase and thought you were talking
      about thread-safety rather than process-safety. Yes, you are correct
      and the server (and C++ driver) use platform-specific tricks to ensure
      that we don't generate duplicate OIDs. Unfortunately that isn't
      possible for the C driver since it shouldn't have any
      platform-specific code.

      I think a good solution would be to add a set_oid_fuzz(int) method
      that will allow users to set that as needed. I should probably also
      allow you to use a custom inc function to use atomic incs if using
      threading.

      Could you file a JIRA ticket for those?

      On Mon, Jan 3, 2011 at 2:48 PM, Greg Sabatino <gsabatino@dnsstuff.com> wrote:
      >
      > Mathias:
      >
      > Thanks for quick reply.  We did see the comment in the code, but don't
      > believe the atomic increment would not completely solve our use-case issue.
      >  Generally, we sort of hoped to get a call to 'rand' (or other API) each
      > time through.  However, around the topic you mention, the only ANSI solution
      > we have for you is a file system write-lock.  Other solutions of course get
      > into system level resource management which will vary by platform.
      > Some quick things we were thinking of to improve the seeding across
      > processes would be to use microseconds (rather than seconds), or (on linux)
      > use a read from /dev/urandom to seed.  Either should improve initial random
      > values by process but are not 100% guaranteed to be unique.  We did plan to
      > call the randomizer each time through the routine.
      > We additionally planned to look into some other solutions for uid generation
      > out there, but haven't put the time in yet...
      > -Greg
      >
      > On 1/3/11 2:00 PM, "Mathias Stearn" <mathias@10gen.com> wrote:
      >
      > You are correct. If you look at line 114 of bson.c you'll see a TODO
      > to make the inc atomic. Unfortunately there is no way to do that in
      > ANSI C. Do you know any good way to do that?
      >
      > On Mon, Jan 3, 2011 at 1:43 PM, Greg Sabatino <gsabatino@dnsstuff.com>
      > wrote:
      >>
      >> Hello Mathias:
      >>
      >> We are in a development project, and looking to implement the C version of
      >> the mongoDB driver (pulled down from github a few weeks back).  The
      >> 'oid_gen' routine in the bson.c file is not quite as robust as we would
      >> like.  In our scenario, there will likely be multiple processes executing
      >> concurrently on the same host and making connections.   It's reasonable to
      >> assume that they may hit this code block in the same second, likely
      >> generating the same oid.   Any planned rev on the driver in the near-term
      >> that may touch this area?  If not, we may take a pass at it sometime in
      >> the
      >> next month or two and can send back to you.
      >>
      >> Thanks,
      >> -Greg
      >>
      >
      >

            Assignee:
            kbanker Kyle Banker
            Reporter:
            dnsstuff DNS Stuff
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: