Contacts

1C 8 Managed Lock Mode does not work. The mechanism of controlled locks. If there are errors, then come back from the event handler

The "1C: Enterprise" system allows you to use two working database modes: automatic locking mode in the transaction and controlled locks in the transaction.

The fundamental difference of these modes is as follows. The automatic locking mode does not require the developer of any actions to control the locks in the transaction in order. These rules are provided by the 1C: Enterprise System platform by using certain transaction isolation levels in a given DBMS. Such a mode of operation is the most simple for the developer, but in some cases (for example, with intensive simultaneous work. large number Users) The input level of transaction isolation in the DBMS cannot provide sufficient parallelism of the work, which is manifested in the form of a large number of conflicts of locks during user operation.

When working in controlled locks, the "1C: Enterprise" system uses a much lower level of transaction isolation in the DBMS, which makes it possible to significantly increase the parallelism of the application of the applied solution. However, unlike the automatic locking mode, this transaction isolation level can no longer be able to fulfill all the rules for working with data in the transaction. Therefore, when working in manageable mode, the developer is required to independently control the locks installed in the transaction.

In a summary of the difference during operation in the automatic lock mode and in the controlled lock mode, see the following table:

Lock type Insulation level of transactions
Automatic blocking
File database Tables Serializable
MS SQL Server Record
IBM DB2. Record REPETABLE READ or SERIALIZABLE
PostgreSQL Tables Serializable
Oracle Database. Tables Serializable
Controlled blocking
File database Tables Serializable
MS SQL Server Record Read Commited.
IBM DB2. Record Read Commited.
PostgreSQL Record Read Commited.
Oracle Database. Record Read Commited.

Setting the lock mode in the configuration
The configuration has a property. Each configuration object also has a property. Data block management mode.
The data blocking mode for the entire configuration as a whole can be set to automatic values, managed (installed by default for new configuration) I. Automatic and manageable. The values \u200b\u200bare automatic and managed mean that the corresponding lock mode will be used for all configuration objects, regardless of the values \u200b\u200bset for each of the objects. Value Automatic and manageable means that the mode that is specified in its property will be used for a specific configuration object. Data block management mode: Automatic or managed.
It should be noted that the data blocking mode specified for the metadata object is set for transactions that are initiated by the "1C: Enterprise" system when working with the data of this object (for example, when modifying the object data).
If, for example, the object record operation is performed in a transaction initiated by the developer (method Start voltage ()) The data lock control mode will be determined by the parameter value. Lock modemethod Start voltage (), not the value of the properties of the metadata object Data block management mode.
By default, the parameter Lock mode has the meaning Regimening locks. Automatic, so for
In order to use controlled locks in an explicit transaction, you should specify the value of this parameter.
Rocked locks (Set this parameter makes sense iffor the configuration property "Data block management mode" is selected "Automatic and manageable") .

Work with controlled locks in the built-in language
Embedded object is designed to control the locks in the transaction BlockingData. An instance of this object can be created using a constructor and allows you to describe the necessary locked spaces and blocking modes. To install all created locks, the method is used to block () object BlockingData. If this method is performed in the transaction (explicit or implicit), the lock is installed and the end of the transaction will be removed automatically. If the method is blocked () is performed outside the transaction, the lock will not be installed.

The conditions are set to the equality of the field value of the specified value or to enter the field value to the specified range.
Conditions can be set in two ways:

● Using the explicit specification of the field name and value (method Set value() Object Element blocks);
● By specifying the data source containing the necessary values \u200b\u200b(the property of the source object Element blocks).

For each blocking element, one of two lock modes can be specified:

● shared
● Exceptional.

The compatibility table of controlled locks is as follows.

The separable blocking mode implies that blocked data cannot be changed by another transaction until the current transaction is completed.
The exceptional lock mode implies that blocked data cannot be changed by another transaction until the end of the current transaction, and cannot be read by another transaction that sets the separated blocking to this data.

Features of work in "Automatic and manageable" mode

When working in lock management mode, two features should be taken into account automatic and managed:

