Analyse: Abgleich schaltet neu aktivierte Analysen nicht ab (Sperre + Nachlesen), weitere Abgleich-Tests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Opus 5.5 committed 2026-10-01 18:50:36 +00:00
1 parent 78170567b4
commit 495c3a2c40
2 files changed
+76 -9

No files matched your search

+14 -9
View File
@@ -566,16 +566,21 @@ export async function runAnalyseReconcile({ now = new Date() } = {}) {
if (!doc.activatedMailAt) await sendK18(doc, project)
})
} else if ((doc.state === 'off' || doc.state === 'disabled') && SITE_KEY_RE.test(doc.siteKey || '')) {
await analyseDeps.client.stopSite(doc.siteKey)
stats.stopped.push(doc.$id)
const marker = offMarker(doc)
if (!doc.removalTicketId && marker >= config.analyse.avvVersion) {
const project = await projectOf(doc.projectId)
if (project && (await customerOf(doc.customerId))) {
await ensureRemovalTicket(doc, project)
stats.tickets.push(doc.$id)
// Gleiche Sperre wie Ein-/Ausschalten, Dokument nachlesen: eine inzwischen neu aktivierte Analyse bleibt an
await withLocks([`analyse:${doc.projectId}`], async () => {
const fresh = await listDocuments(config.collections.portalFeatures, [Query.equal('featureKey', FEATURE_KEY), Query.equal('projectId', doc.projectId), Query.limit(1)])
const cur = fresh[0]
if (!cur || cur.state === 'active' || !SITE_KEY_RE.test(cur.siteKey || '')) return
await analyseDeps.client.stopSite(cur.siteKey)
stats.stopped.push(cur.$id)
if (!cur.removalTicketId && offMarker(cur) >= config.analyse.avvVersion) {
const project = await projectOf(cur.projectId)
if (project && (await customerOf(cur.customerId))) {
await ensureRemovalTicket(cur, project)
stats.tickets.push(cur.$id)
}
}
}
})
}
} catch (err) {
console.error(`[analyse] Abgleich für Projekt ${doc.projectId} fehlgeschlagen:`, err.message)