ExchangePlansManager.WriteChanges( <ExchangeMessageRecord>, <TransactionElements>)

Understanding basics of 1C:Enterprise platform. To start working with 1C:Enterprise platform visit Getting started page

#1
People who like this:0Yes/0No
Interested
Rating: 27
Joined: Apr 5, 2012
Company: 1TÇ Şirketi - Merv Bilgi İşlem Otomasyonu Yazılım Ltd. Şti.

Hi,

In ExchangePlansManager there is the method WriteChanges and even if "TransactionElements" parameter is setted platform automatically can control there data locking event to avoid conflicts between sessions on while data locks.

But how I know this method is user when the nodes are "Distributed".

I have central base and several mini sub bases. Sub bases are not Distributed infobases. I wonder is there possibility to control the TransactionElements manually?
Becuase how I know exchange data for that node is renewed on "EndWrite()" method.

For example data exchange writing coded as:

Code
Function VAPaketiOluştur(ExChangeNode,XMLDocument=Undefined) Export
   
   SetPrivilegedMode(True);
   
   RuleMap = GetExchangeRuleMapStructure(ExChangeNode);
   
   If XMLDocument = Undefined Then
      XMLDocument = New XMLWriter;
   EndIf; 
   
   XMLDocument.SetString("UTF-8");
   XMLDocument.WriteXMLDeclaration();
    
   MessageRecord = ExchangePlans.CreateMessageWriter();
    MessageRecord.BeginWrite(XMLDocument, ExChangeNode);               
    
   XMLDocument.WriteNamespaceMapping("xsi", "http://www.w3.org/2001/XMLSchema-instance");
   XMLDocument.WriteNamespaceMapping("v8",  "http://v8.1c.ru/data");
   XMLDocument.WriteNamespaceMapping("v8c",  "http://v8.1c.ru/8.1/data/core");
   XMLDocument.WriteNamespaceMapping("v8i",  "http://v8.1c.ru/8.1/data/enterprise/current-config");
    
   DeğişiklikSelection = ExchangePlans.SelectChanges(ExChangeNode, MessageRecord.MessageNo);
   While DeğişiklikSelection.Next() Do 
      DataObject = DeğişiklikSelection.Get();
      WriteDataToXML(DataObject, ExChangeNode, RuleMap);
   EndDo;
   
   MessageRecord.EndWrite();
   
   XML_AS_String = XMLDocument.Close();
   
   ExchangeStructure = New Structure;
   ExchangeStructure.Insert("DataSchema",XML_AS_String);
   
   NewValue = New ValueStorage(ExchangeStructure, New Deflation(9));
   
   SetPrivilegedMode(False);
   
   Return NewValue;
    
EndFunction

 
#2
People who like this:0Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

Hello, Murat!

If I understood you correctly, you want to register data for exchange manually. For this use following methods:

Code
ExchangePlans.RecordChanges(Node, RecordSet);

Code
ExchangePlans.DeleteChangeRecords(MessageReader.Sender, MessageReader.ReceivedNo);

For more details, please see Data exchange demo application.

 
#3
People who like this:0Yes/0No
Interested
Rating: 27
Joined: Apr 5, 2012
Company: 1TÇ Şirketi - Merv Bilgi İşlem Otomasyonu Yazılım Ltd. Şti.

I think you not understand correctly or may I did not explain situation how is needed.

Situation is that:

* I have 1 (one) central base (lets name as "A Base")
* I have 2 sub bases (lets name as "B Base" and "C Base").
* Between A base and B base there is working exchangeplan automatically.
* Between A base and C base there is working exchangeplan automatically.

Let's imagine that data exchange between A to B and A to C is working parallel on different sessions.
For example situation is thus:
while exchange plan betwen A to B is ended, it registers with EndWrite() method (we will name this session as "session no 1").
Let's imagine that in this reading there is Test 1 Item Object, Test 2 Item Object and Test 3 Item Object.
So even if, Test 1 Item Object is Locked by another session (let's name this session as "session No 2"). When executing EndWrite() method we can take such error:

Quote
{CommonModule.BayiSenkronizasyon_Sunucu.Module(610)}: Error calling context method (EndWrite): Lock conflict during transaction:
ERROR:  deadlock detected
DETAIL:  Process 61326 waits for ApplicationExclusiveLock on relation 10967341 of database 329082; blocked by process 61301.
Process 61301 waits for ApplicationExclusiveLock on relation 10967341 of database 329082; blocked by process 61326.
HINT:  See server log for query details.

So to avoid such conflicts, on exchangeplan manager there is method WriteChanges(). On this method we can set <TransactionElements> per transaction. And possibility of conflict between sessions will decrease. but this method is used for Distributed Nodes. If sub base is not distributed, how can I code algorithm writing changes to xml document?

 
#4
People who like this:0Yes/0No
Active user
Rating: 4
Joined: Nov 19, 2012
Company:

Murat Yazlıyev,
I hope I understood you correct..
It's a complicated issue and better to solve it by several steps.

1) Does your central infobase work in Client/server mode? MS SQL Server or something else?