● Regardless of the mode specified for this transaction, the system will install the appropriate managed
Lock.
● The lock control mode is determined by the transaction of the "upper" level itself. In other words, if another transaction started by the start of the transaction, the starting transaction can be executed only in the mode that is installed for the transaction already running.

Consider the listed features in more detail.
First feature It is that even if the transaction is used automatic lock control mode, the system will install additionally and the corresponding controlled blocking When writing data in this transaction. From this it follows that transactions executed in controlled locks can to confront with transactions,
Performed in automatic lock control mode.
Second feature It is that the lock management mode is indicated for the metadata object in the configuration or specified when the transaction is explicitly specified (as the method parameter Start voltage ()) is only the "desired" regime. The actual lock control mode in which the transaction will be executed depends on whether this challenge of the start of the transaction is first, or by this time another transaction has already begun in this session of the "1C: Enterprise" system.
For example, if you want to control the locks when recording the register entries, when conducting a document, the controlled lock mode must be installed both for the register itself and for the document, since the recording of register entries will be recorded in the transaction open when writing a document.

You hit the right page! Most likely, in the morning you found that my favorite 1C 8.3 does not start with the message: " The beginning of the session with the information base is prohibited. To perform backup ...».

The first thing that needs to be done now - Urgently allow users to users. After that, calmly read the article to the end and find out why it happened and what is "blocking and removing blocking with information base 1C 8.3.

My experience suggests that you are a user (not a system administrator and not a programmer), and your information base is file (if the SQL base, specialists are already engaged in your problem). To start It is necessary to understand which folder (directory) it is located and delete one file in this folder - 1cv8.cdn (You can not save the file, it will no longer need it).

* If you are an IT specialist, you can safely go to read the "Lock and removal of blocking from the 1C information base".

In the window with a list of information bases, find your database (figure 1 on the illustration below) and click on it one (and only one!) Once with a mouse. Then click the "Edit" button (digit 2).

The list can only be one base, so this window can be familiar with the "Launch window 1C". In this case, simply click the Edit button.

If you see that the information base is located on this computer or in local network - My experience did not let down - the base file, and we all make it right. Copy this path ( figures 3 and 4).

Now go to this folder.

Just in case, here are some options for starting the conductor:

  • You have Windows XP or Windows 7. Click Start, execute, insert the previously copied location of the information base. Explorer will open.
  • You have Windows 7. But there is no "execute" item. Insert the location immediately after pressing the start. Explorer will open.
  • You have Windows 8 or Windows 10. Click Start, in the right upper corner Press the magnifier, insert the previously copied location of the information base, press ENTER. Explorer will open.

  • Find a yellow floppy disk on the taskbar and click on it. Insert the location of the information base into the address bar at the top of the conductor window. (Right-click on the address bar, change the address, right-click again on the address bar, paste).

  • Universal way for everyone versions of Windows And its settings. Click on the keyboard button with the checkbox and, without releasing it, click on the Latin R (or Russian K) keypad. The "Run" window opens, insert the previously copied location of the information base there and click OK.

Taking advantage of one of the proposed options, you will fall into the conductor window with the location of the information base.


In the Explorer window, find the 1CV8.CDN file in the file list, click on it with the right mouse button, select "Delete", as shown in the previous figure.

Ready! Your "1C: Accounting" or "1C: Salary and Personnel Management" or "1C: Trade Management" again launches.

Locking and removing lock from the 1C information base. We destroy myths.

In this section, you will find unique information on working with locks, and also receive a refutation of common misconceptions on the "Data Lock" theme.

How to install blocking?

The information database blocking mechanism is designed to complete current open sessions and prevent new connections. The location of the lock functional in the menu may vary depending on the configuration. For example, in UT, edition 11 (11.3.3.163) These are NSI and administration, [service] Locking user operation. Alternative option: NSI and administration, support and maintenance, lock jobs. UT, edition 10.3 (10.3.21.2) This is a service, users, blocking the installation of connections with an information base.

* There are special sectoral configurations in which blocking from the point of view of the interface and from the point of view of the mechanism will not look as described in this article. Since we consider the standard mechanism for most 1C configurations, we will not affect special sectoral configurations.


