This knowledge article contains several warnings, prerequisites, and important precautions throughout the instructions. Please read the entire article carefully and ensure that all prerequisites and cautionary notes are understood before proceeding. Users are responsible for reviewing each step.
Need
A development or test xDM environment must be tested with production data that has already been stewarded, for example to assess the impact of new data sources or new matching rules on existing golden records.
A full copy of the data location from production to test moves the data, but it can cause problems afterwards: duplicate key violations in the execution engine, or a test environment that behaves like a production one.
This article describes the procedure to refresh a test or development environment with production data in a consistent way.
Summarized Solution
Only the production data location schema is dumped and restored into the test data location schema. The repository schema must never be copied between environments!!
The procedure has these main points:
- Check that the physical tables of the model editions in test and production are compatible (same columns and data types).
- Stop the application server and any new loads, then back up the test data location schema and note the UUID of the test data location.
- Dump the production data location schema, recreate the test schema, and restore the dump into it.
- Put the original test UUID back in
DL_DATA_LOC. - Make sure the
SEQ_LOADIDandSEQ_BATCHIDsequences of the test repository are greater than the production values, then restart.
Detailed Solution
Warning: this procedure is for the data location schema only. The repository schema must not be copied from production to test or development.
The SQL examples below are for Oracle. Schema names (TEST_MDM, TEST_REPO, PROD_MDM, PROD_REPO) are placeholders. The exact commands depend on the database in use and are best prepared with the DBA. Try the procedure on a non-critical environment first.
Step 1: check that the model editions are compatible
The model edition versions never match, because the test environment is usually ahead of production. What matters is that the physical tables are compatible: same columns, same data types.
Step 2: stop the application server
Stop the application server (Tomcat in the original procedure) and do not submit any new loads.
Stopping the server is required, not optional.
If the test data location is dropped while the server is running, a JDBC datasource error ("not bound in context") can occur and a restart may not fix it.
The data location may then have to be deleted and recreated in the Workbench.
Step 3: back up the test data location schema and note its UUID
- Back up the test data location schema.
- Note the UUID of the test data location. It is needed in Step 6.
select UUID from TEST_MDM.DL_DATA_LOC;
/* Sample result: 09DE459BA8934FAE92A217B60A263EDD */Step 4: back up the production data location schema
Dump the production data location schema to a file.
The tool depends on the database:
- Oracle: Data Pump (other backup mechanisms can also be used).
- PostgreSQL:
pg_dump. - Microsoft SQL Server:
BACKUP DATABASE.
Step 5: recreate the test schema and load the production dump
Drop and recreate the test data location schema, then load the production dump into it.
/* Oracle example. The exact commands depend on the environment. */
DROP USER TEST_MDM CASCADE;
CREATE USER TEST_MDM IDENTIFIED BY <password> DEFAULT TABLESPACE USERS TEMPORARY TABLESPACE TEMP;
GRANT CONNECT, RESOURCE TO TEST_MDM;Then import the production dump into TEST_MDM, mapping the production schema to the test schema.
Depending on the environment, permissions on the objects of this schema may need to be granted again.
Step 6: restore the test data location UUID
The restored DL_DATA_LOC table contains the production UUID. Put back the UUID noted in Step 3.
update TEST_MDM.DL_DATA_LOC set UUID = '09DE459BA8934FAE92A217B60A263EDD';
/* Use the UUID saved in Step 3. */Step 7: align the load and batch sequences
The SEQ_LOADID and SEQ_BATCHID sequences of the test repository must be greater than the highest load ID and batch ID in DL_BATCH. Otherwise a new load or batch could use an ID that is already reserved.
This query compares the test and production sequences (it must be adapted when the two environments are on separate databases). Note that nextval consumes one value of each sequence.
select
TEST_REPO.SEQ_LOADID.nextval + 1 as next_test_loadid,
PROD_REPO.SEQ_LOADID.nextval + 1 as next_prod_loadid,
TEST_REPO.SEQ_BATCHID.nextval + 1 as next_test_batchid,
PROD_REPO.SEQ_BATCHID.nextval + 1 as next_prod_batchid,
CASE
WHEN ( TEST_REPO.SEQ_LOADID.nextval >= PROD_REPO.SEQ_LOADID.nextval
AND TEST_REPO.SEQ_BATCHID.nextval >= PROD_REPO.SEQ_BATCHID.nextval)
THEN 'IDs are good. No action needed.'
ELSE 'The nextval of SEQ_LOADID or SEQ_BATCHID must be increased manually'
END as message
from dual;If a sequence is behind, raise it to at least the maximum value found.
Two options exist.
Option 1: drop and recreate the sequence. Simpler, but permissions on the sequence must be granted again.
DROP SEQUENCE SEQ_LOADID;
CREATE SEQUENCE SEQ_LOADID START WITH <value above the production load ID>;
DROP SEQUENCE SEQ_BATCHID;
CREATE SEQUENCE SEQ_BATCHID START WITH <value above the production batch ID>;
/* Grant the permissions on the sequences again. */Option 2: temporarily change the increment. The sequence is not dropped, so its permissions stay unchanged.
ALTER SEQUENCE TEST_REPO.SEQ_LOADID INCREMENT BY <difference needed to exceed the production load ID>;
select TEST_REPO.SEQ_LOADID.nextval from dual;
ALTER SEQUENCE TEST_REPO.SEQ_LOADID INCREMENT BY 1;
select TEST_REPO.SEQ_LOADID.nextval from dual;
/* Repeat for SEQ_BATCHID with the difference needed to exceed the production batch ID. */Step 8: restart and verify
Restart the application server.
New loads can be submitted again.
The test data location now contains the production data and is ready for testing, for example new matching rules.
Troubleshooting the Oracle import
With the legacy imp utility, the import can fail with IMP-00017 and ORA-02304: invalid object identifier literal on the type SEM_SPLIT_TBL. The type can be recreated manually:
create or replace type SEM_SPLIT_TBL as table of varchar2(32767 BYTE);With impdp, the problem is prevented with the option TRANSFORM=oid:n.
What is not transferred
Only the content of the data location schema is transferred.
Everything stored in the repository stays as it is in the test environment, which means the following production information is not available after the refresh:
- Logs of the data loads.
- Logs of the integration batches.
- Workflow statuses.
The model edition, the data location definition and its type (development or production) also come from the repository and are unchanged.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article