Menu

#36 exit handler for releasing resources

2.1 Beta
open
nobody
7
2008-05-29
2007-11-19
No

exitHandler needs to be registered during connection open and all the resources held should be released in the exit handler.

SIGINT and SIGTERM should be handled and from the signal handler we should call the exit handler function.

Resources include transaction, proc slot, mutexes. Incase of mutexes, it should try to recover, it it cannot then it should just exit so that cleanup thread takes care of the situation.

Discussion

  • Prabakaran Thirumalai

    • milestone: 779476 --> 2.1 Beta
     
  • Kishor Amballi

    Kishor Amballi - 2008-06-17

    Logged In: YES
    user_id=1781652
    Originator: NO

    DBAPI Exit handler design document:
    -----------------------------------

    Requirements:
    -------------
    1) whenever a connection is opened or closed it needs to be added to or removed from the list of resourceList;
    2) whenever a connection opens or closes a table it needs to be added to or removed from the list of tableList in Resource.
    3) Opened table scan need to be closed.
    4) Running transactions need to be rolledback.

    Design:
    -------
    Process manager will have a new static data member.

    static List resourceList;

    resourceList is a list of resource object which is defined as follows;

    class Resource
    {
    Connection * con;
    List tableList;
    public:
    Resource () { con = NULL; }
    };

    When connection is opened it is added into the resource list and whenever this connection opens any table
    the reference is stored in the tableList for that Resource object.

    All this is handled by ProcessManager class methods to be written appropriately.

    DbRetVal ProcessManager::registerConnection(Connection *con);
    DbRetVal ProcessManager::registerTable(Connection *con, Table *table);
    DbRetVal ProcessManager::deregisterConnection(Connection *con);
    DbRetVal ProcessManager::deregisterTable(Connection *con, Table *table);

    exit handler () {
    loop through the connections
    loop through the table references
    close the scan if open
    close table
    rollback the transaction if running.
    close the connection;
    }

     
  • Kishor Amballi

    Kishor Amballi - 2008-06-21

    Logged In: YES
    user_id=1781652
    Originator: NO

    At present a new data member is added to the DatabaseManagerImpl class.

    List tableList;

    This will have all the table handles that are open per connection.
    When Connection object goes out of scope all the handles are freed in the databaseManagerImpl destructor.
    since DatabaseManagerImpl is an object in SessionManagerImpl which in turn is part of Connection.

     

Log in to post a comment.