[Rt-commit] rt branch, 4.4/previewscrips-race, updated. rt-4.4.1-226-g376f0b7
Shawn Moore
shawn at bestpractical.com
Thu Jan 19 13:53:51 EST 2017
The branch, 4.4/previewscrips-race has been updated
via 376f0b7a7ad16e8222db64558fb44fbba3ef71eb (commit)
from 8862bd94d3ddc84ac858f36cff2a032e51fdf67c (commit)
Summary of changes:
sbin/rt-validator.in | 42 +++++++++++++++++++++++++++++++++++++++++-
1 file changed, 41 insertions(+), 1 deletion(-)
- Log -----------------------------------------------------------------
commit 376f0b7a7ad16e8222db64558fb44fbba3ef71eb
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Thu Jan 19 18:45:45 2017 +0000
rt-validator rules for Ticket.Owner = Owner GroupMembers
The first rule catches the case where Owner GroupMembers is empty.
The second rule catches the case, exposed by the race condition fixed in
the previous commits, where the Owner GroupMember doesn't match the
denormalized Ticket.Owner column.
Together, along with the traditional checks to verify that there exists
an Owner role group for each ticket, as well as CachedGroupMembers
matching GroupMembers, ought to cover all drift between the denormalized
Ticket.Owner field and the normalized Owner role group GroupMembers.
diff --git a/sbin/rt-validator.in b/sbin/rt-validator.in
index 340d865..68263eb 100644
--- a/sbin/rt-validator.in
+++ b/sbin/rt-validator.in
@@ -636,7 +636,47 @@ push @CHECKS, 'Tickets -> other' => sub {
update_records( 'Tickets', { id => $id, Owner => $prop{Owner} }, { Owner => $replace_with } );
},
);
- # XXX: check that owner is only member of owner role group
+
+ # there exists a GroupMember for each ticket Owner role group
+ {
+ my $query = <<END;
+SELECT Tickets.Id, Tickets.Owner
+FROM Groups
+JOIN Tickets ON Tickets.Id = Groups.Instance
+LEFT JOIN GroupMembers ON Groups.Id = GroupMembers.GroupId
+WHERE Groups.Name = 'Owner'
+AND Groups.Domain = 'RT::Ticket-Role'
+AND GroupMembers.MemberId IS NULL;
+END
+
+ my $sth = execute_query( $query );
+ while ( my ($ticket, $owner) = $sth->fetchrow_array ) {
+ $res = 0;
+ print STDERR "The owner of ticket #$ticket is inconsistent. The denormalized owner is user #$owner\n";
+ print STDERR "but there is no normalized owner.\n";
+ }
+ }
+
+ # Tickets.Owner = OwnerRoleGroup.MemberId
+ {
+ my $query = <<END;
+SELECT Tickets.Id, Tickets.Owner, GroupMembers.MemberId
+FROM Groups
+JOIN GroupMembers ON Groups.Id = GroupMembers.GroupId
+JOIN Tickets ON Tickets.Id = Groups.Instance
+WHERE Groups.Name = 'Owner'
+AND Groups.Domain = 'RT::Ticket-Role'
+AND Tickets.Owner != GroupMembers.MemberId;
+END
+
+ my $sth = execute_query( $query );
+ while ( my ($ticket, $owner, $rolemember) = $sth->fetchrow_array ) {
+ $res = 0;
+ print STDERR "The owner of ticket #$ticket is inconsistent. The denormalized owner is user #$owner\n";
+ print STDERR "but there exists a normalized owner role group member, user #$rolemember.\n";
+ }
+ }
+
return $res;
};
-----------------------------------------------------------------------
More information about the rt-commit
mailing list