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.


Issue

The logs show the following message, repeated at each polling cycle:

Error synchronizing RepoLoad <load id> for dloc <data location name>
org.springframework.dao.IncorrectResultSizeDataAccessException: Incorrect result size: expected 1, actual 2
  at com.semarchy.platform.integration.polling.dlbatch.RepoLoadDao.queryRepoLoad(RepoLoadDao.java:153)
  at com.semarchy.platform.integration.polling.dlbatch.DlBatchSynchronizer.checkRepoLoadOptimisticLocking(DlBatchSynchronizer.java:205)
  ...
  at com.semarchy.platform.integration.polling.IntegrationLoadDequeuer.dequeue(IntegrationLoadDequeuer.java:514)

The same root problem can show up in different ways:

  • Integration jobs and batches stay in PENDING or SCHEDULED status and are never processed.
  • The execution engine does not restart, or the Integration Batch Poller is not running. Opening the poller status page in the UI fails with Cannot create content of PollerStatusPage. It looks like IntegrationBatchPoller has not been started.
  • The log reports error building RepoLoad for dataLocationName [...], loadId: [...], sometimes followed by a NullPointerException on ibStatus.
  • The log reports a duplicate key or unique constraint violation on the DL_BATCH table (for example on its B_LOADID or batch ID index).
  • The issue appears right after a database connection loss, an upgrade, a restart of the execution engine, or a refresh of an environment from another one.


Cause

The state of a load is stored in three places that must stay consistent:

  • MTA_INTEG_LOAD and MTA_INTEG_BATCH in the repository schema.
  • DL_BATCH in the data location schema.

The integration batch poller keeps them aligned. For each load, it reads the load and its batch with a query that expects exactly one row. When the three tables are out of step, the synchronization fails, which aborts the whole dequeuing pass. The batch then stays SCHEDULED, and after a restart the poller may stay stopped, so every later batch remains PENDING.

The following situations lead to this state:

  • Lost synchronization after a database connection loss. This is the most common probable cause. The column LAST_DL_BATCH_SYNCED_REVISION of MTA_INTEG_LOAD is empty or behind the revision of the load or of its batch.
  • A load linked to two batches. The query then returns two rows instead of one, which is exactly what the error message says. This can follow a short disconnection between the database and the application server, or two overlapping submissions of the same load (double click, retried request). Starting from a later product version, this case is handled more robustly. The release notes of the version in use give the details.
  • Environment refresh or database restore. If a data location, a schema or a database is copied from another environment, loads can be pending or running in the copy, and the SEQ_LOADID and SEQ_BATCHID sequences of the repository can be lower than the highest values stored in DL_BATCH. New loads then reuse IDs that already exist, which produces duplicate key violations.
  • Several active pollers. More than one active xDM instance pointing to the same repository (a high availability node not set to passive, a second application server, a developer machine connected to the production repository) can prevent the pollers from coordinating, with batches left PENDING or SCHEDULED.

The error is a symptom of an inconsistent load state. It is not caused by the content of the data.


Solution


Prerequisites: both points are mandatory before changing any data

  1. Back up the repository tables that will be modified (MTA_INTEG_LOAD and MTA_INTEG_BATCH).
  2. Stop the activity on the data location, with one of these two options:
    • Option A (recommended): stop the application server, all instances in a high availability setup (active and passive). This is the safest option, because an execution engine or a batch poller that stays active can resynchronize and recreate the rows before the changes take effect.
    • Option B, only if stopping the application server is not possible: put the data location in maintenance mode and stop both the execution engine and the batch poller. The maintenance mode prevents any other load from being submitted during the operation.


In the SQL below, <repository_schema> is the repository schema name and <DATA_LOCATION_NAME> is the data location name, not a schema name. Using the schema name in place of the data location name is a frequent mistake: the statement then updates 0 rows.


Step 1: identify the loads that are out of sync


Check 1: desynchronization between the data location and the repository

This query, valid on PostgreSQL, Oracle and SQL Server, lists the loads whose synchronization revision (LAST_DL_BATCH_SYNCED_REVISION) is empty or behind the revision of the load or of its batch.

select IL.UUID, IL.REVISION as IL_REVISION, IB.REVISION as IB_REVISION,
       IL.LOADID, IL.LAST_DL_BATCH_SYNCED_REVISION
