computer-nec-license
  • NEC-Computer
  • 1. Concept of Basic Electrical and Electronics Engineering
    • 1.1 Basic Concepts
    • 1.2 Network Theorems
    • 1.3 Alternating Current Fundamentals
    • 1.4 Semiconductor Device
    • 1.5 Signal Generator
    • 1.6 Amplifiers
    • MCQs
      • MCQs On Basic Electrical
        • set-1
        • set-2
      • MCQs On Basic Electronics
        • set-1
        • set-2
  • 2. Digital Logic and Microprocessor
    • 2.1 Digital Logic
    • 2.2 Combinational & Arithmetic Circuit
    • 2.3 Sequential Logic Circuits
    • 2.4 Microprocessor
    • 2.5 Microprocessor System
    • 2.6 Interrupt Operations
    • MCQs
      • MCQs On Digital Logic
        • set-1
        • set-2
        • set-3
        • set-4
        • set-5
        • set-6
        • set-7
        • set-8
        • set-9
        • set-10
        • set-11
        • set-12
      • MCQs On Microprocessor
        • set-1
        • set-2
        • set-3
        • set-4
        • set-5
        • set-6
        • set-7
        • set-8
        • set-9
  • 3. Programming Language and Its Applications
    • 3.1 Introduction to C Programming
    • 3.2 Pointers, Structures, and Data Files
    • 3.3 C++ Language Constructs with Objects and Classes
    • 3.4 Features of Object-Oriented Programming
    • 3.5 Pure Virtual Functions and File Handling
    • 3.6 Generic Programming and Exception Handling
    • MCQs
      • set-1
      • set-2
      • set-3
      • set-4
      • set-5
  • 4. Computer Organization and Embedded System
    • 4.1 Control and CPU
    • 4.2 Computer Arithmetic and Memory System
    • 4.3 I/O Organization and Multiprocessor
    • 4.4 Embedded System Design
    • 4.5 Real-Time Operating and Control Systems
    • 4.6 Hardware Description Language (VHDL) and IC Technology
    • MCQs
      • set-1
      • set-2
      • set-3
      • set-4
      • set-5
      • set-6
      • set-7
      • set-8
      • set-9
      • set-10
      • set-11
  • 5. Concept of Computer Network and Network Security System
    • 5.1 Introduction to Computer Networks
    • 5.2 Data Link Layer
    • 5.3 Network Layer
    • 5.4 Transport Layer
    • 5.5 Application Layer
    • 5.6 Network Security
    • MCQs
      • Basic Networking
        • set-1
        • set-2
      • Advanced Networking
        • set-1
        • set-2
        • set-3
        • set-4
        • set-5
        • set-6
  • 6. Theory of Computation and Computer Graphics
    • 6.1 Introduction to Finite Automata
    • 6.2 Introduction to Context-Free Languages (CFL)
    • 6.3 Turing Machines (TM)
    • 6.4 Introduction to Computer Graphics
    • 6.5 Two-Dimensional Transformation
    • 6.6 Three-Dimensional Transformation
    • MCQs
      • MCQs on Theory of Computation
        • set-1
        • set-2
        • set-3
      • MCQs On Computer Graphics
        • set-1
        • set-2
        • set-3
        • set-4
        • set-5
        • set-6
  • 7. Data Structures and Algorithm, Database System and Operating System
    • 7.1 Introduction to Data Structures, Lists, Linked Lists, and Trees
    • 7.2 Sorting, Searching, Hashing and Graphs
    • 7.3 Introduction to Data Models, Normalization, and SQL
    • 7.4 Transaction Processing, Concurrency Control, and Crash Recovery
    • 7.5 Introduction to Operating System and Process Management
    • 7.6 Memory Management, File Systems, and System Administration
    • MCQs
      • MCQs ON DSA
        • set-1
        • set-2
        • set-3
        • set-4
        • set-5
        • set-6
      • MCQs On DBMS
        • set-1
        • set-2
      • MCQs On Operating System
        • set-1
        • set-2
        • set-3
        • set-4
        • set-5
        • set-6
        • set-7
        • set-8
        • set-9
        • set-10
        • set-11
        • set-12
  • 8. Software Engineering and Object-Oriented Analysis & Design
    • 8.1 Software Process and Requirements
    • 8.2 Software Design
    • 8.3 Software Testing, Cost Estimation, Quality Management, and Configuration Management
    • 8.4 Object-Oriented Fundamentals and Analysis
    • 8.5 Object-Oriented Design
    • 8.6 Object-Oriented Design Implementation
    • MCQs
      • set-1
      • set-2
      • set-3
      • set-4
      • set-5
      • set-6
      • set-7
      • set-8
      • set-9
  • 9. Artificial Intelligence and Neural Networks
    • 9.1 Introduction to AI and Intelligent Agents
    • 9.2 Problem Solving and Searching Techniques
    • 9.3 Knowledge Representation
    • 9.4 Expert System and Natural Language Processing
    • 9.5 Machine Learning
    • 9.6 Neural Networks
    • MCQs
      • set-1
      • set-2
      • set-3
      • set-4
      • set-5
      • set-6
      • set-7
      • set-8
      • set-9
  • 10. Project Planning, Design and Implementation
    • 10.1 Engineering Drawings and Its Concepts
    • 10.2 Engineering Economics
    • 10.3 Project Planning and Scheduling
    • 10.4 Project Management
    • 10.5 Engineering Professional Practice
    • 10.6 Engineering Regulatory Body
    • MCQs
      • MCQs On Engineering Drawing
        • set-1
        • set-2
      • MCQs On Engineering Economics
      • MCQs On Project Planning & Scheduling
      • MCQs On Project Mangement
      • MCQs On Engineering Professional Practice
      • MCQs On Engineering Regulatory Body
  • Questions Sets
    • Set 1 (Chaitra, 2080)
      • Short Questions (60*1=60 Marks)
      • Long Questions (20*2=40 Marks)
    • Set 2 (Aasadh, 2081)
      • Short Questions (60*1=60 Marks)
      • Long Questions (20*2=40 Marks)
    • Set 3 (Asojh, 2080)
      • Short Questions (60*1=60 Marks)
      • Long Questions (20*2=40 Marks)
    • Model Set - Computer Engineering By NEC
      • Short Questions (60*1=60 Marks)
      • Long Questions (20*2=40 Marks)
    • Model Set - Software Engineering By NEC
      • Short Questions (60*1=60 Marks)
      • Long Questions (20*2=40 Marks)
  • Tips & Tricks
