Lock de registros
Posted in 2014
Topics: Server Administration
Boa tarde pessoal.
Estou com um problema no ERP Logix (TOTVS).
Determinados programas geram locks em registros, o que é normal, porém mesmo
após a desconexão da sessão o registro permanece em lock.
Alguém sabe uma forma de desalocar esse registro apenas?
A TOTVS enviou a informação abaixo, porém esse procedimento não resolve o
problema.
------------------
Comando para excluir o locked
executar um procedimento muito + rapido que uma query na SYSLOCKS (geralmente
obsoleta).
Primeiramente executamos a seguinte query no dbaccess para obter o partnum
da(s) tabela(s) em hexadecimal:
select tabname, hex(partnum) from systables where tabname = 'frete_sup';
Esta query ira retornar um numero + ou - assim... 0x0010106D, porem podemos
desprezar os 4 primeiros caracteres, neste caso o 0x00, entao teriamos o
numero 10106D.
Entao executamos o comando "onstat -k | grep 10106d", notem que estou
utilizando o numero sem o 0x00 e tambem troquei os caracteres alfanumericos
para MINUSCULO (isso se faz necessario).
Apos a execucao do comando o retorno sera:
Locks
address wtlist owner lklist type tblsnum rowid key#/bsiz
4410ff84 0 51e046f0 0 S 100002 20a 0
A coluna owner é endereco da sessao do usuario que gerou o Lock, sendo assim
executamos "onstat -u | grep 51e046f0" e teremos:
Userthreads
address flags sessid user tty wait tout locks nreads nwrites
51e046f0 Y--P--- 5803 desenv - 528e46b0 0 1 3458 0
Por fim, encerramos a sessao do usuario a partir do sessid retornado (5803)
utilizando o comando "onmode -z 5803".
The problem, Sandro, is that many Windows applications do not properly
shutdown network connections when they exit, especially when the users quit
using the big red "X" button at the top of the application window. Because
of that the database server thinks that the client application is still
active and it is waiting for input from the program. The method that you
have will work. You could use the sysmaster SMI tables to track down the
user session holding the lock and kill the session that way which is easier
to automate. You do not say what version of the engine you are using, but
in v12.10 there is an idle user timeout feature that will automatically
kill sessions that are idle for more than a specified period of time.
A script to do what you want:
#!/bin/ksh
if [[ $# -ne 2 ]]; then
echo $0 database table
exit 1
fi
database=$1
table=$2
dbaccess sysmaster - <<EOF
unload to /tmp/session.$$ delimiter ' '
select owner from syslocks
where dbsname = $database and tabname = $table;EOF
read sid </tmp/session.$$
onmode -z $sid#End of script
For what it is worth, these applications are badly behaved and I would say
badly written. They should only be holding locks for a fraction of a
second at a time so that this situation cannot happen. If you have control
over the applications themselves, they should be rewritten using Optimistic
Locking Protocols.
Art
Art S. Kagel, Principal Consultant
ASK Database Management
Blog: http://informix-myview.blogspot.com/
Disclaimer: Please keep in mind that my own opinions are my own opinions
and do not reflect on the IIUG, nor any other organization with which I am
associated either explicitly, implicitly, or by inference. Neither do
those opinions reflect those of other individuals affiliated with any
entity with which I am affiliated nor those of the entities themselves.
2014-07-31 15:21 GMT-04:00 SANDRO DELAGE <sandrocpd@gmail.com>:
> Boa tarde pessoal.
>
> Estou com um problema no ERP Logix (TOTVS).
> Determinados programas geram locks em registros, o que é normal, porém
> mesmo
> após a desconexão da sessão o registro permanece em lock.
> Alguém sabe uma forma de desalocar esse registro apenas?
>
> A TOTVS enviou a informação abaixo, porém esse procedimento não resolve o
> problema.
> ------------------
>
> Comando para excluir o locked
>
> executar um procedimento muito + rapido que uma query na SYSLOCKS
> (geralmente
> obsoleta).
>
> Primeiramente executamos a seguinte query no dbaccess para obter o partnum
> da(s) tabela(s) em hexadecimal:
>
> select tabname, hex(partnum) from systables where tabname = 'frete_sup';>
> Esta query ira retornar um numero + ou - assim... 0x0010106D, porem podemos
> desprezar os 4 primeiros caracteres, neste caso o 0x00, entao teriamos o
> numero 10106D.
>
> Entao executamos o comando "onstat -k | grep 10106d", notem que estou
> utilizando o numero sem o 0x00 e tambem troquei os caracteres alfanumericos
> para MINUSCULO (isso se faz necessario).
>
> Apos a execucao do comando o retorno sera:
>
> Locks
> address wtlist owner lklist type tblsnum rowid key#/bsiz
> 4410ff84 0 51e046f0 0 S 100002 20a 0
>
> A coluna owner é endereco da sessao do usuario que gerou o Lock, sendo
> assim
> executamos "onstat -u | grep 51e046f0" e teremos:
>
> Userthreads
> address flags sessid user tty wait tout locks nreads nwrites
> 51e046f0 Y--P--- 5803 desenv - 528e46b0 0 1 3458 0
>
> Por fim, encerramos a sessao do usuario a partir do sessid retornado (5803)
> utilizando o comando "onmode -z 5803".
>
>
>
>
*******************************************************************************
> Forum Note: Use "Reply" to post a response in the discussion forum.
>
>
--089e0158ab625c5b7d04ff82b7f2
Related threads
- record locked
- who locks a record?
- Regarding Non-Default Page Sizes
- Don't Understand Table's Space Requirement