@@ -857,9 +857,10 @@ export async function executeSync(
857857 if ( ! connectorHasAuthSource ( connectorConfig . auth , connectorBeforeLock ) ) {
858858 logger . warn ( 'Skipping sync: connector has no credential to authenticate with' , { connectorId } )
859859 /**
860- * Written only while the row is still the credential-less runnable row this run read: a
861- * reconnect that landed in between keeps its schedule, and a paused or disabled connector
862- * a stale task reached keeps its status.
860+ * Written only while the row is still the credential-less row this run read: a reconnect
861+ * that landed in between keeps its schedule, and a paused or disabled connector a stale task
862+ * reached keeps its status. A row this dispatch marked `pending` is released with it, the
863+ * same token match the lock acquisition below applies.
863864 */
864865 const observed = (
865866 column : typeof knowledgeConnector . credentialId | typeof knowledgeConnector . encryptedApiKey ,
@@ -873,7 +874,15 @@ export async function executeSync(
873874 eq ( knowledgeConnector . id , connectorId ) ,
874875 observed ( knowledgeConnector . credentialId , connectorBeforeLock . credentialId ) ,
875876 observed ( knowledgeConnector . encryptedApiKey , connectorBeforeLock . encryptedApiKey ) ,
876- inArray ( knowledgeConnector . status , [ ...RUNNABLE_CONNECTOR_STATUSES ] )
877+ or (
878+ inArray ( knowledgeConnector . status , [ ...RUNNABLE_CONNECTOR_STATUSES ] ) ,
879+ options . dispatchToken
880+ ? and (
881+ eq ( knowledgeConnector . status , 'pending' ) ,
882+ eq ( knowledgeConnector . syncLockToken , options . dispatchToken )
883+ )
884+ : undefined
885+ )
877886 )
878887 )
879888 return { ...result , skipReason : 'credential_missing' }
0 commit comments