States of Transactions
·
Active − in this state, the transaction is being executed. This is the initial state of every transaction.
Active − in this state, the transaction is being executed. This is the initial state of every transaction.
·
Partially
Committed − When a transaction executes
its final operation, it is said to be in a partially committed state.
·
Failed − A transaction is said to be in a failed
state if any of the checks made by the database recovery system fails. A failed
transaction can no longer proceed further.
·
Aborted − If any of the checks fails and the
transaction has reached a failed state, then the recovery manager rolls back all
its write operations on the database to bring the database back to its original
state where it was prior to the execution of the transaction.
·
Committed − If a transaction executes all its
operations successfully, it is said to be committed. All its effects are now
permanently established on the database system.
Issues and solutions of Database Transactions
Concurrency control
Concurrency Control Protocols are
mechanisms to control concurrency of transactions to ensure isolation of
transactions. Concurrency control is a database management systems (DBMS)
concept that is used to address conflicts with the simultaneous accessing or
altering of data that can occur with a multi-user system. Concurrency control,
when applied to a DBMS, is meant to coordinate simultaneous transactions while
preserving data integrity. The Concurrency is about to control the multi-user
access of Database.
Example:
Concurrency control
- When teller
#1 starts working on an account, a lock is placed on the account.
- When
teller #2 tries to read or update an account while teller #1 is updating
an account, teller #2 will not be given access and gets an error message.
- After
teller #1 has finished the update, teller #2 can proceed.
- At the end
of the day, your account has Rs.1,100 (Rs.1000 - 200 + 300).
Lock based
A lock is nothing but
a mechanism that tells the DBMS whether a particular data item is being used by
any transaction for read/write purpose. Since there are two types of
operations, i.e. read and write, whose basic nature are different, the locks
for read and write operation may behave differently. Locking is necessary in a concurrent
environment to assure that one process does not retrieve or update a record
that is being updated by another process. Failure to use some controls
(locking), would result in inconsistent and corrupt data.
Read operation performed by different transactions on
the same data item poses less of a challenge.
The value of the data item, if constant, can be read by any number of transactions at any given time.
The value of the data item, if constant, can be read by any number of transactions at any given time.
Write operation is something different. When a
transaction writes some value into a data item, the content of that data item
remains in an inconsistent state, starting from the moment when the writing
operation begins up to the moment the writing operation is over.
Sample Transactions with Locks
Locking is
the most common type of concurrency control mechanism. In this approach, any
data is retrieved by an active user for updating, must be locked or denied to
other users until updating is not complete. Some locking types are:
1. Binary
Lock
2. Shared/ exclusive (Read/Write) Lock
3. Certify Lock
Shared/ exclusive (Read/Write) Lock
Read-lock (shared lock):
Is associated
with a database object by a transaction before reading (retrieving the state
of) this object. A transaction may acquire shared lock on a data item in order
to read its content. The lock is shared in the sense that any other transaction
can acquire the shared lock on that same data item for reading purpose. Shared locks exist when two transactions are granted
read access.
One
transaction gets the shared lock on data and when the second transaction
requests the same data it is also given a shared lock. Both transactions are in
a read-only mode, updating the data is not allowed until the shared lock is
released. There is no conflict with the shared lock because nothing is being
updated. Shared locks last as long as they need to last; it depends on the
level of the transaction that holds the lock. Shared locks gives data access
more efficiency, and increases the lock managers overhead.
Write-lock (exclusive lock):
Is associated with a database object by a transaction
(Terminology: "the transaction locks the object," or "acquires
lock for it") before writing (inserting/modifying/deleting) this object.
A transaction may acquire exclusive lock on a data item in order to both
read/write into it. The lock is excusive in the sense that no other transaction
can acquire any kind of lock (either shared or exclusive) on that same data
item.
When we use the shared/exclusive locking scheme, the system must enforce
the following rules:
1. A transaction T
must issue the operation read_lock(X) or write_lock(X) before any
read_item(X) operation is performed in T.
2. A transaction T
must issue the operation write_lock(X) before any write_item(X)
operation is performed in T.
3. A transaction T
must issue the operation unlock(X) after all read_item(X) and
write_item(X) operations are completed in T.
4. A transaction T
will not issue a read_lock(X) operation if it already holds a read
(shared) lock or a write (exclusive) lock on item X. This rule may be relaxed.
5. A transaction T
will not issue a write_lock(X) operation if it already holds a read
(shared) lock or write (exclusive) lock on item X. This rule may be relaxed.
6. A
transaction T will not issue an unlock(X) operation unless it already
holds a read (shared) lock or a write (exclusive) lock on item X.
The
relationship between Shared and Exclusive Lock can be represented by the following
table which is known as Lock Matrix.
Locks already existing
Locks already existing
Shared
|
Exclusive
|
|
Shared
|
TRUE
|
FALSE
|
Exclusive
|
FALSE
|
FALSE
|
The common
interactions between these lock types are defined by blocking behavior as
follows:
·
An existing write-lock on a database object blocks an intended write
upon the same object (already requested/issued) by another transaction by
blocking a respective write-lock from being acquired by the other
transaction. The second write-lock will be acquired and the requested write of
the object will take place (materialize) after the existing write-lock is
released.
·
A write-lock blocks an intended (already requested/issued) read
by another transaction by blocking the respective read-lock.
·
A read-lock blocks an intended write by another transaction by
blocking the respective write-lock.
·
A read-lock does not block an intended read by another
transaction. The respective read-lock for the intended read is acquired
(shared with the previous read) immediately after the intended read is
requested, and then the intended read itself takes place.
Two phase locking
Growing Phase:
In this
phase the transaction can only acquire locks, but cannot release any lock. The
transaction enters the growing phase as soon as it acquires the first lock it
wants. From now on it has no option but to keep acquiring all the locks it
would need. It cannot release any lock at this phase even if it has finished
working with a locked data item. Ultimately the transaction reaches a point
where all the lock it may need has been acquired. This point is called Lock Point.
·
Can only lock items during this Phase.
·
May also upgrade
·
May also Read & Write once items are locked
·
no unlocking in this phase
·
If Transaction is successful, it gets all its
locks.
Shrinking Phase:
After Lock
Point has been reached, the transaction enters the shrinking phase. In this
phase the transaction can only release locks, but cannot acquire any new lock.
The transaction enters the shrinking phase as soon as it releases the first
lock after crossing the Lock Point. From now on it has no option but to keep
releasing all the acquired locks.
·
Can only unlock items during this Phase.
·
May still Read & Write items which are still
locked.
·
Phase begins with first unlock
·
no lock after first unlock
Database deadlock
A deadlock is a situation that occurs when two or more
different database sessions have some data locked, and each database session
requests a lock on the data that another, different, session has already
locked. Because the sessions are waiting for each other, nothing can get done,
and the sessions just waste time instead. A deadlock
is a condition wherein two or more tasks are waiting for each other in order to
be finished but none of the task is willing to give up the resources that other
task needs. In this situation no task ever gets finished and is in waiting
state forever.
For example,
assume a set of transactions {T0, T1, T2,
...,Tn}. T0 needs a resource X to complete its task.
Resource X is held by T1, and T1 is waiting for a
resource Y, which is held by T2. T2 is waiting for
resource Z, which is held by T0. Thus, all the processes wait for
each other to release resources. In this situation, none of the processes can
finish their task. This situation is known as a deadlock.
Wait for graph
A simple way
to detect a state of deadlock is with the help of wait-for graph. This graph is
constructed and maintained by the system. One node is created in the wait-for
graph for each transaction that is currently executing. Whenever a transaction
T1 is waiting to lock an item X that is currently locked by a transaction T2, a
directed edge (T1->T2) is created in the wait-for graph. When T2 releases
the lock(s) on the items that Ti was waiting for, the directed edge is dropped
from the wait-for graph.
Technique that can be used to prevent the
deadlock situation
Releasing and reacquiring locks in order: The basic idea is to always acquire locks in
a particular order.
Using coarser-grained locks: One way to modify a program to avoid holding
multiple locks is to replace uses of multiple locks by a single lock.
Avoiding holding multiple locks: If not thread attempts to hold more than one
lock, then no deadlock can occur since the Hold and Wait condition is
invalidated. For some systems, this is easy to arrange, but for others there is
a genuine needs to lock multiple objects at the same time. In such cases,
minimizing the number of situations where threads hold multiple locks will
often still reduce the number of situations that need to be resolved by other
techniques, so is good practice.
Minimizing the holding of locks: The default style in Java holds locks on objects whenever a
method for the object is executing.
Using finer-grained locks: A common use of this technique is to replace
a lock on a whole object by a number of locks for its parts. E.g., instead of
locking a collection object like an array, the individual objects in the
collection may be locked as appropriate.
Reordering lock acquisition: If we require threads to always acquire
locks in a particular order, then no deadlock can occur. The Circular Wait
Condition is avoided, since we cannot have a circular chain if threads can only
wait for locks which come after the locks they’ve already acquired.
Database
deadlock example in banking
Suppose an
example of two database users working at a bank – let’s call those database
users A and B. Let’s say that user X works in the customer service department
and has to update the database for two of the banks customers, because one
customer (call him customer X) incorrectly received Rs.5, 000 in his account
when it should have gone to another customer (call him customer Y) – so user A
has to debit customer A’s account by Rs.5, 000 and also credit customer B’s
account Rs.5, 000.
Starvation
Starvation
describes a situation where a thread is unable to gain regular access to shared
resources and is unable to make progress. This happens when shared resources
are made unavailable for long periods by "greedy" threads. For
example, suppose an object provides a synchronized method that often takes a
long time to return. If one thread invokes this method frequently, other
threads that also need frequent synchronized access to the same object will
often be blocked.
Security
of data in Bank database
In the CIA
triad, confidentiality, integrity and availability are basic goals of
information security. However, there are instances when one goal is more
important than the others. The following are examples of situations or cases
where one goal of the CIA triad is highly important, while the other goals are
less important.
Confidentiality:
Protecting
information from unauthorized disclosure, or through improper disposal techniques. Underpinning the
goal of confidentiality are authentication methods like user-IDs and
passwords that uniquely identify a data system's users, and supporting control methods that limit each
identified user's access to the data system's resources.
Confidentiality
is the protection of information from unauthorized access. This goal of the CIA
triad emphasizes the need for information protection. Confidentiality requires
measures to ensure that only authorized people are allowed to access the
information. For example, confidentiality is maintained for a computer file if
authorized users are able to access it, while unauthorized persons are blocked
from accessing it. Confidentiality in the CIA triad relates to information
security because information security requires control on access to the
protected information.
For example,
information confidentiality is more important than integrity or availability in
the case of proprietary information of a Bank. Also, confidentiality is the
most important when the information is a record of people’s personal
activities. To guarantee confidentiality under the CIA triad, communications
channels must be properly monitored and controlled to prevent unauthorized
access.
Integrity:
Protecting information from unauthorized modification
and ensuring that information can be relied upon and is accurate and complete. Integrity refers to ensuring the authenticity of information. That information
is not altered, and that the source of the information is genuine. Imagine that
you have a website and you sell products on that site.
The CIA
triad goal of integrity is more important than the other goals in some cases of
financial information. Any change in financial records leads to issues in the
accuracy, consistency, and value of the information. For example, banks are
more concerned about the integrity of financial records, with confidentiality
having only second priority. Some bank account holders or depositors leave ATM
receipts unchecked and hanging around after withdrawing cash. This shows that
confidentiality does not have the highest priority. Instead, the goal of
integrity is the most important in information security in the banking system.
To guarantee integrity under the CIA triad, information must be protected from
unauthorized modification.
Availability:
Ensuring information is available when it is required.
Data is held in many different areas like Network Servers, Personal Computers,
Data Backup Media, and Data Loss Prevention.
Availability is the situation where information is available when and where it
is rightly needed. The main concern in the CIA triad is that the information
should be available when authorized users need to access it. Availability is
maintained when all components of the information system are working properly.
Problems in the information system could make it impossible to access
information, thereby making the information unavailable. In the CIA triad,
availability is linked to information security because effective security
measures protect system components and ensuring that information is available.
Suggestions
to data security
Encryption
(Private Communication)
Secure Sockets Layer-SSL encryption
technology is used within your Online Banking session to encrypt your personal
information before it leaves your computer in order to ensure no one else can
read it.
Session
time out
If some person are inactive for a certain
period of time while logged in to Bank Online, system will automatically log
other out, to avoid unauthorized activities.
Automatic Account Locking
Lock a user's account after a
specified number of consecutive failed log-in attempts. You can configure the
account to unlock automatically after a specified time interval or to require
database administrator intervention to be unlocked. The database administrator
can also lock accounts manually, so that they must be unlocked explicitly by
the database administrator.
Use Access control
Access control is a security technique that can be used
to regulate who or what can view or use resources in a computing environment.
Access control systems perform authorization identification, authentication, access approval, and
accountability of entities through login credentials including passwords, personal identification
numbers (PINs), biometric scans, and physical or electronic keys.There are two main types of access control:
physical and logical. Physical access control limits access to campuses,
buildings, rooms and physical IT assets. Logical access limits connections to
computer networks, system files and data.
The four main categories of access control
are:
·
Discretionary access control
·
Rule-based access control
Use Intrusion Detection and Prevention
Systems (IDS/IPS)
Intrusion Detection
and Prevention Systems (IDS/IPS) can be quite expensive for a financial
institution, especially if they are implemented in the proper way, which
requires 24/7 proactive management. As such, a risk-based decision should be
used to determine which system is best and where it should be located within
the network in order to provide the most cost effective benefits. There are
typically two deployment scenarios that determine the appropriate system or
systems to provide the best value. The institution either hosts Internet
accessible servers or it does not. The distinction plays a key role in
determining the appropriate deployment of IDS/IPS systems for the financial
institution.
Intrusion
detection and prevention software technologies addresses four types of
intrusion detection and prevention software technologies:
· Network-based, which monitors network traffic for particular network segments or devices and
analyzes the network and application protocol activity to identify suspicious
activity.
· Wireless, which
monitors wireless network traffic and analyzes it to identify suspicious
activity involving the wireless networking protocols themselves.
·
Network Behavior Analysis, which
examines network traffic to identify threats that generate unusual traffic
flows, such as denial of service attacks, certain forms of malware and policy
violations such as client system providing network services to other systems.
· Host-based, which monitors the
characteristics of a single host and the events occurring within that host for
suspicious activity.
Other Security Implementation Methods
·
Use Firewalls
·
Regularity monitor Software patches/updates
·
Use Anti-virus and anti-spyware software
·
Setup System Privileges
·
Auditing



No comments:
Post a Comment