Oracle Berkeley DB Getting Started with Transaction Processing for C

Total Page:16

File Type:pdf, Size:1020Kb

Oracle Berkeley DB Getting Started with Transaction Processing for C Oracle Berkeley DB Getting Started with Transaction Processing for C 12c Release 1 Library Version 12.1.6.2 Legal Notice This documentation is distributed under an open source license. You may review the terms of this license at: http:// www.oracle.com/technetwork/database/berkeleydb/downloads/oslicense-093458.html Oracle, Berkeley DB, and Sleepycat are trademarks or registered trademarks of Oracle. All rights to these marks are reserved. No third-party use is permitted without the express prior written consent of Oracle. Other names may be trademarks of their respective owners. To obtain a copy of this document's original source code, please submit a request to the Oracle Technology Network forum at: https://forums.oracle.com/forums/forum.jspa?forumID=271 Published 4/13/2017 Table of Contents Preface ....................................................................................................... v Conventions Used in this Book .................................................................... v For More Information ............................................................................... vi Contact Us ..................................................................................... vi 1. Introduction .............................................................................................. 1 Transaction Benefits ................................................................................. 1 A Note on System Failure .......................................................................... 2 Application Requirements .......................................................................... 2 Multi-threaded and Multi-process Applications ................................................. 4 Recoverability ........................................................................................ 4 Performance Tuning ................................................................................. 5 2. Enabling Transactions .................................................................................. 6 Environments ......................................................................................... 6 File Naming .................................................................................... 7 Specifying the Environment Home Directory ....................................... 7 Specifying File Locations .............................................................. 7 Identifying Specific File Locations ................................................... 8 Error Support ................................................................................. 10 Shared Memory Regions ..................................................................... 10 Regions Backed by Files .............................................................. 11 Regions Backed by Heap Memory ................................................... 11 Regions Backed by System Memory ................................................ 11 Security Considerations ..................................................................... 12 Opening a Transactional Environment and Database ........................................ 13 3. Transaction Basics ..................................................................................... 17 Committing a Transaction ......................................................................... 20 Non-Durable Transactions ......................................................................... 21 Aborting a Transaction ............................................................................ 22 Auto Commit ........................................................................................ 22 Nested Transactions ................................................................................ 25 Transactional Cursors .............................................................................. 26 Secondary Indices with Transaction Applications ............................................. 28 Configuring the Transaction Subsystem ......................................................... 29 4. Concurrency ............................................................................................ 32 Which DB Handles are Free-Threaded .......................................................... 33 Locks, Blocks, and Deadlocks .................................................................... 33 Locks ........................................................................................... 33 Lock Resources ........................................................................ 34 Types of Locks ......................................................................... 34 Lock Lifetime .......................................................................... 35 Blocks .......................................................................................... 35 Blocking and Application Performance ............................................ 36 Avoiding Blocks ........................................................................ 37 Deadlocks ..................................................................................... 38 Deadlock Avoidance ................................................................... 39 The Locking Subsystem ............................................................................ 39 4/13/2017 Using Transactions with DB Page iii Configuring the Locking Subsystem ....................................................... 40 Configuring Deadlock Detection ........................................................... 42 Resolving Deadlocks ......................................................................... 44 Setting Transaction Priorities .............................................................. 46 Isolation .............................................................................................. 47 Supported Degrees of Isolation ............................................................ 48 Reading Uncommitted Data ................................................................ 49 Committed Reads ............................................................................ 51 Using Snapshot Isolation .................................................................... 54 Snapshot Isolation Cost ............................................................... 54 Snapshot Isolation Transactional Requirements .................................. 54 When to Use Snapshot Isolation .................................................... 54 How to use Snapshot Isolation ...................................................... 55 Transactional Cursors and Concurrent Applications ........................................... 57 Using Cursors with Uncommitted Data ................................................... 57 Exclusive Database Handles ...................................................................... 59 Read/Modify/Write ................................................................................. 60 No Wait on Blocks .................................................................................. 61 Reverse BTree Splits ............................................................................... 61 5. Managing DB Files ..................................................................................... 64 Checkpoints ......................................................................................... 64 Backup Procedures ................................................................................. 67 About Unix Copy Utilities .................................................................. 67 Offline Backups .............................................................................. 68 Hot Backup ................................................................................... 68 Incremental Backups ........................................................................ 69 Recovery Procedures ............................................................................... 70 Normal Recovery ............................................................................. 70 Catastrophic Recovery ...................................................................... 72 Designing Your Application for Recovery ....................................................... 73 Recovery for Multi-Threaded Applications ............................................... 73 Recovery in Multi-Process Applications ................................................... 74 Effects of Multi-Process Recovery .................................................. 75 Process Registration ................................................................... 75 Failure Checking ....................................................................... 76 Using Hot Failovers ................................................................................ 77 Removing Log Files ................................................................................. 79 Configuring the Logging Subsystem ............................................................. 80 Setting the Log File Size ................................................................... 80 Configuring the Logging Region Size ...................................................... 81 Configuring In-Memory Logging ............................................................ 81 Setting the In-Memory Log Buffer Size ................................................... 84 6. Summary and Examples .............................................................................. 85 Anatomy of a Transactional Application
Recommended publications
  • A Fast Implementation of Parallel Snapshot Isolation
    A FAST IMPLEMENTATION OF PARALLEL SNAPSHOT ISOLATION UNA IMPLEMENTACIÓN RÁPIDA DE PARALLEL SNAPSHOT ISOLATION Borja Arnau de Régil Basáñez Trabajo de Fin de Grado del Grado en Ingeniería Informática Facultad de Informática, Universidad Complutense de Madrid Junio 2020 Director: Maria Victoria López López Co-director: Alexey Gotsman Contents Acknowledgements iv Abstract v Resumen vi 1. Introduction1 1.1. Motivation . .1 1.2. Goals . .2 1.3. Work Plan . .3 1.4. Document Structure . .3 1.5. Sources and Repositories . .4 1.6. Related Program Courses . .4 2. Preliminaries5 2.1. Notation . .5 2.1.1. Objects and Replication . .5 2.1.2. Transactions . .5 2.1.3. Histories . .6 2.2. Consistency Models . .6 2.2.1. Read Committed (RC) . .7 2.2.2. Serialisability (SER) . .8 2.2.3. Snapshot Isolation (SI) . .9 2.2.4. Parallel Snapshot Isolation (PSI) . 10 2.2.5. Non-Monotonic Snapshot Isolation (NMSI) . 11 2.2.6. Anomaly Comparison . 11 3. The fastPSI protocol 12 3.1. Consistency Guarantees . 12 3.2. Overview and System Model . 13 3.3. Server data structures . 14 3.4. Protocol Description . 16 3.4.1. Transaction Execution . 16 3.4.2. Transaction Termination . 20 3.5. Consistency Tradeoffs and Read Aborts . 23 ii 4. Implementation and Evaluation 26 4.1. Implementation . 26 4.2. Evaluation . 27 4.2.1. Performance & Scalability Limits . 28 4.2.2. Abort Ratio . 31 5. Related Work 35 6. Conclusions and Future Work 37 6.1. Conclusions . 37 6.2. Future Work . 37 A. Serialisable and Read Committed Protocols 39 A.1.
    [Show full text]
  • One-Copy Serializability with Snapshot Isolation Under the Hood
    One-Copy Serializability with Snapshot Isolation under the Hood Mihaela A. Bornea 1, Orion Hodson 2, Sameh Elnikety 2, Alan Fekete 3 1Athens U. of Econ and Business, 2Microsoft Research, 3University of Sydney Abstract—This paper presents a method that allows a repli- With careful design and engineering, SI engines can be cated database system to provide a global isolation level stronger replicated to get even higher performance with a replicated than the isolation level provided on each individual database form of SI such as Generalized Snapshot Isolation (GSI) [13], replica. We propose a new multi-version concurrency control al- gorithm called, serializable generalized snapshot isolation (SGSI), which is also not serializable. The objective of this paper is that targets middleware replicated database systems. Each replica to provide a concurrency control algorithm for replicated SI runs snapshot isolation locally and the replication middleware databases that achieves almost the same performance as GSI guarantees global one-copy serializability. We introduce novel while providing global one-copy-serializability (1SR). techniques to provide a stronger global isolation level, namely To guarantee serializability, concurrency control algorithms readset extraction and enhanced certification that prevents read- write and write-write conflicts in a replicated setting. We prove typically require access to data read and written in update the correctness of the proposed algorithm, and build a proto- transactions. Accessing this data is especially difficult in a type replicated database system to evaluate SGSI performance replicated database system since built-in facilities inside a experimentally. Extensive experiments with an 8 replica database centralized DBMS, like the lock manager, are not available system under the TPC-W workload mixes demonstrate the at a global level.
    [Show full text]
  • Making Snapshot Isolation Serializable
    Making Snapshot Isolation Serializable ALAN FEKETE University of Sydney DIMITRIOS LIAROKAPIS, ELIZABETH O’NEIL, and PATRICK O’NEIL University of Massachusetts and DENNIS SHASHA Courant Institute Snapshot Isolation (SI) is a multiversion concurrency control algorithm, first described in Berenson et al. [1995]. SI is attractive because it provides an isolation level that avoids many of the com- mon concurrency anomalies, and has been implemented by Oracle and Microsoft SQL Server (with certain minor variations). SI does not guarantee serializability in all cases, but the TPC-C benchmark application [TPC-C], for example, executes under SI without serialization anoma- lies. All major database system products are delivered with default nonserializable isolation levels, often ones that encounter serialization anomalies more commonly than SI, and we sus- pect that numerous isolation errors occur each day at many large sites because of this, lead- ing to corrupt data sometimes noted in data warehouse applications. The classical justification for lower isolation levels is that applications can be run under such levels to improve efficiency when they can be shown not to result in serious errors, but little or no guidance has been of- fered to application programmers and DBAs by vendors as to how to avoid such errors. This article develops a theory that characterizes when nonserializable executions of applications can occur under SI. Near the end of the article, we apply this theory to demonstrate that the TPC-C benchmark application has no serialization anomalies under SI, and then discuss how this demon- stration can be generalized to other applications. We also present a discussion on how to modify the program logic of applications that are nonserializable under SI so that serializability will be guaranteed.
    [Show full text]
  • Firebird 3.0 Developer's Guide
    Firebird 3.0 Developer’s Guide Denis Simonov Version 1.1, 27 June 2020 Preface Author of the written material and creator of the sample project on five development platforms, originally as a series of magazine articles: Denis Simonov Translation of original Russian text to English: Dmitry Borodin (MegaTranslations Ltd) Editor of the translated text: Helen Borrie Copyright © 2017-2020 Firebird Project and all contributing authors, under the Public Documentation License Version 1.0. Please refer to the License Notice in the Appendix This volume consists of chapters that walk through the development of a simple application for several language platforms, notably Delphi, Microsoft Entity Framework and MVC.NET (“Model-View-Controller”) for web applications, PHP and Java with the Spring framework. It is hoped that the work will grow in time, with contributions from authors using other stacks with Firebird. 1 Table of Contents Table of Contents 1. About the Firebird Developer’s Guide: for Firebird 3.0 . 6 1.1. About the Author . 6 1.1.1. Translation… . 6 1.1.2. … and More Translation . 6 1.2. Acknowledgments . 6 2. The examples.fdb Database . 8 2.1. Database Creation Script. 8 2.1.1. Database Aliases . 9 2.2. Creating the Database Objects. 10 2.2.1. Domains . 10 2.2.2. Primary Tables. 11 2.2.3. Secondary Tables . 13 2.2.4. Stored Procedures. 17 2.2.5. Roles and Privileges for Users . 25 2.3. Saving and Running the Script . 26 2.4. Loading Test Data . 27 3. Developing Firebird Applications in Delphi . 28 3.1.
    [Show full text]
  • Oracle Berkeley DB Installation and Build Guide Release 18.1
    Oracle Berkeley DB Installation and Build Guide Release 18.1 Library Version 18.1.32 Legal Notice Copyright © 2002 - 2019 Oracle and/or its affiliates. All rights reserved. This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited. The information contained herein is subject to change without notice and is not warranted to be error-free. If you find any errors, please report them to us in writing. Berkeley DB, and Sleepycat are trademarks or registered trademarks of Oracle. All rights to these marks are reserved. No third- party use is permitted without the express prior written consent of Oracle. Other names may be trademarks of their respective owners. If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it on behalf of the U.S. Government, the following notice is applicable: U.S. GOVERNMENT END USERS: Oracle programs, including any operating system, integrated software, any programs installed on the hardware, and/or documentation, delivered to U.S. Government end users are "commercial computer software" pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As such, use, duplication, disclosure, modification, and adaptation of the programs, including any operating system, integrated software, any programs installed on the hardware, and/or documentation, shall be subject to license terms and license restrictions applicable to the programs.
    [Show full text]
  • Ensuring Consistency Under the Snapshot Isolation
    World Academy of Science, Engineering and Technology International Journal of Computer and Information Engineering Vol:8, No:7, 2014 Ensuring Consistency under the Snapshot Isolation Carlos Roberto Valencio,ˆ Fabio´ Renato de Almeida, Thatiane Kawabata, Leandro Alves Neves, Julio Cesar Momente, Mario Luiz Tronco, Angelo Cesar Colombini Abstract—By running transactions under the SNAPSHOT isolation both transactions write the same data item, giving rise to we can achieve a good level of concurrency, specially in databases a write-write conflict. In turn, a temporal overlap occurs with high-intensive read workloads. However, SNAPSHOT is not < when Ti and Tj run concurrently, that is tsi tcj and immune to all the problems that arise from competing transactions < and therefore no serialization warranty exists. We propose in this tsj tci [2]. Thus, a transaction Ti under the SNAPSHOT paper a technique to obtain data consistency with SNAPSHOT by using isolation is allowed to commit only if no other transaction with δ <δ< some special triggers that we named DAEMON TRIGGERS. Besides commit-timestamp in the running time of Ti (tsi tci ) keeping the benefits of the SNAPSHOT isolation, the technique is wrote a data item also written by Ti [4]. specially useful for those database systems that do not have an Implementations of the SNAPSHOT isolation have the isolation level that ensures serializability, like Firebird and Oracle. We describe all the anomalies that might arise when using the SNAPSHOT advantage that writes of a transaction do not block the isolation and show how to preclude them with DAEMON TRIGGERS. reads of others.
    [Show full text]
  • Oracle Solaris 10 910 Release Notes
    Oracle® Solaris 10 9/10 Release Notes Part No: 821–1839–11 September 2010 Copyright © 2010, Oracle and/or its affiliates. All rights reserved. This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited. The information contained herein is subject to change without notice and is not warranted to be error-free. If you find any errors, please report them to us in writing. If this is software or related software documentation that is delivered to the U.S. Government or anyone licensing it on behalf of the U.S. Government, the following notice is applicable: U.S. GOVERNMENT RIGHTS Programs, software, databases, and related documentation and technical data delivered to U.S. Government customers are “commercial computer software” or “commercial technical data” pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As such, the use, duplication, disclosure, modification, and adaptation shall be subject to the restrictions and license terms setforth in the applicable Government contract, and, to the extent applicable by the terms of the Government contract, the additional rights set forth in FAR 52.227-19, Commercial Computer Software License (December 2007). Oracle America, Inc., 500 Oracle Parkway, Redwood City, CA 94065.
    [Show full text]
  • Oracle Technology Global Price List September 7, 2021
    Prices in USA (Dollar) Oracle Technology Global Price List September 7, 2021 This document is the property of Oracle Corporation. Any reproduction of this document in part or in whole is strictly prohibited. For educational purposes only. Subject to change without notice. 1 of 16 Section I Prices in USA (Dollar) Oracle Database Software Update Processor Software Update Named User Plus License & Support License License & Support Database Products Oracle Database Standard Edition 2 350 77.00 17,500 3,850.00 Enterprise Edition 950 209.00 47,500 10,450.00 Personal Edition 460 101.20 - - Mobile Server - - 23,000 5,060.00 NoSQL Database Enterprise Edition 200 44 10,000 2,200.00 Enterprise Edition Options: Multitenant 350 77.00 17,500 3,850.00 Real Application Clusters 460 101.20 23,000 5,060.00 Real Application Clusters One Node 200 44.00 10,000 2,200.00 Active Data Guard 230 50.60 11,500 2,530.00 Partitioning 230 50.60 11,500 2,530.00 Real Application Testing 230 50.60 11,500 2,530.00 Advanced Compression 230 50.60 11,500 2,530.00 Advanced Security 300 66.00 15,000 3,300.00 Label Security 230 50.60 11,500 2,530.00 Database Vault 230 50.60 11,500 2,530.00 OLAP 460 101.20 23,000 5,060.00 TimesTen Application-Tier Database Cache 460 101.20 23,000 5,060.00 Database In-Memory 460 101.20 23,000 5,060.00 Database Enterprise Management Diagnostics Pack 150 33.00 7,500 1,650.00 Tuning Pack 100 22.00 5,000 1,100.00 Database Lifecycle Management Pack 240 52.80 12,000 2,640.00 Data Masking and Subsetting Pack 230 50.60 11,500 2,530.00 Cloud Management
    [Show full text]
  • Developing and Deploying High Performance PHP Applications
    Developing and Deploying High Performance PHP Applications http://joind.in/3396 php|tek 2011 http://blogs.oracle.com/opal Christopher Jones [email protected] Oracle Development http://twitter.com/ghrd 1 This Talk - What to Expect • “State of the Nation” overview of PHP & Oracle Technology • (Some) Best Practices with Oracle Database – With live demos 2 The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. 3 About Me • Work in Oracle's Linux & Virtualization Group • Focus on scripting languages – mostly PHP – Have PHP code check-in privileges • Also work on Oracle features that help scripting languages 4 <Insert Picture Here> In The News 5 In the News: NetBeans IDE • Free – GPL / CDDL • NetBeans is very popular for PHP – Strong, passionate community of users • Zend Framework, Symfony, XDebug, PHPUnit, PhpDoc • New! NetBeans 7.0 just released – Generate PhpDoc – Rename refactoring, Safe delete refactoring – Support for PHP 5.3 namespace aliases • See http://netbeans.org/features/php 6 In the News: Oracle Database • Beta Oracle 11.2 “XE” is available – Free – Windows 32 & 64, Linux 64 – Subset of Enterprise Edition features – Same code base as EE – XE
    [Show full text]
  • Data Sheet: Berkeley Database Products
    ORACLE DATA SHEET Oracle Berkeley Database Products The Oracle Berkeley DB product family consists of Berkeley DB, Berkeley DB Java Edition and Berkeley DB XML. All three are high performance, self- contained, software libraries which provide data storage services for applications, devices, and appliances. They deliver superior performance, scalability and availability for applications that must run unattended without administration. Overview The Oracle Berkeley DB family of high performance, self-contained databases provides CONSIDER BERKELEY DB WHEN: developers with a fast, transactional database solution with a track record of reliability, • You need an SQLite API compatible unmatched scalability and five-nines (99.999%) or better availability. Oracle Berkeley database within mobile, handheld or DB is well suited to Independent Software Vendors, device and equipment other hardware devices. manufacturers, and enterprises or software companies building solutions which need a • Performance, scalability, concurrency data management component. The Oracle Berkeley DB family of products provides fast, is important. local persistence with zero oversight administration. • Zero oversight administration in deployment is required Customers and end-users will experience an application that simply works, reliably • Flexibility to choose SQL, XQuery, manages data, scales under extreme load, and requires zero oversight in deployment. Java Object, or Key/Value data Your development team can focus on your application and be confident that Berkeley management. DB will manage your application’s data. • Mobile data synchronization with Oracle Database is a requirement. Storage Engine Design • Failure from recovery must be automatic and reliable The Berkeley DB products are self-contained software components which support your • High availability and fault tolerance are application.
    [Show full text]
  • Getting Started with Berkeley DB Java Edition
    Oracle Berkeley DB, Java Edition Getting Started with Berkeley DB Java Edition 12c Release 2 Library Version 12.2.7.5 Legal Notice Copyright © 2002 - 2017 Oracle and/or its affiliates. All rights reserved. This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited. The information contained herein is subject to change without notice and is not warranted to be error-free. If you find any errors, please report them to us in writing. Berkeley DB, Berkeley DB Java Edition and Sleepycat are trademarks or registered trademarks of Oracle. All rights to these marks are reserved. No third-party use is permitted without the express prior written consent of Oracle. Other names may be trademarks of their respective owners. If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it on behalf of the U.S. Government, the following notice is applicable: U.S. GOVERNMENT END USERS: Oracle programs, including any operating system, integrated software, any programs installed on the hardware, and/or documentation, delivered to U.S. Government end users are "commercial computer software" pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations.
    [Show full text]
  • Forcepoint DLP Supported File Formats and Size Limits
    Forcepoint DLP Supported File Formats and Size Limits Supported File Formats and Size Limits | Forcepoint DLP | v8.8.1 This article provides a list of the file formats that can be analyzed by Forcepoint DLP, file formats from which content and meta data can be extracted, and the file size limits for network, endpoint, and discovery functions. See: ● Supported File Formats ● File Size Limits © 2021 Forcepoint LLC Supported File Formats Supported File Formats and Size Limits | Forcepoint DLP | v8.8.1 The following tables lists the file formats supported by Forcepoint DLP. File formats are in alphabetical order by format group. ● Archive For mats, page 3 ● Backup Formats, page 7 ● Business Intelligence (BI) and Analysis Formats, page 8 ● Computer-Aided Design Formats, page 9 ● Cryptography Formats, page 12 ● Database Formats, page 14 ● Desktop publishing formats, page 16 ● eBook/Audio book formats, page 17 ● Executable formats, page 18 ● Font formats, page 20 ● Graphics formats - general, page 21 ● Graphics formats - vector graphics, page 26 ● Library formats, page 29 ● Log formats, page 30 ● Mail formats, page 31 ● Multimedia formats, page 32 ● Object formats, page 37 ● Presentation formats, page 38 ● Project management formats, page 40 ● Spreadsheet formats, page 41 ● Text and markup formats, page 43 ● Word processing formats, page 45 ● Miscellaneous formats, page 53 Supported file formats are added and updated frequently. Key to support tables Symbol Description Y The format is supported N The format is not supported P Partial metadata
    [Show full text]