MySQL Forums
Forum List  »  Portuguese

Lock table Timeout - Alguma Luz PFF
Posted by: Carlos Godinho
Date: February 26, 2009 04:41AM

Boas ...
Chamo-me Carlos Godinho e estou desenvolvendo uma aplicação em VB6 que faz integração com o MYSQL.

A ligação VB/MySql é feita via a dll VBMySQLDirect.dll (http://www.vbmysql.com/projects/vbmysqldirect).

A versão do MySql é a 4.1.21

Pois bem depois de já ter esgotado todas as alternativas, e ter pesquisado venho junto de vós solicitar alguma luz sobre o assunto:

O código em questão é o seguinte:

(...)


' Mysql = "SELECT tbl_tq_read.qualification_id as qualification_id,valid_period_months "
' Mysql = Mysql & "FROM tbl_aircraft_type tbl_at_read, tbl_qualification tbl_tq_read, "
' Mysql = Mysql & "tbl_users_has_tbl_qualification tbl_utblq_read "
' Mysql = Mysql & "WHERE air_type_ID = '" & airtype & "' AND "
' Mysql = Mysql & "tbl_at_read.qualification_id = tbl_tq_read.qualification_id And "
' Mysql = Mysql & "tbl_utblq_read.qualification_id_FK=tbl_tq_read.qualification_id "
' Mysql = Mysql & "and callsign_fk = '" & txtPilot & "' FOR UPDATE"
'
' Set pRs = gCnn.Execute(Mysql)
'
' If pRs.RecordCount > 0 Then
'
' Mysql = "Update tbl_users_has_tbl_qualification as tbl_utblq_write set "
' Mysql = Mysql & "start_dte = now(),"
' Mysql = Mysql & "end_dte = DATE_ADD(now(),INTERVAL " & pRs.Fields("valid_period_months") & " month),"
' Mysql = Mysql & "lst_user_change ='" & UCase(txtPilot.Text) & "',"
' Mysql = Mysql & "lst_dte_change = now() "
' Mysql = Mysql & "where qualification_id_FK = " & pRs.Fields("qualification_id")
' Mysql = Mysql & " and callsign_fk = '" & txtPilot & "'"
'
' gCnn.Execute Mysql, RowsAffected
'
' If RowsAffected = 0 Then
'
' gCnn.RollbackTrans
' Error = True
'
' End If
'
' End If
'
' If Not Error Then
'
' Mysql = "SELECT tbl_tq_read.qualification_id as qualification_id,valid_period_months "
' Mysql = Mysql & "FROM tbl_qualification_has_tbl_iata_icao tblqtbliataicao_read, "
' Mysql = Mysql & "tbl_qualification tbl_tq_read, "
' Mysql = Mysql & "tbl_users_has_tbl_qualification tbl_utblq_read "
' Mysql = Mysql & "WHERE icao_dest_FK in('" & Alt_Airport(0) & "','" & Alt_Airport(1) & "') and "
' Mysql = Mysql & "tblqtbliataicao_read.qualification_id_FK=tbl_tq_read.qualification_id AND "
' Mysql = Mysql & "tbl_utblq_read.qualification_id_FK=tbl_tq_read.qualification_id "
' Mysql = Mysql & " and callsign_fk = '" & txtPilot & "' FOR UPDATE"
'
' Set pRs = gCnn.Execute(Mysql)
'
' If pRs.RecordCount > 0 Then
'
' Mysql = "Update tbl_users_has_tbl_qualification set "
' Mysql = Mysql & "start_dte = now(),"
' Mysql = Mysql & "end_dte = DATE_ADD(now(),INTERVAL " & pRs.Fields("valid_period_months") & " month),"
' Mysql = Mysql & "lst_user_change ='" & UCase(txtPilot.Text) & "',"
' Mysql = Mysql & "lst_dte_change = now() "
' Mysql = Mysql & "where qualification_id_FK = " & pRs.Fields("qualification_id")
' Mysql = Mysql & " and callsign_fk = '" & txtPilot & "'"
'
' gCnn.Execute Mysql, RowsAffected
'
' If RowsAffected = 0 Then
'
' gCnn.RollbackTrans
' Error = True
'
' End If
'
' End If
'
' End If
'
If Not Error Then

gCnn.CommitTrans

Else

MsgBox "Error sending log" & Chr(13) & "Error:" & gCnn.Error.Number & " - " & gCnn.Error.Description, vbCritical, "Error"

End If

(...)

Embora não esteja descrito aqui a transacção é aberta.
Quando faço o select a tabela tbl_users_has_tbl_qualification fica bloqueada, falhando assim o update.

Se só fizer o update tudo na boa, a questão mesmo é que necessito de fazer o select para depois passar os valores resultantes do recordset para o update.
Mesmo sacando o conteudo da string Mysql com o Update e botando no query browser dá erro de time out e todo o processo no Mysql que utiliza a referida tabela borraga.

Já exprimentei, select for update, select with locks ...

Gostaria da vossa opinião sobre esta matéria, porque é que acontece o bloqueio de uma tabela com um select, como prevenir uma situação destas ...

Alguma ideia ????

Muito obrigado ...

Cmp.

Carlos Godinho

Options: ReplyQuote


Subject
Views
Written By
Posted
Lock table Timeout - Alguma Luz PFF
6364
February 26, 2009 04:41AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.