HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

Replicating only changes made by a specific database user

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
madeuserreplicatingdatabasechangesspecificonly

Problem

I am performing parallel testing. We have upgraded the legacy batch jobs to a new framework which we need to test against the existing batch jobs.

In the existing setup, I have web application which creates or updates records based on user input and these batch jobs will process the records.

The plan is to have 2 databases, primary and secondary, with the existing batch job connected to the primary database server and the new batch job connected to the secondary database server.

The web application will populate data to both primary and secondary databases.

I would like to perform replication for all the tables in the database. However, I would only like to replicate any DML changes done by the specific database account used by the web application.

Is that possible?

Solution

I agree with Phil+1 that this is not readily possible. Furthermore, it is very unclear how this could even work. Imagine the following simple table is being replicated.

C1   C2
  1    'Apple'
  2    'Orange'
  3    'Pear'


Scenario 1

batchjobaccount : INSERT INTO T1 VALUES (4,'Peach');
 appserveraccount: UPDATE T1 SET C2='Grape' WHERE C1=4;


What should happen in the replication? Should the record be created so that the appserveraccount action can take place or should the update be ignored?

Scenario 2

batchjobaccount : UPDATE T1 SET C1=5 WHERE C1=2;
 appserveraccount: DELETE FROM T1 WHERE C1=5;


What should happen in the replication? Should the record be deleted or not?

Scenario 3

batchjobaccount : DELETE FROM T1 WHERE C1=3;
 appserveraccount: UPDATE T1 SET C2='Strawberry' WHERE C1=3;


What should happen? Should the update fail on the local database but succeed on the replicated database or should it not run on the remote database because it failed on the local database?

If you don't want changes by batchjobaccount to replicate, then why give them permission to make the changes on the local database? If they need a local playground, then can you just make a local copy of the tables and only give batchjobaccount access to those?

Code Snippets

C1   C2
  1    'Apple'
  2    'Orange'
  3    'Pear'
batchjobaccount : INSERT INTO T1 VALUES (4,'Peach');
 appserveraccount: UPDATE T1 SET C2='Grape' WHERE C1=4;
batchjobaccount : UPDATE T1 SET C1=5 WHERE C1=2;
 appserveraccount: DELETE FROM T1 WHERE C1=5;
batchjobaccount : DELETE FROM T1 WHERE C1=3;
 appserveraccount: UPDATE T1 SET C2='Strawberry' WHERE C1=3;

Context

StackExchange Database Administrators Q#24326, answer score: 4

Revisions (0)

No revisions yet.