When this item is selected, the "Locking of Users" dialog box opens, in which you want to enter a message for users, start time and terminating the blocking, as well as code for unlocking.


Since the start and end of the blocking action is entered, it is necessary to be extremely careful in this dialog and enter information explicitly. If in the dialogue, it would be possible to enter the start of blocking "after 15 minutes" the duration of "for 20 minutes", or at least these values \u200b\u200bwere reflected on the basis of the absolute time of the beginning and end of the blocking, it would be difficult to establish blocking a year per year as it It may happen when the date-time input error is error.

The "Startup Time" option is recommended to install as the current date / time + time required by users to prepare for the output with the preservation of editable documents. For example, now 9 h 50 min, we give 10 minutes to users to preserve their results. Total blocking time should be 10 h 00 min.

End time - you can not enter, while blocking the object will be installed indefinitely (forever).

The code for unlocking is a single "password" on the launch of "from scratch", contrary to the installed blocking, which may be needed in some cases (will be mentioned below). Enter and memorize. This parameter in the case of the SQL version of the information base is visible in the "Administration of the 1C Enterprise Servers" snap and is called there "permission code".

In the case of the SQL version of the information base, the Administrator's authorization of the information base or the cluster administrator will be required.


So, after pressing the "Install Lock" button and a positive response to confirm ...


... You will return to the previous dialog box, appearance which has changed:


In the lower right corner, a message will be issued that the blocking of the users will be scheduled. This message will see only you.


Scheduled? Perhaps this is somehow connected with the regulatory tasks?

Will the planned blocking of users work, if the locking tasks is set? Yes, it will work. The locking mechanism does not use regulatory tasks.

What will be seen by users and I myself?

Until the blocking starts, active users will receive "polite" reminders about the need to complete work. In this dialogue on timeout, "Yes" is triggered, so the users who are missing at the workplace will successfully come out of the 1C session.


The blocking initiator receives another message:


After starting the blocking, the information base cannot be logged in in conventional method. About how it still goes, will be talked below. Please note that the dialog does not contain automatic indication at the time of the locking time, so the task to inform users about the time of resumption of work falls on the administrator. This information can be specified in the message to the user.



The bomb explodes exactly at the appointed time. Siren is how to explode.

Contrary to the popular belief that the completion of the active user sessions is made gently, after a warning, which can be ignored and continue to work, is actually completing, and it is better to say, "wrapping", active sessions occur exactly on the schedule, rigidly and with the loss of all unsaved results. All warnings are issued in the interval from the time of clicking the "Set lock" button until the start of the blocking, after which, the completion of the active session will occur without any notice, and 1C will switch to the cycle attempts to start configuration anew, with an interval of 1 minute.

Do not make up excluding the input modes of reference values, in which the value is missing in the directory - to exit the input mode cannot be (for example, close 1C cross), but it will not prevent complete operation. More significant interest is the mode of modal dialogue, so it will be said more about it.

* Completion of user sessions in old configurations occurs a little later than the designated time, because Users first receive an alert "The operation of the system is completed."

And exactly exploded?

To begin with, we note that in old configurations may not work blocking for the initiator of the lock. And now we turn to the consideration of the issue for the platform 8.3.

File IB user who has solved, for example, delete a document, and then go for lunch, leaving the "Mark Document Document" dialog on the screen, will keep an open connection with the information base. Of course, his session will end after lunch, after he answers "yes" or "no", but before that moment you will see that there are active users. At the same time, the initiator of the lock will be seen:


A message about a runtime error will appear in the registration log, which should be interpreted not as a runtime error, but how "not all users have completed their sessions":


And this is not the only reason blocking may not work (Cm. Next, "For whose clock?" And "But what about my users in Vladivostok?").

Modal dialogue in the SQL version of the information base on managed forms

The 1C application server has the ability to remove the session despite the modal dialogue mode. The 1C interface and modal dialogue will remain at the user on the screen, creating the visibility of an incomplete session, but in fact the session will be deleted, and the connection to the IB will be broken in a timely manner. When you try to continue working, the user will see an error message "Session is missing or deleted" or "Session is completed by the administrator" depending on the nuances.



