mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 09:28:40 +00:00
fix dual writing internal ID conflict
This commit is contained in:
parent
05f99dcdf0
commit
7b588219f9
1 changed files with 12 additions and 1 deletions
|
|
@ -108,6 +108,17 @@ class UsageDump extends Action
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create clone to dual write
|
||||
* This is required as first request to db
|
||||
* modifies the document's details like internal ID
|
||||
* which will conflict in new DB
|
||||
*/
|
||||
$clonedProjectDoucments = [];
|
||||
foreach ($projectDocuments as $document) {
|
||||
$clonedProjectDoucments[] = new Document($document->getArrayCopy());
|
||||
}
|
||||
|
||||
$dbForProject->createOrUpdateDocumentsWithIncrease(
|
||||
collection: 'stats',
|
||||
attribute: 'value',
|
||||
|
|
@ -117,7 +128,7 @@ class UsageDump extends Action
|
|||
$dbForLogs->createOrUpdateDocumentsWithIncrease(
|
||||
collection: 'usage',
|
||||
attribute: 'value',
|
||||
documents: $projectDocuments
|
||||
documents: $clonedProjectDoucments
|
||||
);
|
||||
$end = \microtime(true);
|
||||
Console::log('['.DateTime::now().'] Id: '.$project->getId(). ' InternalId: '.$project->getInternalId(). ' Db: '.$project->getAttribute('database').' ReceivedAt: '.$receivedAt. ' Keys: '.$numberOfKeys. ' Time: '.($end - $start).'s');
|
||||
|
|
|
|||
Loading…
Reference in a new issue