27.2. Database copies functionality structure


<< Prev   Next >>

Actually, when creating a database copy, the tables being the copies of the relative tables of the infobase objects are created in the copy database. A copy tables scope is determined with the help of the Content property of the object that describes a certain database copy (DatabasesCopiesManager object). In the process of operation, the system tracks the changes in the transferred data and, on command, transfers these changes to each database copy. Data transfer to the registered database copies is performed using a special method of the program interface (DatabasesCopies.Update()). There is a possibility to update the database copies asynchronously, for example, by using a regular task (similar to updating the full-text search index). In other words, a database copy becomes a "real" copy only after the changes registered in the transferred tables are transferred into it.

When a database copy is updated by selecting DatabaseCopy.Update(), internally the following dissimilar (as to their content) operations are performed by the platform:

  1. Data is initially exported to a new copy table. All table data, regardless of the state of separators, is transferred for the table that belongs to the separated configuration object (data of all areas is transferred).

    For that purpose, one or more system background jobs are used. The said export is made upon each modification of copy data structure (adding or deleting an attribute or an object itself).

  2. Current data is exported to an existing copy table. The separated data is transferred to the data area that is determined by the separator values of the transferred transaction in the main database.

    This action is performed without using background jobs. In this scenario, all successfully completed actions performed with data stored in the main database are exported. Obviously, modified data is saved and exported for those objects only which are marked as placed in the said copy. If the scope of changes is large or update interval is long, such transfer and calling the DatabaseCopies.Update() method can be time-consuming.

The update process described above is used if the standard data replication type is selected for a certain database copy (DatabaseCopyManager.ReplicationType property). If an external type of database data replication is selected for a database copy:

  • 1C:Enterprise system performs no actions to create tables in the copy.
  • 1C:Enterprise system performs no actions on the data synchronization between the main database and its copy. DatabaseCopies.Update() method is not required.
  • The personnel setting the database copies parameters are fully responsible for the creation of tables of the required structure as well as for the data replication and regularity.
  • In this case, 1C:Enterprise only transfers the data acquisition query to the database copy instead of DBMS of the main database. Any inconsistency in the data structure between the copy and the main base will result in a query error.
  • 1C:Enterprise considers that data in this copy is always up-to-date.

The platform supports several standard replication versions (described by the DatabaseCopiesStandardReplicationVersion system enumeration). The versions differ in tools that determine data that needs to be transferred from the main database to the copy. However, data is always transferred by 1C:Enterprise server cluster. Standard replication versions:

  • Version1. In this case, 1C:Enterprise server cluster tools track the changes that must be transferred to the copy.
  • Version2. In this case, tools of the DBMS where the main database is located track the changes that must be transferred to the copy.

To get and set a standard database copy replication version, use the GetStandardReplicationVersion()/SetStandardReplicationVersion() methods of the database copy manager. When a standard replication version is changed, states of all copies with the standard replication type are reset. At the next copy update, its data will be fully reloaded.

1C:Enterprise platform does not support change tracking using DBMS tools (Version2) for some of the supported database management systems. Database management systems that allow using your own change tracking tools:

  • Microsoft SQL Server version 2008 or later. The change record functionality (Change Data Capture) is used. The change record functionality will be enabled automatically if the user on whose behalf the server cluster accesses Microsoft SQL Server is a member of the sysadmin server role.

    If the user is not a member of this server role, they need to perform the following commands in the main database to enable the change record functionality:

execute sys.sp_cdc_enable_db;
execute sp_configure 'show advanced options', 1;
RECONFIGURE;
execute sp_configure 'max text repl size', -1;
RECONFIGURE;

Run these commands under a user who is a member of the sysadmin server role.

To ensure the functionality operation, you also need the SQL Server Agent service. For more information about the change record functionality, read the documentation for Microsoft SQL Server.

If Version2 of the standard change replication functionality is selected and the main database DBMS does not support this mode, Version1 will be used instead.