Modal dialogue in the SQL version of the information base on ordinary forms

User sessions are completed.

After installing the lock from the dialog, it is better not to go out, because When you retain input to this dialog, before the start of the blocking, the message that blocking is already installed (really only half), active sessions zero (not true) pops up. In this case, the process of completing the work of users continues (contradicts the zero of active sessions + not quite so, because users "are completed themselves"). Although the code blocking code is not ideal, in the end, it will not interfere with setting the lock and complete the active sessions, however disorienting the information base administrator.



Will the blocking work if you set the lock and close the dialog?

Whether blocking will work if you set the lock and immediately exit 1C (i.e., complete the 1c session before starting the blocking)?

Yes. The response mechanism for the installed blocking does not provide for interaction between the initiator of the lock and the rest of users. User sessions independently check if they can work.

Whose clock will lock the lock if the time on computers is slightly different?

The problem of the surprise of the watch

With a file IB, each computer itself checks whether there is a temporary blocking range in the IB, and compares it with its local clock. Depends on the accuracy of their clock whether this computer Implement the session to complete at the right time. If the base is blocked from 10:00, for one computer this moment will come earlier, and for another - later.

In the domain environment and with impeccable operation of system administrators, time on all computers is synchronized with the domain controller. But on different reasons Time can be shot down: time is not configured to synchronize the domain controller, configured time synchronization with an external current time server, which is more unavailable, failures in network or domain services, no rights to change system time, etc.

It seems that we can talk about seconds, as a last resort, minutes. But in fact, on the computer may be, for example, no update has been established. operating systemsupporting the transition to seasonal (winter / summer) time, and the error can already be not a second, and the clock. Easily carry out such an experiment: Schedule the lock at 10 am by half an hour, and on one of the computers, turn the time for an hour ahead - the blocking does not work on it.

Therefore, before installing the lock, carefully deposit the time in the lower right corner of the computer with your own wrapped clockAnd also contact your system administrator in advance whether the time synchronization works in your IT infrastructure.

And what about my users in Vladivostok?

The problem of absolute time when users from different time zones

A temporary blockage range is saved in the information base. Look at the contents of the 1cv8.cdn blocking file (which is created in the file version of the IB), it is recorded in it start time on 07/17/2017 13:59 in the format of GGHMDDDHCHMSS without any indication on time zone:


Without specifying on the time zone it would be clear about what absolute time this is speechIf the time was always related to some particular time belt, such as UTC + 0. But in the database, the local time is saved by the computer, which was the initiator of the lock. From which time zone was this computer - it is unknown, which means unknown absolute blocking time.

If in Moscow, in a centralized IB, you set the blocking at 13:59, and this moment of time for Moscow users is in the future, then users of the same IB in Vladivostok 13:59 was 7 hours ago. And depending on the technical solution, in accordance with which work with IB users of Vladivostok is carried out, blocking these users will either work, or not.

What are the technical solutions in which the blocking will work incorrectly for users of Vladivostok? Those at which the client part 1C will receive time in Vladivostok, and not in Moscow. For example, offices are connected to a local VPN network, and the client part 1C starts with local computer, having time UTC + 10. But if they work with the database through the RDP connection or in RemoteApp mode on the Moscow server, running on this server client part 1C - everything will be fine, because It will have time UTC + 3.

Does there be problems with the survey of hours and time zone in the case of a SQL version of the information base?

Not. In this embodiment, there is a "server clock" that are accepted for the standard.

Will it throw me out of the configurator if I was in it, and the blocking began to act?

Will it be possible to enter the configurator after starting the lock action?

It is impossible! Checking the ability to work with the configurator is performed only at start-up and is not performed during operation. Therefore, if the lock is installed for subsequent work in the configurator, it is much easier to start it to run it than then bypass the ban on startup.

How to remove blocking?

In the same dialogue in which the blocking was installed. We remind you that after setting the lock in it, instead of the "Install the lock" button, the "Remove Lock" button.

In the case of the SQL version of the IB, the blocking is also possible in the "Administration of the 1C Enterprise Server Servers" snap. (see below)