Powered by GitBook
On this page
  • 1. ACID Properties
  • 2. Concurrent Executions
  • 3. Serializability Concept
  • 4. Lock-based Protocols
  • 5. Failure Classification
  • 6. Recovery and Atomicity
  • 7. Log-based Recovery
  • Conclusion
  1. 7. Data Structures and Algorithm, Database System and Operating System

7.4 Transaction Processing, Concurrency Control, and Crash Recovery

Transaction processing, concurrency control, and crash recovery are essential components of database management systems that ensure data consistency, integrity, and durability even in the face of system failures or concurrent operations.


1. ACID Properties

ACID is an acronym that describes the four key properties of a transaction to ensure database reliability and correctness.

  • Atomicity: A transaction is treated as a single unit, which means that either all of its operations are executed, or none of them are. If any part of the transaction fails, the entire transaction is rolled back.

  • Consistency: A transaction takes the database from one consistent state to another. It ensures that any data modifications made by the transaction maintain the integrity constraints of the database.

  • Isolation: Transactions execute independently of one another. Even though transactions may run concurrently, the effect of one transaction is not visible to others until it is fully completed.

  • Durability: Once a transaction is committed, its changes are permanent and survive any subsequent system failures. This ensures that the data is not lost.


2. Concurrent Executions

  • Concurrent Executions: Refers to multiple transactions being executed simultaneously in a database system. Concurrency is essential for improving system throughput, but it introduces challenges such as maintaining consistency and isolation.

    • Challenges:

      • Lost Updates: One transaction's update is overwritten by another.

      • Temporary Inconsistency: Transactions access the database in an inconsistent state.

      • Uncommitted Data: One transaction reads data that has not yet been committed by another transaction.

      • Inconsistent Retrievals: Transactions retrieve data that may be changed by another transaction during its execution.


3. Serializability Concept

  • Serializability: The highest level of isolation, which ensures that the results of concurrent transactions are equivalent to the result of some serial execution of those transactions.

    • Types of Serializability:

      • Conflict Serializability: Transactions are conflict-serializable if their execution order can be rearranged to produce the same result as a serial execution.

      • View Serializability: Transactions are view-serializable if the transactions can be reordered in such a way that each transaction's view of the data is the same as in a serial execution.

    • Goal: To ensure that concurrent execution of transactions preserves the consistency and correctness of the database.


