版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、Lock & ConcurrencyGrow market shareThrive for excellenceSucceed with smarter solutionsIBM Confidential 2009 IBM Corporation9 slidesGIBloMbIanlfoTremcahtnioonloMgaynSaegrevmiceenstWhy are locks needed?Page 2Page 2PI+E |IBM DB2 AdministrationIBM Confidential 2009 IBM CorporationGlobal Technology Servi
2、cesGrowth ? Thrive for excellence ? Smarter solutionsClassification of locksPage 3Page 3PI+E |IBM DB2 AdministrationIBM Confidential 2009 IBM CorporationGlobal Technology ServicesGrowth ? Thrive for excellence ? Smarter solutionsObjects of locksPage 4Page 4PI+E |IBM DB2 AdministrationIBM Confidentia
3、l 2009 IBM CorporationGlobal Technology ServicesGrowth ? Thrive for excellence ? Smarter solutionsTable lock modesWSE在linux上最多使用4CPU/16G内存Page 5Page 5PI+E |IBM DB2 AdministrationIBM Confidential 2009 IBM CorporationGlobal Technology ServicesGrowth ? Thrive for excellence ? Smarter solutionsRow lock
4、modesWSE在linux上最多使用4CPU/16G内存Page 6Page 6PI+E |IBM DB2 AdministrationIBM Confidential 2009 IBM CorporationGlobal Technology ServicesGrowth ? Thrive for excellence ? Smarter solutionsWhen two application meetsWSE在linux上最多使用4CPU/16G内存Page 7Page 7PI+E |IBM DB2 AdministrationIBM Confidential 2009 IBM Co
5、rporationGlobal Technology ServicesGrowth ? Thrive for excellence ? Smarter solutionsIntroduction to isolation levelsPage 8Page 8PI+E |IBM DB2 AdministrationIBM Confidential 2009 IBM CorporationGlobal Technology ServicesGrowth ? Thrive for excellence ? Smarter solutionsLock wait and timeoutPage 9Pag
6、e 9PI+E |IBM DB2 AdministrationIBM Confidential 2009 IBM CorporationGlobal Technology ServicesGrowth ? Thrive for excellence ? Smarter solutionsLock escalationWSE在linux上最多使用4CPU/16G内存Page 10Page1P0I+E|IBM DB2 AdministrationIBM Confidential 2009 IBM CorporationGlobal Technology ServicesGrowth ? Thriv
7、e for excellence ? Smarter solutionsSET CURRENT LOCK TIMEOUTPage 11Page1P1I+E|IBM DB2 AdministrationIBM Confidential 2009 IBM CorporationGlobal Technology ServicesGrowth ? Thrive for excellence ? Smarter solutionsDeadlockPage 12Page1P2I+E|IBM DB2 AdministrationIBM Confidential 2009 IBM CorporationGl
8、obal Technology ServicesGrowth ? Thrive for excellence ? Smarter solutionsSupport Other Vendors Concurrency Modelsn Easy for developers to work with DB2n No need to rewrite concurrent access logic Optimize throughput for mixed workloads Eliminate conflicts between Read workloads and Write workloadsn
9、 Log-based control No management overhead13Page 13IBM DB2 AdministrationIBM Confidential 2009 IBM CorporationGlobal Technology ServicesGrowth ? Thrive for excellence ? Smarter solutionsConcurrency Control Prior to DB2 9.7n Oracle default:Snapshot Isolationn DB2 default:Cursor stabilitysignificant ef
10、fort to re-order table14Page 14acceIBsM sDB2 tAodminaistrvatioon idIBM dConefidaentdial loc k200s9 IBM CorporationPorting other RDBMS applications to DB2 requiredSituationResultReader blocks ReaderNoReader blocks WriterMaybeWriter blocks ReaderYesWriter blocks WriterYesSituationResultReader blocks R
11、eaderNoReader blocks WriterNoWriter blocks ReaderNoWriter blocks WriterYesGlobal Technology ServicesGrowth ? Thrive for excellence ? Smarter solutionsConcurrency Control in DB2 V9.7n Up to DB2 9.5 Cursor Stability is the default isolation leveln Now in DB2 Cobra Currently Committed is the default fo
12、r NEW databases Currently Committed is disabled for upgraded databases, i.e., Cursor Stability semantics are usedn Applications that depend on the old behavior (writers blocking readers) will need to update their logic or disable the Currently Committed semantics.15Page 15IBM DB2 AdministrationIBM C
13、onfidential 2009 IBM CorporationGlobal Technology ServicesGrowth ? Thrive for excellence ? Smarter solutionsConcurrency Control in DB2 V9.7n Currently Committed is a variation on DB2s Cursor Stability isolation If uncommitted row-change found, use currently committed version of data Avoids timeouts
14、and deadlocks Log based:No management overheadCursor StabilityCurrently Committed16Page 16IBM DB2 AdministrationIBM Confidential 2009 IBM CorporationSituationResultReader blocks ReaderNoReader blocks WriterNoWriter blocks ReaderYesWriter blocks WriterYesSituationResultReader blocks ReaderNoReader bl
15、ocks WriterNoWriter blocks ReaderNoWriter blocks WriterYesGlobal Technology ServicesGrowth ? Thrive for excellence ? Smarter solutionsIsolation Levels how to specify in DB2n Statement Level Use the WITH clause Overrides the isolation level specified for the packagen Dynamic SQL within the current se
16、ssion SET CURRENT ISOLATION for all subsequent dynamic SQL statements within the same sessionn Precompile / Bind ISOLATION option of PREP or BIND commandn JDBC or SQLJ at run time SQLJ profile customizer (db2sqljcustomize command)n CLI or ODBC at run time CHANGE ISOLATION LEVEL command17Page 17IBM D
17、B2 AdministrationIBM Confidential 2009 IBM CorporationGlobal Technology ServicesGrowth ? Thrive for excellence ? Smarter solutionsExample Cursor Stability (v9.5)update T1 set col1 = ? where col2 = 2update T2 set col1 = ? where col2 = ?select * from T2 where col2 = ?select * from T1 where col5 = ? an
18、d col2 = ?Waiting because isWaiting because isreading uncommitted datareading uncommitted data18Page 18IBM DB2 AdministrationIBM Confidential 2009 IBM CorporationDEADLOCK!Transaction ATransaction BGlobal Technology ServicesGrowth ? Thrive for excellence ? Smarter solutionsExample Cursor Stability wi
19、th Currently Committedupdate T1 set col1 = ? where col2 = 2update T2 set col1 = ? where col2 = ?select * from T2 where col2 = ?select * from T1 where col5 = ? and col2 = ?commitcommitNo lockingReads last committed versionNo lockingReads last committed versionof the df the data19Page 19IBM DB2 Admini
20、strationIBM Confidential 2009 IBM CorporationtNa o deadlocks, no timeouts in this scenario!oTransaction ATransaction BGlobal Technology ServicesGrowth ? Thrive for excellence ? Smarter solutionsCurrently Committed how to use itn cur_commit DB config parameter ON: default for new DBs created in Cobra
21、 CC semantics in place DISABLED: default value for existing DBs old CS semantics in placen PRECOMPILE/BIND CONCURRENTACCESSRESOLUTION: Specifies the concurrent access resolution to use for statements in the package. USE CURRENTLY COMMITTED WAIT FOR OUTCOME20Page 20IBM DB2 AdministrationIBM Confident
22、ial 2009 IBM CorporationGlobal Technology ServicesGrowth ? Thrive for excellence ? Smarter solutionsCurrently Committed Isolation : How it WorksLMPActive Log FilesDEL: Emp,5,5456,Baum,D2/18 INS: Emp,1,4245,Chan,Y2/11,11Log ArchiveINS:Emp,1,6354,Smith,A1/21, 43INS:Emp,4,1325,Tata,X1/03,33Uncommitted
23、INSERTed data is skipped.For uncommitted DELETEs and UPDATEs, when encountering a lock which would otherwise conflict, DB2 uses new information in the lock manager to reconstruct and return the previously committed data from the log buffer or log file.21Page 21IBM DB2 AdministrationIBM Confidential
24、2009 IBM Corporationrowidempidnameofficesalary486354SmithA1/2143774245ChanY2/1111967836JonesAA/00 C3/46211041325TataX1/0333 2055456BaumD2/1822Log BufferUPD: Emp,3,7836,Chan,AA/00?C3/46ocklistrowidlog ref7796205-lock X(I)X(U)X(D)Global Technology ServicesGrowth ? Thrive for excellence ? Smarter solut
25、ionsCurrently Committed : Internals & Usage Notesn Log-based implementation : simple & fast No need for rollback segments! Currently committed data typically reconstructed from memory (log buffer) Exception: updates/deletes from mass update transactions that spill log buffer Active logs read from st
26、orage in this casen Fallback to traditional locking If the currently committed data is unavailable (or not available quickly), DB2 will fall back to the traditional locking behavior Examples Currently committed data is only available from an archived log (as may be the case with infinite logging) Updater held table lock (not row lock)22Page 22IB
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 加油站消防安全总结报告
- 钢管租赁合同3篇
- 小学三年级语文阅读教学方法3篇
- 大学生保险实习报告12篇
- 教学实训大楼学生公寓新建项目可行性研究报告写作模板-备案审批
- 财务总监述职报告6篇
- 黑龙江省哈尔滨市博文高级中学高三英语联考试卷含解析
- 有关致家长感谢信3篇
- 餐饮合伙合同范本3篇
- 述职报告模板6篇
- 紫阳县蒿坪镇双利石煤矿矿山地质环境保护与土地复垦方案
- 新外研版高二英语选择性必修三unit2 life behind the lens课件
- 两篇古典英文版成语故事守株待兔
- DB61T 1573-2022高速公路养护应急物资管理规范
- GB/T 3820-1997纺织品和纺织制品厚度的测定
- 绿色溶剂-离子液体
- 风险因素识别与评价表(幕墙工程危险源)
- 湖南师范大学现当代文学真题(2000-2022年)
- 丙方岗位实习法定监护人(或家长)知情同意书模板
- 中小学生班主任基本功大赛笔试试卷及参考答案
- 墙面皮革硬包施工工艺
评论
0/150
提交评论