Log4j 2
  1. Log4j 2
  2. LOG4J2-591

Log4j closes MongoDB connections after the first log message

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 2.0-rc1
    • Fix Version/s: 2.0-rc2
    • Component/s: Appenders
    • Labels:
      None

      Description

      It seems that the AbstractDatabaseManager behavior is now to close the connection after the buffer is flushed (or immediately after a write if there is no buffer). These are the calls to commitAndClose().

      The intended behavior for close() is that it would return a connection to the connection pool. That would make sense for most good database drivers.

      However, the MongoDBProvider simply closes the MongoClient, releasing the entire pool. This means that further attempts to write to the log, after the first time, will fail.

        Activity

        Hide
        Tal Liron added a comment -

        I would suggest that it's unnecessary to close the MongoClient at all, since the Java MongoDB driver already maintains its internal pool of connections automatically. A MongoClient instance does not represent a database connection.

        So, in MongoDBConnection, close() can simply be a no-op.

        Show
        Tal Liron added a comment - I would suggest that it's unnecessary to close the MongoClient at all, since the Java MongoDB driver already maintains its internal pool of connections automatically. A MongoClient instance does not represent a database connection. So, in MongoDBConnection, close() can simply be a no-op.
        Hide
        Matt Sicker added a comment - - edited

        So does MongoClient hold an internal pool of connections, or is each MongoClient a connection object? If it's the latter, then it looks like we'll have to borrow some code from dbcp2 or commons-pool. This is related to the JDBC one as well (which we might be removing the non-JNDI versions of).

        Edit: oh ok, thanks.

        Show
        Matt Sicker added a comment - - edited So does MongoClient hold an internal pool of connections, or is each MongoClient a connection object? If it's the latter, then it looks like we'll have to borrow some code from dbcp2 or commons-pool. This is related to the JDBC one as well (which we might be removing the non-JNDI versions of). Edit: oh ok, thanks.
        Hide
        Matt Sicker added a comment -

        Fixed in revision 1585240. Please verify and close.

        Show
        Matt Sicker added a comment - Fixed in revision 1585240. Please verify and close.

          People

          • Assignee:
            Matt Sicker
            Reporter:
            Tal Liron
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development