As it has already been stated, the system uses the database copies when working with the Query object in the data composition system. 1C:Enterprise platform allows you to control where a query (or data composition) will be executed. The following properties are used for this (for the Query and DataCompositionOutputParameterValues objects):

  • DatabaseCopiesUse. Allows you to specify the possibility and priority of using database copies:
    • DontUseCopies. Specifies that the query will be executed in the main database. In this case, it is considered that all data is always relevant.
    • UseCopiesOnly. Specifies that the query will be executed only in some database copy. Relevance of data in the copy is considered. If a query cannot be executed in a copy, an exception will be thrown and the query will not be executed.
    • PreferUseCopies. Specifies that the query must be executed in the database copy. Relevance of data in the copy is considered. If a suitable copy is not found at the time of query execution, the query will be executed in the main database.
    • Auto. It is interpreted as the PreferUseCopies value.
  • UsedDatabaseCopies. Determines the list of database copies where a query or data composition can be executed.

If a database copy can be used when executing a query, make sure all the following conditions are met for that:

  1. All tables used in the query or in all data sources of the composition system must be in one copy. The term "all" means the following tables used in the query (directly or indirectly):
    • Tables and attributes used as query sources.
    • Tables and attributes from which any data in the query is obtained (for example, in the case of address put "through a dot").
    • Tables and attributes engaged in the conditions of restriction of access to the data (if any).
  2. Relevance of data in the copy meets developer requirements. The algorithm for determining relevance is described below.
  3. If the table contains a query for which the selection in the copy is set the condition in the query must correspond to the selection to the copy. If the query contains no condition but the copy contains the selection for this table such query will be transferred to the database or copy in which the selection for this table is set.

To easier select the tables to locate in the database copy, use the Tables selection for data accelerator external data processor. It is located on ITS disk in the section of the developer's methodological support.

To set the required data relevance, use the RequiredDataRelevance and RequiredDataRelevanceTime properties of the Query object (and property of the same name of the data composition output parameter). These properties behave differently based on the DatabaseCopiesUse property value. For example:

  • DatabaseCopiesUse property is set to PreferUseCopies. The RequiredDataRelevance property is interpreted as follows:
    • Relevant. In this case, the data will be obtained only from the main database.
    • Any. In this case, the data from the copy containing all tables necessary for the query execution will be used and these tables contain the data of required relevance (RequiredTimeDataRelevance property). If there is no required database copy, the query will be performed in the main database.
  • DatabaseCopiesUse property is set to UseCopiesOnly. The RequiredDataRelevance property is interpreted as follows:
    • Relevant. In this case, data from the copy is considered usable if it is relevant. Data will be considered relevant if there are no changes in the main database for this copy that have not yet been transferred to the copy.
    • Any. In this case, data from a copy with required data relevance will be used (the RequiredDataRelevanceTime property). If there is no required database copy, an exception is thrown.

If the RequiredDataRelevance property is set to Auto (with any value of the DatabaseCopiesUse property), required data relevance in the copy is automatically determined by the platform. In this case, the Relevant value will be used for the Query object and the Any –value will be used for the data composition system.

The platform allows obtaining the information on the data source and its relevance after the data retraction (and –during the data composition for the data composition system):

  • The QueryResult object provides the following properties:
    • RelevantData. Allows you to determine whether the data obtained by the query is relevant.
    • RelevanceTime. Contains the date and time of the last data update in the copy. For relevant data, it contains the time of query initiation.
    • DatabaseCopy. Contains the name of the database copy used for the data extraction.
  • The composition system expression language contains RelevantData(), DataRelevanceTime(), and DatabaseCopy() functions. The purpose of these functions fully corresponds to the query result properties of the same name.

The output to the report of the information on the information source and retrieved date relevance can be managed using the data composition system. OutputDataRelevance and OutputDatabaseCopy parameters are intended for it. However, it should be noted that if a data composition schema has nested schemas, each data composition schema can either be part of a main data base or any of its copies which is in compliance with requirements specified in the query being executed.

If several copies are set in the infobase and each of these copies meets the executed query requirements, the system will randomly select a copy from the list of suitable ones. There is no copy selection in the system in this case.

See also:

  • Use of requirements of functions appointment for server management.
  • Functions of data composition system expression language.

<< Prev   Next >>

Icon/Social/001 Icon/Social/006 Icon/Social/005 Icon/Social/004 Icon/Social/002