2) What is "Default transaction data lock control mode" for your configuration?

3) What version of 1C:Enterprise platform do you use?

4) Which metadata object gives you most of the deadlocks?

5) I think there is no way to use "TransactionElements" in non distributed infobase. But you may use third parameter in "SelectChanges" method - "<SelectionFilter>". Not the easiest way, but it gives you some control of number of written elements.

6) You can also use some trick method with 2 nodes for each peripheral base. You need:
- when objects are writing you need to register changes only for first node.
- when you are writing changes you need to transfer changes from first node to second. But only fixed amount of objects, as example, 1000. Then write changes from second node to XML file and send it to peripheral base. So if you have 15000 registered changes, it takes 15 iterations to synchronize infobases.
This method was implemented in first solutions 1C Company on the 1C:Enterprise 8 platform.

 
#5
People who like this:0Yes/0No
Active user
1C:Professional
Rating: 6
Joined: May 8, 2013
Company: 1C Company

Murat,

Do I get it right that you are actually having this deadlock in your environment? How reproducible is it? Do you know the 100% solid way to get the deadlock? If so, could you send me the infobase and the step-by-step instruction on how to reproduce it?

The thing is that deadlock issues usually are extremely complex and it might take us for long time to resolve it by correspondence.

 
#6
People who like this:0Yes/0No
Interested
Rating: 27
Joined: Apr 5, 2012
Company: 1TÇ Şirketi - Merv Bilgi İşlem Otomasyonu Yazılım Ltd. Şti.

Aleksey Bochkov,
I think you get it correct. Let me answer your questions.
1. Central base on Client Server Mode. Ubuntu Server 8.13 x86-64. PostgreSQL 9.2 x86-64. 1C:Enterprise 8.3.5.1248 x86-64.
All peripheral bases are on one Server on Client Server Mode. Ubuntu Server 8.13 x86-64. PostgreSQL 9.2 x86-64. 1C:Enterprise 8.3.5.1248 x86-64.
2. "Default transaction data lock control mode" is "Managed".
3. 8.3.5.1248 x86-64.
4. On which metadata object we get an error we do not know exactly. Because we get it when executing methods like DeleteChenges, BeginWrite, EndWrite,
5. I think Filter will not help us, because we get such error when total action. Even if we read selection by filter there is probability to get an error, because in the end we should end the writing.
6. This method is interesting method. We can try to realize it. Is there any working example?

P.S. we have an idea to realize such mechanism that will place the request to an order.
or another solution is not Getting object of reference using method

Code
DeğişiklikSelection = ExchangePlans.SelectChanges(ExChangeNode, MessageRecord.MessageNo);
   While DeğişiklikSelection.Next() Do 
      DataObject = DeğişiklikSelection.Get();


we estimate that if DataObject is not closed or become undefined, even if on another session code trying to endwriting of an message and on that message is existing related ref(object). System gives me deadlock.
I think we can resolve it without Getting an Object of ref using Query to select changes refs.

 
#7
People who like this:0Yes/0No
Active user
Rating: 4
Joined: Nov 19, 2012
Company:

Murat Yazlıyev,
Great!
4. Look into the Event log for records with transaction status = Canceled and application = background job. It is really important to know.
Because if it is Informational register - you can reduce number of rows in records set by option "Main Filter" (Include dimension in information register main filter) in Designer.
If it is other register - see below..
For catalogs and documents will be different story.

5. By filtering a data you are reducing amount of record that will be proceed by "EndWrite" so you can reduce risk of deadlock. But I never tried this method so I'm not sure.

6. You can find it, as example, in Russian Trade Management 10.3. I cannot provide you any samples due to copywrite issues.. and it's pretty big algorithm.

Next set of questions :).

1) Make sure that all accumulation\accounting\recalculation registers in Designer has "Enable totals split" = True.
Make sure it is also switched on in Enterprise mode for all registers. See attached picture.

2) For one of our customer (pretty heavy solution with 14 nodes, databases over 100 Gb, over 100 users in central node) was helpful to switch off present totals for all registers. In theory in can makes some algorithms slower (reports, document posting), but it didn't affect our users. It helps us to make exchange more stable. But DBMS was IBM DB2. PostgreSQL works different.
You should do the experiment.
See the Syntax Assistant - "SetPresentTotalsUsing"

3) Do you update statistics in your databases regularly? What about indexes?

Anyway, one of the best way to figure out what is going on is to create a performance test.
Unfortunately, "Test Center" solution from 1C Company supports only Russian language.
I have a lot of experience in this field ;).

Edited: Aleksey Bochkov - Mar 05, 2015 08:38 PM
 
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)
Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.