What do you need an unlock code?

To enter the IB at the moment when blocking is valid. Situations in which it is necessary:

  • After installing the blocking, a session of work with IB was completed (manually or as a result of the blocking on the initiator itself), and it is required to start a new session;
  • The termination time by mistake was not filled at all;
  • The end time of the blocking was mistakenly (for example, the next month or year was inappropriate);
  • Information base in the SQL version, and to cancel incorrectly installed blocking it is not possible to delete the 1CV8.CDN file in the information database catalog.

In this case, use the hint, which is given when starting. Those. In the window with a list of information databases, click "Edit" and enter in extra options Starting string:

ENTERPRISE / F "Z: \\ Exchange \\ ut 11" / Commandable user / UC12345

... Taking into account the location catalog and unlock code.


It is better to copy this string to the clipboard and correct in the Editing Information Dialog dialog. If you confused the type of quotes or Russian "C" and Latin, you will see an error message:



In the case of proper input and subsequent launch of 1C in the enterprise mode, 1C will automatically remove the lock and will complete its operation. After that, you can delete additional parameters and run 1C as usual.

What to do if I did not install the lock, and SQL base is blocked by someone? At the same time, I do not know the unlock code.

The information database lock can be set by the configuration itself at the time of creating an archive copy. If the process of its creation has not been completed normally, the SQL base may remain in the blocking state. In this case, access to the console (more correctly - snap-in) "Administration of 1C: Enterprises" servers.

Where to look for her?

Snap "Administer 1C: Enterprises" is often installed on the same server where it is deployed SQL Server, as well as where the "Server 1C" (or "Application Server 1C") is deployed. Although it is not necessary: \u200b\u200bSQL can be installed on one computer, "Application Server 1C" - on the other, and the snap can be deployed on its own workstation. With a high probability of success, you can achieve by making the following:

  • Connect to the RDP to the server, which is specified in the SRVR \u003d row ... Using your domain login and password. If you are impossible to connect, ask system administrator Add you to a remote desktop user group. (In case of refusal of such rights, expand and configure to the workstation to snap "Administer Enterprise Server 1C");

  • On the server, find the "Administration of Servers 1C: Enterprises";
  • Run the snap-on, expand the tree to the node with your information database;

  • In the properties of the information database, remove the checkbox "blocking the start of sessions" or correct the start and end of the lock or see the "permissible code" to enter the IB (it is "code for unlocking" in the lock setting dialog).

What if all users of the information sQL database came out, and run the configurator is still impossible, because Are there active users?

In the "Connection" node of the information base, the available connections can be removed on the right side of the screen.


This is not all questions related to the blocking the information base.

If you have any questions:

  • Is it possible to work for Moscow time if you rent a server in Europe and do not want to depend on his time zone?
  • How to find 1c applications server if unknown where it is installed?
  • How to unfold "Administer 1C: Enterprise Servers" and how to configure it?
  • If in one local network multiple applications servers, how to be?
  • How to be in case cluster system? etc.

Our certified technological advisors 1C will be happy to answer them.

Periodically, you have to understand the use of blocking mechanisms in certain cases for the implementation of various tasks. Although there is a lot of information on these topics, it is very scattered and, with time, begins to forgot the material of the material that I had to flip. You have to understand again ...

As a result, the idea appeared to structure and briefly state the essence of different locking modes in 1C as a whole and in relation to typical configurations. I hope it will be useful.

And so, let's go ...

At first I will write about the levels of transaction isolation, briefly consider only those levels that are related to this article.

Insulation levels of transactions

Read. committed (reading completed) - It is allowed to read the data in the transaction, the changes over which were completed by all other transactions. The default is used for most databases.

Read. committed SNAPSHOT (Data Versioning) - Permitted reading old version Data changes for which are not completed by other transactions. It is supported by databases: Postgre. SQL and Oracle. Starting with the version of 1C 8.3 platform, implemented to work with databases:MSSQL .

REPEATABLE read. (repeated reading) - A ban on changing the records in the transaction, which have already been read earlier in the framework of other transactions.

