Get the App
SLTechnology News&Howtos  ›  Development  › 

How does WCF deal with things?

Shulou Source: shulou.com Published: 2022-06-02 06:41:14 10月01日 Update

This article mainly explains "how to deal with things in WCF". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to handle things in WCF.

There are three problems with simple transactions.

1) dirty reading: to put it simply, transaction one changes the data at a certain time, and the changed data is read by transaction two, but transaction one finally fails, resulting in data rollback, and transaction two is a victim.

2) non-repeatable reading: the result of each read of the same data is different, that is, non-repeatable reading. For example, transaction one changes the data to be read, which is a non-repeatable read.

3) Phantom reading: it is very simple, for example, transaction one is in the query data, but transaction two inserts a data that meets the query conditions, which leads to the illusion of newly inserted data.

Three explanations of WCF transaction processing problems may be difficult to understand, in fact, to put it simply, dirty reading is reading the data that others are changing, while repeatable reading is changing the data that others are reading, while illusory reading is reading data that others have not had time to insert, change or delete. I think it is much easier to understand in this way. In view of the different problems above, you can set different isolation methods of transactions to prevent problems, which include

1) Any: the isolation level of a component is obtained from the isolation level of the calling component. If the component is the root component, the isolation level is used in Serializable.

2) ReadUncommitted: reads uncommitted data, which maintains a shared lock when reading data to avoid reading modified data, but can be changed before the end of the transaction, resulting in non-repeatable reads or phantom reads.

3) ReadCommitted: read commit data, issue shared locks and allow non-exclusive locking. This method is similar to reading uncommitted data, which seems similar to reading uncommitted data, but with one difference: the read-only lock of a transaction is unlocked when it is moved to the next line, while the write lock is unlocked only after the transaction is completed or aborted, and the transaction waits for all write locks to be unlocked.

4) RepeatableRead: repeatable read, similar to reading submitted data, placing locks on all data used in the query to prevent other users from updating the data. Prevents non-repeatable reads, but phantom rows can still occur. In this way, the read-only lock is not released until the transaction is terminated or aborted.

5) Serializable: prevents updates or inserts before completing the transaction.

From the above description, several isolation methods are difficult to distinguish, WCF transaction processing is very difficult, but remember these more convenient ways to understand isolation

Isolation level

ReadUncommitted

ReadCommitted

RepeatableRead

Serializable

Dirty reading

Yes

No

No

No

Non-repeatable read

Yes

Yes

No

No

Illusory reading

Yes

Yes

Yes

No

It can be seen from the above table that the isolation method is more stringent than the first class except Any. Any comes down in a continuous line, and if it has no inheritance, it will be the strictest Serializable.

Thank you for your reading, the above is the content of "how to deal with WCF". After the study of this article, I believe you have a deeper understanding of how to deal with WCF, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Data transaction manner isolation things processing that is problems repeatability levels components similarity learning queries differences content updates one line three Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Shulou Technology NVidia Xiaomi OPPO Reno