Desktop version

Main > Forum > 1C:Enterprise Platform > Studying 1C:Enterprise platform > DocumentObject.<DocName>.IsLocked() & DataLock Mechanism & UnlockDataForEdit

Forum

Search UsersRules
DocumentObject.<DocName>.IsLocked() & DataLock Mechanism & UnlockDataForEdit
#1
Interested
Points:: 0
Joined:: Apr 5, 2012

Hi,

While trying to write an object, if I receive such an error message:

Quote
Lock conflict during transaction:
ERROR:  deadlock detected
DETAIL:  Process 13663 waits for ApplicationExclusiveLock on relation 2962767 of database 329082; blocked by process 14532.
Process 14532 waits for ApplicationExclusiveLock on relation 2962767 of database 329082; blocked by process 13663.
HINT:  See server log for query details.
How I understand it means that an object which I want to write to db is locked from another session or process? Am I right?

So, I prefer to control lock situation of an object in this case. In onject there exists a method named IsLocked(). In syntax written as:
Quote
Note that this method is used to check if a database object is locked by a certain object of script. It cannot be used to check whether a database object is locked in general.
So this method does not control even if data is locked from another session or process?

So how can I control if data is locked by another session or process? And how can I Unlock the data that locked by another session or process?

Or I need to use common method named UnlockDataForEdit(<Key>,<Fo rmIdentifier>) ??

Profile
#2
Just came
Points:: 0
Joined:: Oct 8, 2013

Hi, Murat.

You are rigth. You can not control locked data or not from another session.

You can only try to lock and wait when a data will be free.

Profile
#3
Active user
Points:: 0
Joined:: May 8, 2013

Quote
"I understand it means that an object which I want to write to db is locked from another session or process? Am I right?"
Not exactly. It means that you and someone else are mutually blocking each other - you wait until he releases a resource you need, while he wait for you to release a resource he needs. This type of conflict is called deadlock and it's one of the most complicated errors to deal with.
Quote
"In onject there exists a method named IsLocked()"
This method has nothing to do with this type of locks. The thing is that there are two different types of locks in 1C: object locks (see Developer Guide, 9.1) and transaction locks. Deadlocks occur in connection with transaction locks while IsLocked() method works with object locks only.

Transaction locks are used by DBMS and 1C to prevent data loss or inconsistency as a result of concurrent user activity (for example these locks do no allow two users to write the same database table record concurrently). This locks are acquired mostly automatically on almost every action you perform on data and you have very limited options to control them.
Quote
"And how can I Unlock the data that locked by another session or process?"
You cannot. All transaction locks are released automatically (in most cases when transaction is over). There is no way to unlock anything by 1C script and there is a good reason for that. You cannot just unlock whatever you want because it can cause data loss or inconsistency.

OK, let's get back to you deadlock.

Basically, a deadlock is an error in script (most probably in 1C application script). In other words there is something wrong with data processing sequence in you configuration. There are at least 4 different lines of scriptwhose running in this particular order in two different sessions caused the deadlock. We need to find them out and fix the sequence.

To be able to do that we need to collect a technological log containing TLOCK and TDEADLOCK events. Please copy the attached logcfg.xml file into "\bin\conf" folder on 1C server where "\bin" - is a folder 1C cluster runs from. Wait for a minute and make sure that the folder "C:\1C\logs" appeared on the server and there are subfolders looking like "rphost_XXX" inside.

After that you have to wait until at least one deadlock is happened, archive all content of "C:\1C\logs" folder and upload it to the forum.

Please be advised that tech log collecting can cause system slow-down. To switch the tech log off just delete or rename the logcgf.xml file.

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.