4. Lock-based Protocols

  • Locking: A mechanism used to control concurrent access to data by ensuring that only one transaction can access a particular piece of data at a time.

    • Types of Locks:

      • Shared Lock (S-lock): Allows multiple transactions to read the data but prevents any from writing.

      • Exclusive Lock (X-lock): Allows a transaction to both read and write the data and prevents any other transaction from accessing it.

  • Lock-based Protocols: Ensure serializability by requiring transactions to acquire locks before accessing data and releasing them after the transaction is completed.

    • Two-Phase Locking (2PL): A protocol where transactions must obtain all the locks, they need before releasing any locks. It has two phases:

      1. Growing Phase: Locks are acquired, and no locks are released.

      2. Shrinking Phase: Locks are released, and no new locks are acquired.

  • Deadlock: It is not a protocol but a problem that can occur when using lock-based protocols like 2PL. A deadlock in a database occurs when two or more transactions are waiting for each other to release locks on resources, creating a cycle of dependency that prevents any of them from proceeding.

    Below are the four conditions necessary for a deadlock to occur (commonly known as the Coffman Conditions):

    • Mutual Exclusion

      • At least one resource must be in a non-sharable mode, meaning only one transaction can hold a lock on the resource at any given time.

      • Example: Transaction A locks a row exclusively for writing, so no other transaction can access it.

    • Hold and Wait

      • A transaction holding at least one resource is waiting to acquire additional resources held by other transactions.

      • Example: Transaction A holds Lock 1 and requests Lock 2, while Transaction B holds Lock 2 and requests Lock 1.

    • No Preemption

      • Resources cannot be forcibly taken away from a transaction; they must be released voluntarily.

      • Example: If Transaction A holds Lock 1, the system cannot force Transaction A to release Lock 1. It must wait until Transaction A finishes its task.

    • Circular Wait

      • A circular chain of transactions exists, where each transaction is waiting for a resource held by the next transaction in the chain.

      • Example:

        • Transaction A → waiting for a resource held by Transaction B.

        • Transaction B → waiting for a resource held by Transaction C.

        • Transaction C → waiting for a resource held by Transaction A.

  • Example of Deadlock in a Database:

    Consider the following scenario:

    • Transaction A locks Row X and requests a lock on Row Y.

    • Transaction B locks Row Y and requests a lock on Row X. Both transactions are now waiting for each other to release their locks, leading to a deadlock.

  • Deadlock Detection and Resolution:

    • Detection:

      Database systems periodically check for deadlocks using wait-for graphs. If a cycle is detected, it indicates a deadlock.

    • Resolution:

      • Transaction Rollback: Terminate one of the transactions to break the cycle.

      • Timeouts: Automatically abort transactions that have been waiting too long.

    • Deadlock Prevention Techniques:

      • Avoid Circular Wait: Impose an ordering on resource acquisition.

      • No Hold and Wait: Ensure transactions request all needed resources at once.

      • Allow Preemption: Forcefully release locks from lower-priority transactions.


5. Failure Classification

Failures can occur in a database system, affecting the transactions and the database’s consistency. These failures are typically classified into:

  • Transaction Failures: Failures that occur within a transaction, such as logic errors, constraints violations, or deadlocks.

  • System Failures: Failures in the database management system (DBMS) or hardware that affect multiple transactions, such as power outages, memory corruption, or disk crashes.

  • Media Failures: Failures related to the storage medium, like disk crashes or corrupt data files.


6. Recovery and Atomicity

  • Recovery: The process of restoring the database to a consistent state after a failure. It ensures that all committed transactions are durable and that uncommitted transactions are rolled back.

  • Atomicity in Recovery: During recovery, the atomicity property ensures that if a transaction is incomplete (due to a crash), it is rolled back to avoid partial updates. This prevents the database from being left in an inconsistent state.


7. Log-based Recovery

  • Log-based Recovery: A method for recovering a database by maintaining a transaction log, which records all changes made to the database. Logs contain:

    • Before Image: The value of a data item before it was modified.

    • After Image: The new value of the data item after modification.

    • Log Records: Each log record includes:

      • The transaction identifier (TID).

      • The operation (e.g., read, write).

      • The data item affected.

      • The before and after values.

  • Recovery Process:

    • Undo: For uncommitted transactions at the time of failure, undo the operations by using the before image.

    • Redo: For committed transactions, redo the operations using the after image to ensure that the changes are applied.

    • Write-Ahead Log (WAL): Ensures that log entries are written to disk before any changes are made to the actual database, ensuring the durability of transactions.


Conclusion

  • Transaction processing, concurrency control, and crash recovery are crucial for maintaining the integrity, consistency, and durability of a database.

  • The ACID properties provide the foundation for reliable database operations, while mechanisms like lock-based protocols and log-based recovery ensure that transactions are executed properly even in the case of failures.

  • By ensuring correct and consistent transaction processing, databases can handle concurrent operations efficiently and recover from system failures without losing data.

Previous7.3 Introduction to Data Models, Normalization, and SQLNext7.5 Introduction to Operating System and Process Management

Last updated 4 months ago