Regarding the isolation of transactions, all, then I want to say a few words about the mechanism of separation of results in the accumulation registers.

Separation of the outcome of the accumulation registers

The accumulation register at the database level consists of two tables: Basic tableand Table of outcomes. During recording to the register (both on the coming and consumption), data is recorded in both tables, the data is recorded directly to the main table, the final line of the measurement set is updated in the outcome table. Accordingly, when working parallel transactions, the entry to the outcome table can not be executed simultaneously, which reduces the speed of documents.

To eliminate this problem, a mechanism has been created - separation.Without going into details, this mechanism allows you to update the data in the outcome of the accumulation register by the same measurement set, at the same time.

To disclose the main topic of the article, I need to describe general principles Remain control mechanisms that are used in typical configurations. If briefly, there is an old and new control mechanisms, and both are currently applied, despite the fact that the new regime is about 8 years.

Mechanisms for controlling residues in standard 1c configurations

Old scheme further Old. - A request to the database is formed to monitor free residues, in the case of a positive solution, the register is formed. On the this moment It is used in accounting quantity 3.0 and in some algorithms ut 11, ka 2, ERP 2.

disadvantages :

  • it is necessary to block the records that participate in the movement at the time of their reading, which worsens the parallelity of the work.

New scheme further New - Movement on the register is performed, then the presence of negative residues is checked, in the event of their presence, the operation is rolled back. Currently used in UT 11, ka 2, ERP 2.

Benefits:

  • you do not need to delete the movement of the document by a separate operation, the data is overwritten without approving empty sets. It seriously increases the speed of the document.
  • the speed of execution of the request to the residues is increased, since in most cases the request after conducting an empty result.
  • There is no need to pre-block the variable data.

disadvantages :

  • in the event that it is necessary to obtain data from the accounting registers (for example, the calculation of the cost of write-off), in any case, it is necessary to block the records already at the time of their reading.

Summarizing the above written, you can conclude - if you do not need to do additional requests To the database registers, it is better to apply a new mechanism if necessary - apply the old mechanism.

Well, it is time to go, in fact, to the presentation of the main topic of a given article - description of the modes of blocking. In fact, the modes are only two: Autoand ManageableThey are indicated in the general properties of the configuration, I am sure that all this is well known, so I do not stop in this detail.

You probably guessed that it is necessary to work with these two modes, it is necessary to work in different ways to different mechanisms for conducting documents. We will analyze it in more detail.

Automatic lock mode

In this case, the transaction insulation mode described above is used:REPEATABLE read..

Note: This article discusses mainly the client server version. For the file mode will be applied even more high level Insulation, which we will not consider here.

To eliminate interlocking when conducting documents with controlling residues -Old. Applies the design of the query language " FOR CHANGE", When reading the data in the transaction in the first reading, you are not divided into this data to read, but blocking the update. Accordingly, in another transaction will already be impossible to perform a similar procedure, since to impose on the same data two blocking updates from different transactions can not.

The blocking is superimposed on those records that appear in the query (in the worst case, with a non-optimal query plan, or incorrectly writing it can be blocked more records than necessary).

Note: In case of working with the file base and with P. postgre. SQL Blocking is superimposed entirely to the entire table.

Example:

Choose respens. Namerenclature, respertovarov. Non-stake as a number of regisrting. Sustakers. Lostats as respens for change

Use residual control mode -New together with the automatic locking mode, it makes sense only for registers without separating results, in this case, no additional actions do not need to do. When using registers with the separation of results may occur d. eA. dlock on reading data if the record in the register was performed at the same time, and somehow decide this problem will not work.

Managed locking mode

In this case, the transaction isolation modes are applied:Read. committed andRead. committed Snapshot .

Old. - The separated blocking is removed after reading the remnants, therefore, to exclude the possibility of negative residues, it is necessary to block the necessary records in the register explicitly before forming a request for remnants. Actually, this is the principle of controlled locking mode.

Example:

Blockers) \u003d new blocksded; Element blocks \u003d blockingded. Addly ("regisrting. Townovanskladakh. Nabinets"); Element blocks. Installing (warehouse, warehouse); Element blocking. Setting ("Nomenclature", nomenclature); Element blocks. PREPARY \u003d CARLOKLOCHED. Block edges. Cablock ();

