Is it possible to have a data anomaly when the same row is
updated at the same time on two Streams instances? I like the idea
of using n-way Streams replication instead of RAC but I'm concerned
about managing data integrity.
For example, if I changes JONES salary to $50k on one instance while
someone on the other instances changes JONES to $70k, won't these
changes cross-replicate causing data overlay, or does Oracle Streams
have a conflict resolution mechanism?
Both advanced replication and streams send both the before image
and the changed image. If the before image does not match, either
conflict resolution must be used to resolve the conflict or the
transaction will go in the error queue. So if Jones's salary is
changed on both computers at the same time, both changes will end up
in the replication error queue because the before images will not
match.
T.J. Ruggiero, an Oracle support engineer notes: When a
transaction is committed at the source, an LCR (logical change
record) is generated and enqueued via Oracle AQ. This LCR contains
both old values and new values (assuming that the proper
supplemental logging has been set up to put this information in the
redo streams) just like in advanced replication.
The LCR is propagated to the target if a propagation is involved,
and the apply process there attempts to apply it. If it is found
that that the old values in the LCR don't match the current values
in the row at the target, an error is signaled and the LCR is moved
to the error queue. This is called 'Conflict Detection' and is
implemented by default.
'Conflict Resolution' is where a method is called to settle the
conflict once it is detected before the LCR is placed in the error
queue. This must be set up by the DBA.
Conflict is expected when two sites can update the same row at the
same time. If this type of functionality is desired, then conflict
resolution should be implemented. Conflict can be avoided if sites
practice data ownership, i.e. each site only hits certain data.
 |
If you like Oracle tuning, you may enjoy my new book "Oracle
Tuning: The Definitive Reference", over 900 pages
of BC's favorite tuning tips & scripts.
You can buy it direct from the publisher for 30%-off and get
instant access to the code depot of Oracle tuning scripts. |