Problem
When attempting to run an Ad Server Inventory Sync in CloudSense Digital Fulfilment (Media), an error occurs:
"There is a pending message for the Ad Server Inventory Synch on this record. New request cannot be sent before the response is processed"
However, when querying for pending or unprocessed outgoing messages related to the Ad Server Inventory Sync, no records are found.
This "phantom" pending message error prevents inventory synchronization from running, blocking critical business operations.
Cause
This error can occur when:
- Stale State: The Ad Server record has a flag or reference indicating a pending sync, but the actual outgoing message record has been deleted, processed, or is in an inconsistent state.
- Sync Failure History: The inventory sync has been failing for an extended period (e.g., 30 days), and the system is tracking this as a "pending" operation even though no active message exists.
- Concurrent Sync Attempts: Multiple sync attempts were initiated, and the system locked the record to prevent duplicate processing, but the lock was not properly released.
Resolution
Step 1: Verify Outgoing Message Status
Query for any outgoing messages related to the Ad Server Inventory Sync:
SELECT Id, csam__Status__c, csam__Outgoing_Message__c,
csam__Outgoing_Message__r.csam__Status__c,
csam__Outgoing_Message__r.csam__ObjectGraph_Callout_Handler__c,
csam__Outgoing_Message__r.csam__ObjectGraph_Callout_Handler__r.Name
FROM csam__Incoming_Message__c
WHERE csam__Outgoing_Message__r.csam__ObjectGraph_Callout_Handler__r.Name = 'Ad Server Inventory Synch'
AND csam__Outgoing_Message__r.CREATEDDATE = THIS_MONTH
ORDER BY CREATEDDATE DESC
Expected Result:
- If the query returns no records, the "pending message" error is a stale state issue.
- If the query returns records with csam__Status__c = 'Pending' or 'In Progress', those messages are blocking the sync.
Step 2: Check Outgoing Message Records Directly
Query the outgoing message records for the Ad Server:
SELECT Id, Name, csam__Status__c, csam__ObjectGraph_Callout_Handler__r.Name,
csam__Error_Message__c, CreatedDate, LastModifiedDate
FROM csam__Outgoing_Message__c
WHERE csam__ObjectGraph_Callout_Handler__r.Name = 'Ad Server Inventory Synch'
AND CreatedDate = LAST_N_DAYS:30
ORDER BY CreatedDate DESC
Expected Result:
- Review the status of recent outgoing messages.
- If all messages show csam__Status__c = 'Completed' or 'Failed', but the error persists, the Ad Server record has a stale reference.
Step 3: Review Ad Server Record
Navigate to the Ad Server record in Salesforce and check for any custom fields or flags that might indicate a "pending sync" state. Look for:
- Custom fields like
Sync_Status__c,Last_Sync_Date__c, orPending_Sync__c. - Any workflow rules or process builders that update these fields based on outgoing message status.
If you find a field indicating a pending sync, but no actual pending messages exist, manually update the field to clear the stale state.
Step 4: Retry the Sync
After verifying that no pending messages exist and clearing any stale state flags:
- Navigate to the Ad Server record.
- Click the Sync Inventory button (or equivalent action).
- Monitor the outgoing message records to confirm the sync is progressing.
Step 5: Monitor for Recurring Failures
If the sync starts successfully but fails again:
- Review the
csam__Error_Message__cfield on the outgoing message record for details. - Common causes of recurring sync failures include:
- Authentication Issues: Invalid or expired credentials for the GAM (Google Ad Manager) integration.
- Data Issues: Malformed data in the Ad Server or related records (e.g., invalid inventory item IDs).
- Timeout Issues: Large inventory datasets causing the sync to exceed timeout limits.
Prevention
- Regular Monitoring: Set up a dashboard or report to track outgoing message statuses for Ad Server Inventory Syncs.
- Error Handling: Ensure custom workflows or process builders that manage sync state flags include logic to clear stale states after a certain period (e.g., 24 hours).
- Scheduled Cleanup: Consider implementing a scheduled Apex job to identify and clear stale "pending sync" flags where no corresponding outgoing message exists.
Additional Notes
- The Ad Server Inventory Sync is part of the CloudSense Digital Fulfilment (Media) module and integrates with Google Ad Manager (GAM).
- Outgoing messages are stored for 30 days by default. If a sync has been failing for longer than 30 days, historical message records may no longer be available for review.
Priyanka Bhotika
Comments