core: record transactions that have seen ordering cycles

This commit is contained in:
Mike Yuan
2025-11-12 23:47:39 +01:00
parent 0d9e79d5ca
commit d3da74696b
4 changed files with 24 additions and 5 deletions
+2
View File
@@ -1659,6 +1659,8 @@ static void manager_clear_jobs_and_units(Manager *m) {
m->n_running_jobs = 0;
m->n_installed_jobs = 0;
m->n_failed_jobs = 0;
m->transactions_with_cycle = set_free(m->transactions_with_cycle);
}
Manager* manager_free(Manager *m) {
+3
View File
@@ -238,6 +238,9 @@ typedef struct Manager {
uint64_t last_transaction_id;
/* IDs of transactions that once encountered ordering cycle */
Set *transactions_with_cycle;
sd_event_source *run_queue_event_source;
char *notify_socket;
+13
View File
@@ -8,6 +8,7 @@
#include "bus-common-errors.h"
#include "bus-error.h"
#include "dbus-unit.h"
#include "hash-funcs.h"
#include "manager.h"
#include "set.h"
#include "slice.h"
@@ -15,6 +16,8 @@
#include "strv.h"
#include "transaction.h"
#define CYCLIC_TRANSACTIONS_MAX 4096U
static bool job_matters_to_anchor(Job *job);
static void transaction_unlink_job(Transaction *tr, Job *j, bool delete_dependencies);
@@ -399,6 +402,16 @@ static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsi
LOG_MESSAGE_ID(SD_MESSAGE_UNIT_ORDERING_CYCLE_STR),
LOG_ITEM("%s", strempty(unit_ids)));
if (set_size(j->manager->transactions_with_cycle) >= CYCLIC_TRANSACTIONS_MAX)
log_warning("Too many transactions with ordering cycle, suppressing record.");
else {
uint64_t *id_buf = newdup(uint64_t, &tr->id, 1);
if (!id_buf)
log_oom_warning();
else
(void) set_ensure_consume(&j->manager->transactions_with_cycle, &uint64_hash_ops_value_free, id_buf);
}
if (delete) {
const char *status;
/* logging for j not k here to provide a consistent narrative */