Commit e2dbffbf26c85746e6a0f0f613893bcb5e30a42e
1 parent
8b3ff21a
Exists in
master
faz SET TRANSACTION READ ONLY para a operação refresh_gerente, que é uma das mai…
…s pesadas que tem. Isso deve reduzir a contenção de locks significativamente, de modo a resultar em um impacto significativo na performance git-svn-id: http://svn.softwarepublico.gov.br/svn/sistemadeatendimento/sistema/trunk@6 63db2ce5-8a6c-0410-abb9-a418dd412890
Showing
1 changed file
with
24 additions
and
12 deletions
Show diff stats
Fila-Servico/lib/Fila/Servico/Controller/WS/Gestao/Local.pm
... | ... | @@ -92,22 +92,34 @@ sub refresh_painel :Private { |
92 | 92 | |
93 | 93 | sub refresh_gerente :Private { |
94 | 94 | my ($self, $c) = @_; |
95 | + | |
95 | 96 | # esse método é chamado por outras ações que precisam fazer um |
96 | 97 | # callback para o gerente do local. As informações todas são |
97 | 98 | # enviadas, para que possa ser apresentada a tela. |
98 | 99 | |
99 | - my $old = $c->stash->{soap}->compile_return(); | |
100 | - | |
101 | - my $local = $self->status_local($c, {}); | |
102 | - my $guiches = $self->status_guiches($c, {}); | |
103 | - my $encaminhamentos = $self->listar_encaminhamentos($c, {}); | |
104 | - | |
105 | - $c->model('SOAP')->transport->connection($c->engine->connection($c)); | |
106 | - $c->model('SOAP')->transport->addrs([$c->stash->{local}->gerente_atual->first->funcionario->jid.'/cb/render/gerente']); | |
107 | - $c->model('SOAP::CB::Gerente')->render_gerente({ %$local, %$guiches, %$encaminhamentos }); | |
108 | - | |
109 | - $c->stash->{soap}->compile_return($old); | |
110 | - | |
100 | + my $storage = $c->model('DB')->storage; | |
101 | + $storage->ensure_connected; | |
102 | + | |
103 | + $storage->txn_do | |
104 | + (sub { | |
105 | + # Essa operação é somente leitura, dessa forma, vamos mandar o | |
106 | + # model alterar o tipo da transação, de forma a reduzir a | |
107 | + # contenção de locks | |
108 | + $storage->dbh_do('SET TRANSACTION READ ONLY'); | |
109 | + | |
110 | + my $local = $self->status_local($c, {}); | |
111 | + my $guiches = $self->status_guiches($c, {}); | |
112 | + my $encaminhamentos = $self->listar_encaminhamentos($c, {}); | |
113 | + | |
114 | + my $old = $c->stash->{soap}->compile_return(); | |
115 | + $c->model('SOAP')->transport->connection | |
116 | + ($c->engine->connection($c)); | |
117 | + $c->model('SOAP')->transport->addrs | |
118 | + ([$c->stash->{local}->gerente_atual->first->funcionario->jid.'/cb/render/gerente']); | |
119 | + $c->model('SOAP::CB::Gerente')->render_gerente | |
120 | + ({ %$local, %$guiches, %$encaminhamentos }); | |
121 | + $c->stash->{soap}->compile_return($old); | |
122 | + }); | |
111 | 123 | } |
112 | 124 | |
113 | 125 | ... | ... |