from <repository_schema>.MTA_INTEG_LOAD IL
inner join <repository_schema>.MTA_DATA_LOCATION DL on (IL.O_DATALOCATION = DL.UUID)
left join <repository_schema>.MTA_INTEG_BATCH IB on IB.R_INTEGLOAD = IL.UUID
where IL.CLASSNAME <> 'ContinuousLoad'
  and DL.NAME in ('<DATA_LOCATION_NAME>')
  and ( IL.LAST_DL_BATCH_SYNCED_REVISION is null
        or IL.LAST_DL_BATCH_SYNCED_REVISION < IL.REVISION
        or (IB.REVISION is not null and IL.LAST_DL_BATCH_SYNCED_REVISION < IB.REVISION) );

No row returned means that the data location and the repository are in sync, and each row returned is a load that is out of sync, which Step 3 fixes.


Check 2: duplicate batches on the same load in MTA_INTEG_BATCH

This query, valid on PostgreSQL, Oracle and SQL Server, lists the loads that have more than one row in MTA_INTEG_BATCH, by looking for duplicates on R_INTEGLOAD.

select R_INTEGLOAD, count(*)
from <repository_schema>.MTA_INTEG_BATCH
group by R_INTEGLOAD
having count(*) > 1;

No row returned means that no load is linked to two batches, and each row returned is a load linked to several batches, whose rows can be listed with below query to keep a copy before Step 2:

select * from <repository_schema>.MTA_INTEG_BATCH where R_INTEGLOAD = '<value returned>';


Step 2: check the batches in a non-terminal status

select STATUS, count(*)
from <repository_schema>.MTA_INTEG_BATCH
group by STATUS
order by STATUS;

PostgreSQL, Oracle and SQL Server (the same two statements work on all three, with no syntax difference). Compare the number of batches in PENDING, SCHEDULED or RUNNING with what is expected. If batches are stuck and no load is really running, set them to ERROR so that the poller can start again:

update <repository_schema>.MTA_INTEG_BATCH
set STATUS = 'ERROR'
where STATUS in ('PENDING', 'RUNNING', 'SCHEDULED')
  and O_DATALOCATION = (select UUID from <repository_schema>.MTA_DATA_LOCATION where NAME = '<DATA_LOCATION_NAME>');

This statement must be restricted to the batches that are really stuck, because it would also affect a batch that is legitimately running. Loads running at the time can be cancelled beforehand so that they do not interfere with the resynchronization. The affected data can be submitted again afterwards, with a new load ID.


Only if Check 2 of Step 1 returns a row: keep a copy of the two rows of MTA_INTEG_BATCH for that load, then delete the duplicate batch (the most recent one) while the execution engine is stopped. If the engine is running, it can write the duplicate again. Do not apply this deletion for any other symptom.


Step 3: resynchronize the load revisions

The statement below sets LAST_DL_BATCH_SYNCED_REVISION to the highest revision of the load and of its batch. This is the only step where the syntax depends on the database, because the update-from-subquery syntax differs. The three versions below do exactly the same thing and restrict the update to the data location named in the query. Choose the one matching the repository database.


PostgreSQL (the MERGE statement only exists from PostgreSQL 15):

UPDATE <repository_schema>.MTA_INTEG_LOAD T
SET LAST_DL_BATCH_SYNCED_REVISION = GREATEST(COALESCE(S.IL_REVISION, 0), COALESCE(S.IB_REVISION, 0))
FROM (
  SELECT IL.UUID, IL.REVISION AS IL_REVISION, IB.REVISION AS IB_REVISION
  FROM <repository_schema>.MTA_INTEG_LOAD IL
  INNER JOIN <repository_schema>.MTA_DATA_LOCATION DL ON IL.O_DATALOCATION = DL.UUID
  LEFT JOIN <repository_schema>.MTA_INTEG_BATCH IB ON IB.R_INTEGLOAD = IL.UUID
  WHERE IL.CLASSNAME <> 'ContinuousLoad'
    AND DL.NAME IN ('<DATA_LOCATION_NAME>')
    AND ( IL.LAST_DL_BATCH_SYNCED_REVISION IS NULL
          OR IL.LAST_DL_BATCH_SYNCED_REVISION < IL.REVISION
          OR (IB.REVISION IS NOT NULL AND IL.LAST_DL_BATCH_SYNCED_REVISION < IB.REVISION) )
) S
WHERE T.UUID = S.UUID;

Oracle (and PostgreSQL 15 or later):

MERGE INTO <repository_schema>.MTA_INTEG_LOAD T
USING (
  SELECT IL.UUID UUID, IL.REVISION IL_REVISION, IB.REVISION IB_REVISION
  FROM <repository_schema>.MTA_INTEG_LOAD IL
  INNER JOIN <repository_schema>.MTA_DATA_LOCATION DL ON IL.O_DATALOCATION = DL.UUID
  LEFT JOIN <repository_schema>.MTA_INTEG_BATCH IB ON IB.R_INTEGLOAD = IL.UUID
  WHERE IL.CLASSNAME <> 'ContinuousLoad'
    AND DL.NAME IN ('<DATA_LOCATION_NAME>')
    AND ( IL.LAST_DL_BATCH_SYNCED_REVISION IS NULL
          OR IL.LAST_DL_BATCH_SYNCED_REVISION < IL.REVISION
          OR (IB.REVISION IS NOT NULL AND IL.LAST_DL_BATCH_SYNCED_REVISION < IB.REVISION) )
) S ON (T.UUID = S.UUID)
WHEN MATCHED THEN UPDATE
SET T.LAST_DL_BATCH_SYNCED_REVISION = GREATEST(COALESCE(S.IL_REVISION, 0), COALESCE(S.IB_REVISION, 0));
-- commit if the SQL client is not in auto-commit mode

SQL Server (no GREATEST function in older versions, and the highest batch revision is taken to avoid duplicate rows):

WITH SourceData AS (
  SELECT IL.UUID AS UUID, IL.REVISION AS IL_REVISION, MAX(IB.REVISION) AS IB_REVISION
  FROM <repository_schema>.MTA_INTEG_LOAD IL
  INNER JOIN <repository_schema>.MTA_DATA_LOCATION DL ON IL.O_DATALOCATION = DL.UUID
  LEFT JOIN <repository_schema>.MTA_INTEG_BATCH IB ON IB.R_INTEGLOAD = IL.UUID
  WHERE IL.CLASSNAME <> 'ContinuousLoad'
    AND DL.NAME IN ('<DATA_LOCATION_NAME>')
    AND ( IL.LAST_DL_BATCH_SYNCED_REVISION IS NULL
          OR IL.LAST_DL_BATCH_SYNCED_REVISION < IL.REVISION
          OR (IB.REVISION IS NOT NULL AND IL.LAST_DL_BATCH_SYNCED_REVISION < IB.REVISION) )
  GROUP BY IL.UUID, IL.REVISION
)
MERGE INTO <repository_schema>.MTA_INTEG_LOAD AS T
USING SourceData AS S ON T.UUID = S.UUID
WHEN MATCHED THEN UPDATE SET
  T.LAST_DL_BATCH_SYNCED_REVISION =
    CASE WHEN COALESCE(S.IL_REVISION, 0) > COALESCE(S.IB_REVISION, 0)
         THEN COALESCE(S.IL_REVISION, 0) ELSE COALESCE(S.IB_REVISION, 0) END;

Run it once per data location concerned, and check the number of rows reported as updated. Re-running Check 1 of Step 1 afterwards must return no row.


Step 4: restart cleanly

If the application server was stopped in the prerequisites (Option A), it is still stopped at this point.
With Option B, stop it now, all instances in a high availability setup, because the cache cannot be cleared while it is running.
  1. Clear the application cache: remove the deployed semarchy folder in webapps/ and the Catalina folder in work/. Archive the logs so that they remain available for analysis.
  2. Start the application server (the active instance first, then the passive ones).
  3. In the Semarchy Configuration or Manager UI, check that the execution engine and the Integration Batch Poller are running.
  4. Submit a small test load on the data location and check that it completes.


Step 5: if the sequences are out of step (after a refresh or restore)

If the error follows the copy of an environment, or shows duplicate key violations on DL_BATCH, compare SEQ_LOADID and SEQ_BATCHID of the repository with the highest load ID and batch ID stored in the DL_BATCH table of each data location, and in MTA_INTEG_LOAD and MTA_INTEG_BATCH. Each sequence must be higher than those values. If it is not, raise it above the maximum and restart. The procedure to refresh an environment, including this check, is described in the article "Refresh an xDM development/test environment with production data".


If duplicate batch IDs already exist in DL_BATCH, a unique index can block the poller. Handling this case means removing duplicate rows, and it should be done only with the help of the support team after a backup.


Preventing the issue

  • Make sure that only one xDM instance is active against a given repository. In high availability, configure one active node and set the others to passive. Check that no other server or developer machine points to the production repository.
  • Avoid submitting the same load twice (repeated clicks, scheduled jobs or API calls that retry on timeout).
  • Stop the execution engine and the application server before refreshing an environment, and include the sequence check in the refresh procedure.
  • Investigate repeated database disconnections between the application server and the repository, because they are the most likely trigger of the desynchronization.