RAIB: Unterschied zwischen den Versionen

Aus OrgaMon Wiki
Zur Navigation springen Zur Suche springen
Keine Bearbeitungszusammenfassung
Zeile 9: Zeile 9:
== Heart-Beat-Ticker ==
== Heart-Beat-Ticker ==


A Database has a internal GENERATOR (the Heart-Beat-Ticker = HBT) that is incremented after each statement commit doing some change to data or metadata. A read-Only Statement should not incrememt the HBT.
A Database has a internal GENERATOR (the Heart-Beat-Ticker = HBT [int64]) that is incremented after each statement commit doing some change to data or metadata. A read-Only Statement should not incrememt the HBT.


== Cluster Table ==
== Cluster Table ==

Version vom 23. Mai 2007, 11:26 Uhr

Redundant Array of Independent dataBases

Concepts

The goal of RAIB is to increase the availability of a firebird database. This is done by fail-over servers. They communicate with a "master" or "primary server" getting all the irformation to hold their copy of the database in sync with the master server. If the master fails, a spare can be used to do further transactions. This is NOT done by Replication-Technologies, but by Statement-Log-Packets for each "Write" Operation to the Database.

Heart-Beat-Ticker

A Database has a internal GENERATOR (the Heart-Beat-Ticker = HBT [int64]) that is incremented after each statement commit doing some change to data or metadata. A read-Only Statement should not incrememt the HBT.

Cluster Table

inside the database is the information about the spares and the master.

IP               Role       last-HBT
192.168.115.192  master
192.168.115.196  spare
192.168.115.80   spare
30.23.12.3       spare

planned switiching the role from master to spare

  1. the master do not accept W Statements any more. (Try again in 2 Minutes!)
  2. the master ensures that one spare is ready to take over (master.HTB=spare.HTB)
  3. the master switch to "spare" Mode
  4. the spare switch to "master" Mode

Database in master mode

Database in spare mode

  • the LOG-Receive Thread

the master initiates communication to a spare and post LOG Packets to the spare. Alle Packets are flushed into memory - if CRC is ok, the spare sends a ACK to the master. The master do NOT wait until the spare executes the statement because the master already prooved that the statement is executable.

  • the Worker-Thread

read the LOG-Packets, and execute it against the own Database.

  • LOG-missed

if the spare was offline a time, she sees that local.HBT <> LOG.HBT+1. Before it can execute actual LOG-Packets she MUST ask the master (or other spares) for the missing LOG Packets. After doing the old stuff it can start to do execute the actual receiced LOG-Packtes. While this time, the log-Receive thread isnt stopping filling the LOG-Buffer.

New Database "Shutdown" Modes

work normal but refuse "W" Statement with a special error message. They may redirekted to a master.


Statement LOG

A SQL-Statement like "DROP TABLE HUGEONE" may change thousands of Pages of the Database File. The Log-Packet itselb schould NOT contain all the changed Database Pages but the SQL-Statement itself. We can trust on the fact that the spares have all the knowledge to understand the Statement and execute it. This information is transmitted to one or more spares. This information is also stored in the Database itself for a time. At least until its prooven that a n.fabk is available. After the Log-DataBlock must succsessfully

1 - Do the Statement, detect while doing it, if it is harmfull to the Database (W oder R) 2 - if W: compile a log-block with the name GEN_ID(HBT,1);

   if R: break

3 - Send the LOG over the line.


Client: DROP TABLE CLUB$2873 Server: W,928372

Client: SELECT CURRENT_TIMESTAMP from RDB$DATABASE Server: R

Content of a LOG-Packet

  • the Statement
  • the Server context: used 'NOW'- and 'RND'- Values.
  • the HBT-Tick after the statement is executed.

detecting the failure

==

Positive Side Effekts

if a client assumes that a special statement is read only AND HBT of a spare is the HBT of the master she can post this statement to a spare to take load away from the master.

and the Statement is Read-Only it can be used as a 


Communication master<->spare

if a spare comes up (on connection request of a master), a spare can ask the master how

Good to have several spares

it enough fore the master to have one responding spare. If a connection to a spare fails it it retried every 20 Seconds.

Spare - Modes

Filesystem

the master writes the LOG-Packets (FileName <HBT>.flog) to a (remote) filesystem.

passive spare

a firebird-server receives the log-Packets but do not execute them. The worker-Thread writes the .flog Files to the filesystem.

active spare

a firebird-server receives and execute the log-Packets a fast as possible.