Using the residual control mode New :

In the case of the use of registers without separating the results, additional blockages are not needed to the data database, the DBMS itself blocks the necessary data (in this case, the record in the outcome of the accumulation register).

In case of using the accumulation registers with the separation of results (by default, registers are created to the configurator, it is possible to obtain the following negative situations:

  • Without versionation mode (MS SQL and 1C 8.2) - We get a mold when trying to read data if the entry in two transactions was performed simultaneously. When writing data, the blocking will not occur, since different rows of the DBMS are used (separation of results)
  • With SNAPSHOT versioning mode (PostgreSQL, oracle or 1C 8.3) - Locking will not occur, but negative residues will appear, since the control will be executed without taking into account all non-completed transactions.

To exclude a similar situation, you need to install the record set flag before writing to the register: Block to change. This design gives the command when recording to impose exceptional lock on the records of the register balance table without taking into account the outcome separator, inherently, it simply simply disables the separation of the outcome for the accumulation register.

Accordingly, the possibility of parallel recording to a data register with a similar measurement set will be expected to be completed by the previous one.

Example:

Set records. Blocking inflammations \u003d truth;

I hope this article was useful, and after reading it is created a more holistic understanding of the operation of the 1C platform at various locking modes using different mechanisms for residual residues.

If you missed something and something was not accurate, I would see it in the comments to the article.

Special thanks much, if notice the article by an asterisk, because it does not motivate on writing new articles as your approvalJ.

Today we will talk about locks both at level 1C 8.3 and 8.2 and at the DBMS level. Data blocking is a mandatory element of any system, the number of users in which more than one.

Below I will cut, how the lock works, and which types they happen.

Lock is information that the system resource is captured by another user. There is an opinion that blocking is a mistake. No, blocking is an inevitable measure in a multiplayer system for the separation of resources.

Damage to the system can only bring excess ("extra") blockages, these are those blocking that block unnecessary information. Such blockings must be learned to eliminate, they can lead to non-optimal work Systems.

Locks in 1C are divided into object and transaction.

Objects are, in turn, optimistic and pessimistic. And the transactional can be divided into managed and automatic.

Object locks 1C.

This type of blocking is fully implemented at the 1C platform level and does not affect the DBMS.

Get 267 video tutorials for 1C for free:

Pessimistic blocking

This blocking is triggered when one user has changed something in the form of a directory, and the second is trying to change the object in the form.

Optimistic blocking

This blocking compares the versions of the object: if two users have opened the form, and one of them has changed and recorded the object, then the second when recording the system will give an error that the versions of objects differ.

Transactional locks 1C.

The mechanism of transactional locks 1C is much more interesting and more functional than the mechanism of object locks. This mechanism actively involves blocking at the DBMS level.

Invalid operation of transactional locks may result in the following issues:

  • the problem of lost change;
  • the problem of dirty reading;
  • non-refundability of reading;
  • reading phantoms.

These problems were considered in detail in the article about.

Automatic transactional locks 1C and DBMS

In the automatic mode of blocking the entire lock and fully meets the DBMS. The developer in this case is absolutely not involved in the process. This facilitates the work of the programmer 1C, however information system For a large number of users on automatic locks, it is undesirable (especially for POSTGRESQL DBMS, Oracle BD - when modifying data, they fully block the table).

For different DBMS, different degrees of insulation are used in automatic mode:

  • Serializable to the entire table - 1C file mode, Oracle;
  • Serializable on recording - MS SQL, IBM DB2 when working with non-object entities;
  • REPEATABLE READ On the record - MS SQL, IBM DB2 when working with object entities.

Managed transactional locks 1C and DBMS

All responsibility takes the developer of an applied solution at the level of 1C. At the same time, the DBMS establishes a fairly high level of insulation for transactions - Read Commited (Serializable for file DBMS).

When performing any operation with the database, the 1C Lock Manager analyzes the ability to block the resource (capture). The blocking of the same user is always compatible.

Two blockages are not compatible if: installed by different users, have incompatible (exceptional / shared) and installed on the same resource.

Physical implementation of locks in DBMS

Physically blocks are a table that is in the database called Master. The blocking table itself carries the name syslockinfo.

The table conventionally has four fields:

  1. ID of blocking session Spid;
  2. what exactly is blocked by RES id;
  3. lock type - S, U. or X. Mode. (in fact, in MS SQL there are 22 types, but only three are used in ligaments with 1C);
  4. lock state - can take value GRANT.(installed) and Wait.(Waiting for its turn).

Mechanism transaction blocks Used to competitive user access to DBMS.
Transaction is a certain inextricable operation, during which the state of the base changes. This is a minimum quantum of change: it is impossible to make a half-transaction; If the transaction has not completed, the base roll back to the initial state.
Since the transaction captures an array of data, a nuance occurs on access to this array: for example, one transaction changes the data, and the other tries to read them. The result of reading may be incorrect, because will not turn on recent changes. Therefore, at the DBMS level, the transaction isolation works. The following insulation levels are possible:

  • Read uncommited - While one transaction changes the array, the other cannot change it, but can read. Lower level of isolation.
  • Read Commited. - While one transaction changes the array, the other cannot change it, nor read
  • REPEATABLE READ. - While one transaction reads an array, the other cannot change it, but can read
  • Serialaizable - While one transaction reads an array, the other cannot change it or read. All operations are consistent. Maximum isolation level.

If for configuration 1c: enterprises installed automatic lock modeThe transaction isolating the DBMS is selected. In the case of MS SQL, it will be REPEATABLE READ or SERIALIZABLE levels, that is, the data isolation is close to the maximum. This solves problems with the correctness of the data, but can lead to the appearance of locks at the DBMS level during the intensive work of users. Therefore, in 1C: the company has its own functionality with locks, which is activated by the inclusion of controlled locks. In this case, the transaction isolation level for MS SQL will be READ Commited. The platform itself will isolate the data without relying on the DBMS.

The inclusion of the controlled lock mode occurs in the configuration properties:

Also, the lock mode can be set for specific configuration objects:

In the event that the configuration as a whole is installed automatic lock mode, all transactions on all registers will operate specifically in automatic mode, regardless of the mode that is set for the configuration object. If the managed is similar, all transactions will be in manageable. If the configuration is automatic and controlled for the configuration, then the mode for each object will be determined by its settings.

For the mode, automatic and manageable is one point. Transaction, a single user can be several transactions from the platform point of view. For example, the interactive conduct of the register document makes twotransactions - recording of the document itself, and inside this transaction recording rows for register. Depending on the lock management mode for the document itself and the register moving, four situations are possible:

  1. Document mode automatic, register automatic mode -\u003e
  2. Document Mode Controlled, register mode Managed-\u003e Register entry in managed mode
  3. Document mode automatic, register mode managed -\u003e Register record in automatic mode
  4. Document Mode Controlled, Register Automatic Register -\u003e exceptional situation (error)

Question 06.59 exam 1C: Professional on the platform. When conducting a document on any register if the document has automatic transactional lock control mode, and the register is managed (in the configuration properties, the option "Automatic and manageable") is used, then such a conduct will lead:

The correct answer is the second, define on the first transaction, if automatic, then everything is automatically.

Question 06.60 Exam 1C: Professional on the platform. When conducting a document on any register if the document has a controlled transactional lock control mode, and the register is automatic (in the configuration properties, the option "Automatic and manageable") is used, then such a conduct will lead:

  1. to the emergence of an erroneous situation
  2. the entire transaction will be performed automatically
  3. the entire transaction will be performed in the managed mode.

The correct answer is the first, define on the first transaction, if managed, then error.

Question 06.61 Exam 1C: Professional on the platform. When conducting a document on any register if the document has an automatic transactional lock control mode, and the register is managed (in the configuration properties, the "manageable" option is used), then such a conduct will lead:

  1. to the emergence of an erroneous situation
  2. the entire transaction will be performed automatically
  3. the entire transaction will be performed in the managed mode.


Did you like the article? Share it