Unit 6 Flashcards

1
Q

SAQ 1 - A

Compare the concept of a transaction with that of a coarse-grained atomic action. What are their differences and similarities?

A

A transaction and a coarse-grained atomic action both consist of several operations, but these are treated as belonging together, and hence both are atomic. They both give the appearance of indivisibility. The difference is that a transaction also has the property of failure atomicity:

  • if there is a failure part-way through the execution of the transaction, all the partly done operations are undone, so that it is as if nothing has happened;
  • if the transaction completes, the results of the transaction are made durable (stored in persistent storage).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

SAQ 1 - B

What are the desirable properties for transactions?

A

There are four desirable (ACID) properties: atomicity, consistency, isolation and durability.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

SAQ 1 - C

What are the transaction states in the transaction state model?

A

The transaction model specifies the following transaction states: Active, Failed, Partially Committed, Committed and Aborted.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

SAQ 1 - D
When a transaction is in the Partially Committed state, it has not fully completed. What are the possible next states? Describe the circumstances under which it would progress to each of them.

A

When a transaction is Partially Committed it can progress to the Committed state in the case where all the data involved in the transaction is written to disk and made durable. On the other hand, if there is a problem in making the data durable, the transaction is said to have Failed. The effects of the transaction are then undone, i.e. rolled back, and only then is the transaction completely finished when it enters the Aborted state.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

SAQ 1 - E

What is the role of a TP system? List its components.

A

The task of the TP system is to manage the correct and efficient execution of transactions.

Transaction Manager, scheduler, recovery manager and a cache manager.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Exercise 2

What is the similarity between the definition of serialisability for transactions, and the definition of thread safety for classes as discussed in Units 3 and 4?

A

A class is considered thread-safe if its instances behave under concurrent method calls as if they were called sequentially. This concept is similar to that for the execution of transactions, which should behave as if their execution was serial.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

SAQ 2 - A

What is a serial schedule?

A

A serial schedule is one in which transactions execute strictly one after the other, without any interleaving of operations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

SAQ 2 - B

Give the definition of serialisability.

A

A schedule for a group of transactions is serialisable if, and only if, it produces the same results as if the transactions had executed in some serial order.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

SAQ 2 - C

When executing a number of transactions, several serial schedules may be possible. These serial schedules do not necessarily all give the same final results for the data objects involved. Explain whether or not you think this is problematic.

A

This is not problematic, as the main concern is whether the data objects are in a consistent state.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

SAQ 2 - D

What are conflicting operations?

A

Operations conflict if the order in which they are performed affects the result.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

SAQ 2 - E

How is the notion of conflicting operations used to determine whether a schedule is serialisable?

A

The notion of conflicting operation allows us to determine in what order transactions execute a pair of conflicting operations. Then, if for all the pairs of conflicting operations in a schedule the order of execution by transactions is the same, we know that the schedule is equivalent to a serial schedule.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

SAQ 2 - F

Precedence graphs can be used as a notation for transactions and the conflicting operations of those transactions. Explain under which circumstances such graphs could contain a cycle.

A

A precedence graph contains a cycle if the schedule it represents is not serialisable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

SAQ 3 - A

What are the two phases of two-phase locking?

A

The two phases are acquire and release. In the acquire phase, the transaction gradually gets hold of all the locks it needs, as and when it needs them, but does not release any locks. In release, the transaction acquires no more locks but lets go of the ones it holds when it has completed work on the locked objects.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

SAQ 3 - B

What is a shared lock and why might we want to use shared locks?

A

A shared lock is useful when non-conflicting operations are using the same object, and it is therefore safe for both to use the object. If a shared lock can be used, it increases concurrency

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

SAQ 3 - C

What is a simple alternative to deadlock detection?

A

Timeouts

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

SAQ 3 - D

What are cascading aborts and what causes them?

A

Cascading aborts occur when one transaction has to abort and this leads to other transactions having to abort. This is bad for the performance of a system, as much work may have to be repeated.

17
Q

SAQ 3 - E

What are the advantages and disadvantages of TSO?

A

The advantages of TSO are:

  • simple and efficient implementation;
  • concurrency control data is held with individual objects and not centrally;
  • objects are not locked for longer than the duration of an operation and so circular waits and hence deadlocks cannot occur.

The main disadvantages of TSO are:

  • the loss of flexibility, in that it imposes one serial schedule and excludes other possibilities;
  • it is more susceptible to transaction aborts than other approaches, due to lack of isolation, and may possibly lead to cascading aborts.
18
Q

SAQ 3 - F

Why is the optimistic concurrency control approach so named?

A

This approach is called optimistic because it expects success, rather than failure. That is, it works away, confident that things will probably turn out for the best, and only performs a final check at the very end.

19
Q

SAQ 4 - A

Distinguish between volatile memory, persistent storage and stable storage.

A

Volatile memory holds data that would be lost if the device is switched off (see Section 2), whereas data stored in persistent storage remains even when the device is switched off, or the program that created the data stops executing. Stable storage is even more secure, because data is stored in several places. Therefore, if a disk fails in one location, usually the data survives in a different location.

20
Q

SAQ 4 - B

For crash resilience, what must be done when a transaction aborts?

A

For a transaction, when a crash occurs, it must be as though the transaction had never been invoked. Therefore all the effects of an aborted transaction must be undone before it can be restarted.

21
Q

SAQ 4 - C

Which of the ACID properties of transactions are addressed through the provision of crash resilience?

A

(Failure) atomicity and durability. Transactions have to be all or nothing, i.e. failure atomic, and therefore crash-resilience mechanisms are put in place to ensure that a half-completed transaction can be undone should a crash occur. A crash-resilience mechanism also ensures that, if the transaction had committed, its results are definitely stored in persistent store, i.e. durability.

22
Q

SAQ 4 - D

What is meant by rolling back?

A

Rolling back means restoring the persistent store to the state that existed before the start of a transaction that was aborted due to a system crash.

23
Q

SAQ 4 - E

In logging, what might happen if log information is written to the persistent store after the data updated by the atomic operation is written there?

A

In logging, the information in the log is used to roll back the persistent store to its state at the start of the transaction in which the crash occurred, by using the old values recorded in the log. If a crash occurs after the data updated by the transaction is written to the permanent store but before the log information is written there (i.e. it is not a write-ahead log), then there will be no record of the original state to facilitate rollback.

24
Q

SAQ 4 - F

What is shadowing? What essential feature is required to ensure that shadowing is implemented

A

Shadowing is where the results of a transaction are built up in a structure that mirrors part of the persistent store but the persistent store is not updated until the transaction commits. Once the transaction has committed, the updated copy replaces the relevant part of the persistent store. The essential feature of shadowing is that the replacement of the relevant part of the persistent store by the updated copy should occur in a single operation (e.g. by setting a single pointer). This avoids problems that would occur if a crash happened during the replacement.

25
Q

SAQ 5 - A

What does the term relation refer to in relational database models?

A

Relation refers to the logical grouping of the data, which is often represented as a table, with rows and columns. Each column contains data of a certain type, and each row, also known as a record, contains the details for an object in the table. The relation is the table as a whole.

26
Q

SAQ 5 - B

What are the core features of a DBMS?

A

The core features of a DBMS are:

  • A modelling language to model the data;
  • data structures for storage of data;
  • A query language to retrieve and update data;
  • A transaction concurrency control mechanism.
27
Q

SAQ 5 - C

What is the purpose of JDBC?

A

The purpose of JDBC is to provide a standard interface for communication with a large number of different databases.

28
Q

SAQ 5 - D

What are the steps involved in setting up a connection between a Java application and a database, when using JDBC?

A

The steps involved in setting up the communication are:
1 the application causes the database driver to be loaded;
2 the application requests a connection for a particular database, and the driver manager requests all registered drivers to respond with a connection;
3 the driver manager returns a connection to the application;
4 communication through the JDBC connection to the database.

29
Q

SAQ 6 - A

Why is a DBMS not able to offer concurrency control for distributed transactions?

A

Each DBMS has one resource manager. A distributed transaction involves objects residing in several locations held in several databases, and will require more than one resource manager to manage the concurrency control.

30
Q

SAQ 6 - B

What is the default setting for transaction processing when executing SQL statements?

A

The default setting of the Connection object is that each SQL statement is treated as a transaction.

31
Q

SAQ 6 - C

How can the default setting be altered?

A

The default setting can be altered with the command setAutoCommit(false), in which case all the statements after that are treated as forming part of one transaction, which will finish as soon as the commit or the rollback command is executed.

32
Q

SAQ 6 - D

Explain how we can deal with possible SQLExceptions occurring during the execution of SQL statements arriving from a Java application.

A

The SQL statements that form one transaction should be grouped in a try–catch clause. If an exception occurs during one of the statements being executed, this can be caught, and the transaction can then be rolled back using the rollback method.

33
Q

SAQ 7 - A

What is the point of having transaction isolation levels?

A

For some applications it may be appropriate to fine-tune the concurrency control, based on allowing certain types of read to happen.

34
Q

SAQ 7 - B

Explain the different forms of read: dirty read, non-repeatable read and phantom read.

A

A dirty read occurs if a transaction reads values that are written by another transaction that hasn’t committed yet.

A non-repeatable read occurs if a transaction reads the same object twice during
execution and finds a different value the second time, although the transaction has
not changed the value in the meantime.

A phantom read occurs when a transaction re-executes a query, returning a set of data that satisfies the condition in the query, and finds that the set of data has changed as a result of another recently committed transaction.

35
Q

SAQ 8 - A

Give two strategies for the replication of data.

A

Two strategies for the replication of data are synchronous and asynchronous replication. In synchronous replication all replicas of a data item are updated at the same time, when a data item is being updated. A transaction cannot commit unless all replicas will be updated.

In asynchronous replication the replicas are updated after the source has been updated.

36
Q

SAQ 8 - B

Differentiate between three forms of ownership for the replication of data.

A

Three forms of ownership for the replication of data are:

master–slave ownership – only the master site is permitted to make updates;

workflow ownership – permission to update the data moves along a certain path;

update anywhere ownership – permission is equally shared between peers.

37
Q

SAQ 8 - C

What do we mean by transparent management of a distributed DBMS? How does this apply to fragmentation and replication?

A

Transparent management is an important aim of a distributed DBMS, meaning that to the user of such a system it should appear as if they are dealing with just one database. The management of the distribution involves hiding the low-level details of where everything is stored exactly (fragmentation) and whether there are several copies of each data item (replication).

38
Q

SAQ 8 - D

What does the 2PC protocol aim to achieve?

A

The aim of 2PC is that the committing of a distributed transaction is done atomically – that is, either the entire transaction has taken place and its effects are made durable, or it is as if nothing has happened.