]> git.mxchange.org Git - friendica.git/commitdiff
We are now setting the corresponding worker id
authorMichael <heluecht@pirati.ca>
Thu, 21 Jul 2022 07:05:38 +0000 (07:05 +0000)
committerMichael <heluecht@pirati.ca>
Thu, 21 Jul 2022 07:05:38 +0000 (07:05 +0000)
database.sql
doc/database/db_inbox-entry.md
src/Protocol/ActivityPub/Processor.php
src/Protocol/ActivityPub/Queue.php
static/dbstructure.config.php

index d8b26cebeb65293a9ee8a3ebbec324ab31b4cfb4..a16bf24cf302edbf91ad934b60b4982639b2df68 100644 (file)
@@ -739,10 +739,13 @@ CREATE TABLE IF NOT EXISTS `inbox-entry` (
        `activity` mediumtext COMMENT 'The JSON activity',
        `signer` varchar(255) COMMENT '',
        `push` boolean NOT NULL DEFAULT '0' COMMENT '',
+       `wid` int unsigned COMMENT 'Workerqueue id',
         PRIMARY KEY(`id`),
         UNIQUE INDEX `activity-id` (`activity-id`),
         INDEX `object-id` (`object-id`),
-        INDEX `received` (`received`)
+        INDEX `received` (`received`),
+        INDEX `wid` (`wid`),
+       FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Incoming activity';
 
 --
index 56dee2c620f4e70fffe0477994ad6f444c6feee3..91126919e919871904211eda86cb7207692e58c0 100644 (file)
@@ -19,6 +19,7 @@ Fields
 | activity           | The JSON activity                    | mediumtext     | YES  |     | NULL    |                |
 | signer             |                                      | varchar(255)   | YES  |     | NULL    |                |
 | push               |                                      | boolean        | NO   |     | 0       |                |
+| wid                | Workerqueue id                       | int unsigned   | YES  |     | NULL    |                |
 
 Indexes
 ------------
@@ -29,6 +30,13 @@ Indexes
 | activity-id | UNIQUE, activity-id |
 | object-id   | object-id           |
 | received    | received            |
+| wid         | wid                 |
 
+Foreign Keys
+------------
+
+| Field | Target Table | Target Field |
+|-------|--------------|--------------|
+| wid | [workerqueue](help/database/db_workerqueue) | id |
 
 Return to [database documentation](help/database)
index 7973f0c0aadb85e571b3240dc7bbe42c8aceb886..03c68eac002f6fc52d3f226a8a5e174d4079c1c4 100644 (file)
@@ -294,7 +294,8 @@ class Processor
                        if ($fetch_by_worker) {
                                Logger::notice('Fetching is done by worker.', ['parent' => $activity['reply-to-id'], 'recursion-depth' => $recursion_depth]);
                                $activity['recursion-depth'] = 0;
-                               Worker::add(PRIORITY_HIGH, 'FetchMissingActivity', $activity['reply-to-id'], $activity, '', Receiver::COMPLETION_AUTO);
+                               $wid = Worker::add(PRIORITY_HIGH, 'FetchMissingActivity', $activity['reply-to-id'], $activity, '', Receiver::COMPLETION_AUTO);
+                               Queue::setWorkerId($activity, $wid);
                                return [];
                        }
                }
index c5cfd522ae227239b84b447e97666de0f3781403..f8f5666d13b8dbb405c57125e3ea95958f3273af 100644 (file)
@@ -89,6 +89,21 @@ class Queue
                DBA::delete('inbox-entry', ['id' => $activity['entry-id']]);
        }
 
+       /**
+        * Set the worker id for the queue entry
+        *
+        * @param array $activity
+        * @param int   $wid
+        * @return void
+        */
+       public static function setWorkerId(array $activity, int $wid)
+       {
+               if (empty($activity['entry-id']) || empty($wid)) {
+                       return;
+               }
+               DBA::update('inbox-entry', ['wid' => $wid], ['id' => $activity['entry-id']]);
+       }
+
        /**
         * Process the activity with the given id
         *
@@ -129,7 +144,7 @@ class Queue
        }
 
        /**
-        * Process all activities
+        * Clear old activities
         *
         * @return void
         */
index 0db5681871a642fd1cab37b195f964cf04917dfa..abaddc8d0ab84ca38bf9155a2b4a36f365e201d8 100644 (file)
@@ -798,12 +798,13 @@ return [
                        "activity" => ["type" => "mediumtext", "comment" => "The JSON activity"],
                        "signer" => ["type" => "varchar(255)", "comment" => ""],
                        "push" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
-               ],
+                       "wid" => ["type" => "int unsigned", "foreign" => ["workerqueue" => "id"], "comment" => "Workerqueue id"],               ],
                "indexes" => [
                        "PRIMARY" => ["id"],
                        "activity-id" => ["UNIQUE", "activity-id"],
                        "object-id" => ["object-id"],
                        "received" => ["received"],
+                       "wid" => ["wid"],
                ]
        ],
        "inbox-entry-receiver" => [