mongo::client::initialize() considered harmful

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: API, Implementation
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Newer versions of mongo-cxx-driver require that mongo::client::initialize() is called at the beginning. I cannot remember having to do that for not much older versions. This causes major problems for us. In Fawkes, a robot software system, we have plugins loaded at run-time, some of which use MongoDB through mongo-cxx-driver. Now the initalization could require different options, where only the first would actually be accepted. Especially shutdown cannot be called lightly as it breaks the library for plugins still loaded.

      The question now is, why is it necessary to rely on global or static initialization at all? It would be much cleaner to have a handle which bundles everything related to a particular instance. Ideally, this would be per database connection so that they can be fully independent.

      The problem here is, that the library is assumed too much to be a platform that resides in a single application. The only benefit I see is that it avoids having to have a single place where the initialization of the many (more or less unrelated) components is performed. However, this comes at the cost of making the initialization trace largely non-obvious and cause problems as just described by relying on static initialization. The source separation comes at the cost of run-time obfuscation.

      Is there another reason overseen and can it be considered to re-factoring the library to avoid the use of a single static initializer?

            Assignee:
            Andrew Morrow (Inactive)
            Reporter:
            Tim Niemueller
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: