国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

How to handle the concurrency problems on ASP.Net

2024-07-10 12:56:16
字體:
來源:轉載
供稿:網友

<數據唯一性>

acid中重要的一個環節: data isolation

data isolation
creating fully-isolated transactions in a multithreaded environment is a non-trivial exercise. there are three ways isolation can be violated:
lost update: one thread reads a record, a second thread updates the record, and then the first thread overwrites the second thread's update.
線程1讀了一條記錄,線程2更新了一條記錄,接著線程1覆蓋了線程2的更新。dirty read: thread one writes data; thread two reads what thread one wrote. thread one then overwrites the data, thus leaving thread two with old data.
線程1寫入了數據,線程2讀取了線程1所寫入的數據。線程1更改了數據,最后線程2讀取的是沒有更新的舊數據。unrepeatable read: thread one reads data; the data is then overwritten by thread two. thread one tries to re-read the data but it has changed.
線程1讀去了數據;但是此數據接著被線程2修改了。線程1試圖從新讀取數據,但是數據已經被修改了。
 
solution for multiuser updates:

to prevent this kind of problem, you may use any of the following strategies:
step1: locking the records. when one user is working with a record, other users can read the records but they cannot update them. 鎖定要修改的記錄。
    app: you would need to write monitoring processes that keep track of how long records have been locked, and unlock records after a time-out period.step2:updating only the columns you change. in the previous example, qa would have changed only the owner and the status, while the developer would have changed only the description.
只更新你要修改的列.
    app: comparing original against new,this method involves creating an event handler for the rowupdating event. the event handler examines the original value of each field and queries the database for the value currently in the database. step3:previewing whether the database has changed before you make your updates. if so, notify the user. 預先檢查一下在執行更新之前數據庫是否已經被修改了,如果是這樣的話,通知用戶。step4:attempting the change and handling the error, if any.
處理更改和錯誤。
    app: the best approach to managing concurrency is to try the update and then respond to errors as they arise.this approach has tremendous efficiency advantages.for this approach to work, your stored procedure for updates must fail if the data has changed in the database since the time you retrieved the dataset. since the dataset can tell you the original values that it received from the database, you need pass only those values back into the stored procedure as parameters, and then add them to the where clause in your update statement,



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 华阴市| 神农架林区| 哈尔滨市| 凌源市| 高青县| 军事| 富裕县| 湖南省| 司法| 全椒县| 葵青区| 石城县| 九江市| 宁化县| 仙游县| 依安县| 嘉荫县| 德令哈市| 霸州市| 东乡族自治县| 共和县| 德钦县| 屏山县| 伊春市| 开封市| 巴林左旗| 饶阳县| 潢川县| 大邑县| 镇原县| 正定县| 石景山区| 枞阳县| 万安县| 东安县| 华容县| 大田县| 垦利县| 连平县| 双桥区| 大城县|