public inbox for pmg-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: Stoiko Ivanov <s.ivanov@proxmox.com>, pmg-devel@lists.proxmox.com
Subject: Re: [pmg-devel] [PATCH pmg-api] rulecache: sort rules additionally by id
Date: Thu, 15 Dec 2022 12:10:01 +0100	[thread overview]
Message-ID: <3560812a-fdf5-fb0d-f329-bf2baf94290f@proxmox.com> (raw)
In-Reply-To: <20221130132054.66009-1-s.ivanov@proxmox.com>

On 11/30/22 14:20, Stoiko Ivanov wrote:
> When more rules have the same priority currently their order is not
> stable - postgres returns them in a stable way, based on their last
> changetime - e.g. disabling and reenabling a rule puts it in the front
> of evaluation. Sortin by id (the primary key) in addition should make
> rule evaluation robust to such updates
> 
> While there is no guarantee of ordering (within the same priority)
> unexpected changes in which rule fires can cause confusion (at least
> it confused me quite a bit).
> 
> Reported-by: Mira Limbeck <m.limbeck@proxmox.com>
> Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
> ---
> With this applied I got stable ruleaction executions across rule-changes and
> pmg-smtp-filter restarts, but would appreciate some additional test
> 
>   src/PMG/RuleCache.pm | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/PMG/RuleCache.pm b/src/PMG/RuleCache.pm
> index d35e9c1..ebce98e 100644
> --- a/src/PMG/RuleCache.pm
> +++ b/src/PMG/RuleCache.pm
> @@ -37,7 +37,7 @@ sub new {
>   	my $sth = $dbh->prepare(
>   	    "SELECT ID, Name, Priority, Active, Direction FROM Rule " .
>   	    "where Active > 0 " .
> -	    "ORDER BY Priority DESC");
> +	    "ORDER BY Priority, ID DESC");

this sadly loses the 'DESC' ordering for the priority and all
rules are now loaded in the reverse order 🙃

>   
>   	$sth->execute();
>   






      reply	other threads:[~2022-12-15 11:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-30 13:20 Stoiko Ivanov
2022-12-15 11:10 ` Dominik Csapak [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3560812a-fdf5-fb0d-f329-bf2baf94290f@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pmg-devel@lists.proxmox.com \
    --cc=s.ivanov@proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal