summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
1d0136f)
Since the central packages table was introduced we used FOR UPDATE
for synchronization between different wanna-build calls. This
causes a write for every locked row, which is unhelpful for WAL
traffic considering that merge-v3 needs to lock everything.
Let's synchronize by using FOR UPDATE on public.locks instead,
which should ease the WAL load a lot.
sub get_source_info {
my $name = shift;
return get_readonly_source_info($name) if $simulate;
sub get_source_info {
my $name = shift;
return get_readonly_source_info($name) if $simulate;
my $pkg = $dbh->selectrow_hashref('SELECT *, extract(days from date_trunc(\'days\', now() - state_change)) as state_days, floor(extract(epoch from now()) - extract(epoch from state_change)) as state_time FROM ' .
my $pkg = $dbh->selectrow_hashref('SELECT *, extract(days from date_trunc(\'days\', now() - state_change)) as state_days, floor(extract(epoch from now()) - extract(epoch from state_change)) as state_time FROM ' .
- table_name() . ' WHERE package = ? AND distribution = ?' .
- ' FOR UPDATE',
+ table_name() . ' WHERE package = ? AND distribution = ?',
undef, $name, $distribution);
return $pkg;
}
undef, $name, $distribution);
return $pkg;
}
sub lock_table {
return if $simulate;
sub lock_table {
return if $simulate;
- $dbh->do('SELECT 1 FROM ' . table_name() .
- ' WHERE distribution = ? FOR UPDATE', undef, $distribution) or die $dbh->errstr;
+ $q = 'SELECT 1 AS result FROM public.locks' .
+ ' WHERE architecture = ? AND distribution = ? FOR UPDATE';
+ my $result = $dbh->selectrow_hashref($q, undef, $arch, $distribution) or die $dbh->errstr;
+ die unless $result->{'result'} == 1;
--- /dev/null
+BEGIN;
+
+CREATE TABLE public.locks AS
+ SELECT DISTINCT distribution, architecture FROM packages;
+ALTER TABLE public.locks OWNER TO wbadm;
+REVOKE ALL ON public.locks FROM PUBLIC;
+GRANT SELECT ON public.locks TO PUBLIC;
+GRANT UPDATE ON public.locks TO wb_all;
+
+COMMIT;