When the database server performs a logical recovery, it normally defers index builds until the end of the recovery. However, if the database server is acting as a secondary database server, it is in logical recovery mode for as long as data replication is running. Thus, secondary database servers must use a different mechanism to perform index builds.
The mechanism used is as follows. When the secondary database server receives a logical-log record that necessitates a corresponding index build, it sends a message back to the primary database server to request a physical copy of the index. The primary database server has a lock on the table that is being updated. The owner of the lock is a dr_btsend thread. The application thread that is executing is free to continue processing. The dr_btsend thread cannot release the lock, however, until the secondary database server acknowledges receipt of the index. If the application tries to access the table while it is locked, this attempt fails, unless the application has set the lock mode to wait.
If applications do not have lock mode set to WAIT, some unexpected errors might occur. For example, many SQL statements cause updates to the catalog table indexes. The following sequence of SQL statements fails if the lock mode of the application is not set to WAIT:
CREATE DATABASE db_name; DATABASE db_name; CREATE TABLE tab_name;
These SQL statements would fail because the CREATE DATABASE statement creates indexes on the systables catalog table and, therefore, places a lock on the table until the indexes are copied over to the secondary database server. Meanwhile, the CREATE TABLE statement tries to insert a row into the systables catalog table. The insert fails, however, because the table is locked.
This application would fail because both the CREATE DATABASE and CREATE TABLE statements cause updates to the systables catalog table index.
Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]