Changes between Version 19 and Version 20 of MapGuideRfc86


Ignore:
Timestamp:
10/06/09 09:59:28 (15 years ago)
Author:
tomfukushima
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • MapGuideRfc86

    v19 v20  
    1 = !MapGuide RFC 86 - The Bound FDO Connection =
     1= !MapGuide RFC 86 - The Pinned FDO Connection =
    22
    33This page contains a change request (RFC) for the !MapGuide Open Source project.
     
    2323== Overview ==
    2424
    25 This proposal is to extend MapGuide Feature Service so that calls to Feature Service can use the same FDO connection to avoid some unexpected errors. The solution is to add two methods !BindConnection(!MgResourceIdentifier featureSourceId) and !UnbindConnection(!MgResourceIdentifier featureSourceId) so that users are able to bind/unbind an FDO connection to the current user session.
     25This proposal is to extend !MapGuide Feature Service so that calls to Feature Service can use the same FDO connection to avoid some unexpected errors. The solution is to add two methods !PinConnection(!MgResourceIdentifier featureSourceId) and !UnpinConnection(!MgResourceIdentifier featureSourceId) so that users are able to pin/unpin an FDO connection to the current user session.
    2626
    2727== Motivation ==
    2828
    29 Currently MapGuide Server maintains an FDO connection pool in order to improve performance. Once MapGuide Server receives a request to access data in a feature source, it will try to find an available FDO connection in FDO connection pool. It avoids exhausting FDO connections to the underlying RDBMS and improves performance of MapGuide Server when many users use MapGuide Server in the same time. However, it means that one user session may use the different FDO connection for the same feature source at the different time. Sometimes, it will result in some unexpected errors. Let’s take a look at one example.
     29Currently !MapGuide Server maintains an FDO connection pool in order to improve performance. Once !MapGuide Server receives a request to access data in a feature source, it will try to find an available FDO connection in FDO connection pool. It avoids exhausting FDO connections to the underlying RDBMS and improves performance of !MapGuide Server when many users use !MapGuide Server in the same time. However, it means that one user session may use the different FDO connection for the same feature source at the different time. Sometimes, it will result in some unexpected errors. Let’s take a look at one example.
    3030
    3131{{{
     
    6262}}}
    6363
    64 In the example above, it is possible that FDO connections used by executing SQL statements "SAVEPOINT X", "SAVEPOINT Y", "ROLLBACK TO X", "ROLLBACK TO Y" and "COMMIT" are completely different FDO connections. If so, it will result in an error when executing SQL statement "ROLLBACK TO X", "ROLLBACK TO Y" or "COMMIT". If it isn't a nested transaction, it can be resolved by passing an !MgTransaction instance when executing SQL statements because MapGuide Server will guarantee that operations in the same transaction use the same FDO connection. However, it still has the following two issues.
    65   * There are only three methods supporting transaction, MgFeatureSerive::!UpdateFeatures, MgFeatureSerive::!ExecuteSqlQuery and MgFeatureSerive::!ExecuteSqlNoQuery.
    66   * MgFeatureSerive::!BeginTransaction will do something on the DRBMS serverwhen opening a transaction. This has consequences such as updates are only visible in this transaction, and data gets locked.
     64In the example above, it is possible that FDO connections used by executing SQL statements "SAVEPOINT X", "SAVEPOINT Y", "ROLLBACK TO X", "ROLLBACK TO Y" and "COMMIT" are completely different FDO connections. If so, it will result in an error when executing SQL statement "ROLLBACK TO X", "ROLLBACK TO Y" or "COMMIT". If it isn't a nested transaction, it can be resolved by passing an !MgTransaction instance when executing SQL statements because !MapGuide Server will guarantee that operations in the same transaction use the same FDO connection. However, it still has the following two issues.
     65  * There are only three methods supporting transaction, MgFeatureService::!UpdateFeatures, MgFeatureService::!ExecuteSqlQuery and MgFeatureService::!ExecuteSqlNoQuery.
     66  * !MgFeatureService::!BeginTransaction will do something on the DRBMS serverwhen opening a transaction. This has consequences such as updates are only visible in this transaction, and data gets locked.
    6767
    6868Another issue is that it may result in a whole bunch of connections are open when using !MgFeatureReader, !MgDataReader or !MgSqlDataReader. Each reader will use an FDO connection exclusively. So in the example below, it will have all of a sudden a whole bunch of admin connections open when you open a connection with admin rights.
     
    8484}}}
    8585
    86 So we need a mechanism to bind an FDO connection to one user session. Then MapGuide always uses this bound FDO connection when executing any FDO commands for the same feature source in this session. Moreover, we need provide a mechanism to unbind the FDO connection which is bound to one user session so that FDO connection is available for other user sessions after the user doesn’t need to bind the FDO connection to his session.
     86So we need a mechanism to pin an FDO connection to one user session. Then !MapGuide always uses this pinned FDO connection when executing any FDO commands for the same feature source in this session. Moreover, we need provide a mechanism to unpin the FDO connection which is pinned to one user session so that FDO connection is available for other user sessions after the user doesn’t need to pin the FDO connection to his session.
    8787
    8888== Proposed Solution ==
    8989
    90 In this RFC, we extend Feature Service to add the ability to use the same FDO connection for calls to Feature Service. The following two methods will be added to class !MgFeatureService to allow users to bind/unbind an FDO connection to the current session. Method !BindConnection(...) will select an FDO connection from FDO connection pool for the specified feature source if there is one FDO connection available. Otherwise, create a new FDO connection and add it to FDO connection pool. Then this FDO connection is bound to current session. It means this FDO connection becomes an exclusive connection and can’t be used by other sessions. Since then, any call to Feature Service for the feature source and the session, which needs an FDO connection, will always use the bound FDO connection till users call method !UnbindConnection(...) to unbind this FDO connection or current session is time-out. By default, one session will be time-out after 20 minutes. Users can modify this setting through property [!SiteServiceProperties]->!SessionTimeOut in MapGuide Server configuration file "serverconfig.ini".
     90In this RFC, we extend Feature Service to add the ability to use the same FDO connection for calls to Feature Service. The following two methods will be added to class !MgFeatureService to allow users to pin/unpin an FDO connection to the current session. Method !PinConnection(...) will select an FDO connection from FDO connection pool for the specified feature source if there is one FDO connection available. Otherwise, create a new FDO connection and add it to FDO connection pool. Then this FDO connection is pinned to current session. It means this FDO connection becomes an exclusive connection and can’t be used by other sessions. Since then, any call to Feature Service for the feature source and the session, which needs an FDO connection, will always use the pinned FDO connection till users call method !UnpinConnection(...) to unpin this FDO connection or current session is time-out. By default, one session will be time-out after 20 minutes. Users can modify this setting through property [!SiteServiceProperties]->!SessionTimeOut in !MapGuide Server configuration file "serverconfig.ini".
    9191
    9292{{{
    9393    /// \brief
    94     /// Bind FDO connection to current session for a feature source.
     94    /// Pin the FDO connection to current session for a feature source.
    9595    ///
    9696    /// \param featureSourceId (MgResourceIdentifier)
     
    100100    /// Returns nothing.
    101101    ///   
    102     void BindConnection(MgResourceIdentifier featureSourceId) = 0;
     102    void PinConnection(MgResourceIdentifier featureSourceId) = 0;
    103103
    104104    /// \brief
    105     /// Unbind FDO connection bound to current session for the specified feature
     105    /// Unpin the FDO connection pinned to current session for the specified feature
    106106    /// source.
    107107    ///
     
    112112    /// Returns nothing.
    113113    ///
    114     void UnbindConnection(MgResourceIdentifier featureSourceId) = 0;
     114    void UnpinConnection(MgResourceIdentifier featureSourceId) = 0;
    115115}}}
    116116