Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM General » View Thread |
Messages 1 to 10 of 11 total |
Corrupted Table |
Fri, Mar 14 2008 10:19 AM | Permanent Link |
Mauricio Campana Nonino | Tim Young,
I have developed a new software using DBIsam (4.25 Build 5). Currently only one customer is using this software in FS mode with a multi-user environment. I am having a strange problem: at least once a week I have to repair a specific table. The log of "RepairTable" returns "Index does not match record data and are invalid". After repairing, the indexes are fixed. I don't understand why it gets corrupted. The application has more than 80 tables, but just one is affected. There is no power outages or loss of network connectivity. The only difference with the other tables is that the application constantly deletes a group of records and inserts new ones. Could you take a look in the table and try to find out something, please? I have posted the problematic table in "Binary Posts". Thanks, Mauricio Campana Nonino Nonino Software |
Fri, Mar 14 2008 3:52 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Mauricio,
<< I have developed a new software using DBIsam (4.25 Build 5). Currently only one customer is using this software in FS mode with a multi-user environment. I am having a strange problem: at least once a week I have to repair a specific table. The log of "RepairTable" returns "Index does not match record data and are invalid". After repairing, the indexes are fixed. I don't understand why it gets corrupted. The application has more than 80 tables, but just one is affected. There is no power outages or loss of network connectivity. The only difference with the other tables is that the application constantly deletes a group of records and inserts new ones. Could you take a look in the table and try to find out something, please? I have posted the problematic table in "Binary Posts". >> The table doesn't tell me much, unfortunately. Can you get the corruption to occur if you run the application in a test environment ? If not, could you at least send me the code that performs the deletion/insertion ? -- Tim Young Elevate Software www.elevatesoft.com |
Fri, Mar 14 2008 5:30 PM | Permanent Link |
Mauricio Campana Nonino | Tim Young,
<<Can you get the corruption to occur if you run the application in a test environment ? >> I've tried to replicate the problem, but with no success. << If not, could you at least send me the code that performs the deletion/insertion ?>> Sure. Here is the code: function NSImprimirVendaItemCupomFiscal(vCodigo,vDescricao,vAliquota:string; vQtd:Double; vValorUnitario:Currency; vDesconto:Double; vValorUnitarioOriginal:currency):Boolean; var vTabelas:TStringList; begin Result:=true; vTabelas:=TStringList.Create; vTabelas.Add(FormTabelas.TabItensCF.TableName); try FormTabelas.DBSagres.StartTransaction(vTabelas); FormTabelas.TabItensCF.Refresh; if vOrdemItemCF=0 then begin FormTabelas.TabItensCF.IndexName:='Por Ordem'; FormTabelas.TabItensCF.FindKey([FiscalImpCFGuidId]); while (not FormTabelas.TabItensCF.EOF) and (FormTabelas.TabItensCFImpCFGuidId.Value=FiscalImpCFGuidId) do begin FormTabelas.TabItensCF.Delete; end; end; FormTabelas.TabItensCF.Append; FormTabelas.TabItensCFImpCFGuidId.Value:=FiscalImpCFGuidId; inc(vOrdemItemCF); FormTabelas.TabItensCFOrdem.Value:=vOrdemItemCF; FormTabelas.TabItensCFCodProduto.Value:=Trim(vCodigo); FormTabelas.TabItensCFAliquotaId.Value:=vStrAliquota; FormTabelas.TabItensCFQtd.Value:=vQtd; FormTabelas.TabItensCFValor.Value:=vTotValor; FormTabelas.TabItensCFValorDesc.Value:=vValorDesconto; FormTabelas.TabItensCFData.Value:=vData; FormTabelas.TabItensCF.Post; FormTabelas.DBSagres.Commit; except on e:exception do begin Result:=false; if FormTabelas.DBSagres.InTransaction then FormTabelas.DBSagres.Rollback; if FormTabelas.TabItensCF.State in [dsEdit,dsInsert] then FormTabelas.TabItensCF.Cancel; FormTabelas.TabItensCF.Refresh; SysUtils.Beep; ShowMessage('Ocorreu um erro inesperado na gravação dos dados!'+#13+'('+e.Message+')'); end end; vTabelas.Clear; vTabelas.Free; end; FiscalImpCFGuidId and vOrdemItemCF are global variables. An example could be something like this: FiscalImpCFGuidId:=RetImpCFGuidId; vOrdemItemCF:=0; NSImprimirVendaItemCupomFiscal('0100','Test 1','T01',1,15.45,0,15.45); NSImprimirVendaItemCupomFiscal('0105','Test 2','T01',1,11.99,0,11.99); Mauricio Campana Nonino Nonino Software |
Fri, Mar 14 2008 11:18 PM | Permanent Link |
"Gregory Sebastian" | Hi Mauricio,
I couldn't find anything seriously wrong with the code. The only thing that you could consider with regards to the code is perhaps : 1. FormTabelas.TabItensCF.FindKey([FiscalImpCFGuidId]); to replace with FormTabelas.TabItensCF.SetRange([FiscalImpCFGuidId], [FiscalImpCFGuidId]); instead and CancelRange after the Delete. But I don't think this will help much with the corruption. 2. Also if the table is connected to data aware controls, and deleting a number of records, you can also enclose in table DisableControls & EnableControls. 3. vTabelas:=TStringList.Create; & vTabelas.Clear; vTabelas.Free; could preferrably be within a try finally end block Do you have any before/after post, insert or delete event handlers for this table ? I'm guessing that the problem could be at the users enviroment. It could be some 3rd party software. Have you tried temporarily disabling the Anti Virus or 3rd party firewall ? That might help troubleshoot and rule out that possibility. Regards Gregory Sebastian "Mauricio Campana Nonino" <nonino@sercomtel.com.br> wrote in message news:8F9EE8A5-47D3-40A8-962C-E21F4E99E3EF@news.elevatesoft.com... > Tim Young, > > <<Can you get the corruption to occur if you run the application in a test > environment ? >> > I've tried to replicate the problem, but with no success. > > << If not, could you at least send me the code that performs the > deletion/insertion ?>> > Sure. Here is the code: > > function > NSImprimirVendaItemCupomFiscal(vCodigo,vDescricao,vAliquota:string; > vQtd:Double; > > vValorUnitario:Currency; > > vDesconto:Double; > > vValorUnitarioOriginal:currency):Boolean; > var > vTabelas:TStringList; > begin > Result:=true; > vTabelas:=TStringList.Create; > vTabelas.Add(FormTabelas.TabItensCF.TableName); > try > FormTabelas.DBSagres.StartTransaction(vTabelas); > FormTabelas.TabItensCF.Refresh; > > if vOrdemItemCF=0 then begin > FormTabelas.TabItensCF.IndexName:='Por Ordem'; > FormTabelas.TabItensCF.FindKey([FiscalImpCFGuidId]); > while (not FormTabelas.TabItensCF.EOF) and > (FormTabelas.TabItensCFImpCFGuidId.Value=FiscalImpCFGuidId) do begin > FormTabelas.TabItensCF.Delete; > end; > end; > > FormTabelas.TabItensCF.Append; > FormTabelas.TabItensCFImpCFGuidId.Value:=FiscalImpCFGuidId; > inc(vOrdemItemCF); > FormTabelas.TabItensCFOrdem.Value:=vOrdemItemCF; > FormTabelas.TabItensCFCodProduto.Value:=Trim(vCodigo); > FormTabelas.TabItensCFAliquotaId.Value:=vStrAliquota; > FormTabelas.TabItensCFQtd.Value:=vQtd; > FormTabelas.TabItensCFValor.Value:=vTotValor; > FormTabelas.TabItensCFValorDesc.Value:=vValorDesconto; > FormTabelas.TabItensCFData.Value:=vData; > FormTabelas.TabItensCF.Post; > FormTabelas.DBSagres.Commit; > except > on e:exception do begin > Result:=false; > if FormTabelas.DBSagres.InTransaction then > FormTabelas.DBSagres.Rollback; > if FormTabelas.TabItensCF.State in [dsEdit,dsInsert] then > FormTabelas.TabItensCF.Cancel; > FormTabelas.TabItensCF.Refresh; > SysUtils.Beep; > ShowMessage('Ocorreu um erro inesperado na gravação dos > dados!'+#13+'('+e.Message+')'); > end > end; > vTabelas.Clear; > vTabelas.Free; > end; > > FiscalImpCFGuidId and vOrdemItemCF are global variables. An example could > be something like this: > > FiscalImpCFGuidId:=RetImpCFGuidId; > vOrdemItemCF:=0; > NSImprimirVendaItemCupomFiscal('0100','Test 1','T01',1,15.45,0,15.45); > NSImprimirVendaItemCupomFiscal('0105','Test 2','T01',1,11.99,0,11.99); > > > Mauricio Campana Nonino > Nonino Software > |
Tue, Mar 18 2008 11:35 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Mauricio,
<< Sure. Here is the code: >> So, the entire operation occurs within a transaction ? If so, then that makes it very weird, since no other users can cause any change detection, etc. to occur while the transaction is in progress. In other words, the user executing the transaction acts like they're the only person accessing the tables at that time. Are you using TDBISAMEngine.LargeFileSupport=True at all ? It sounds like perhaps you've got different LargeFileSupport settings for different users, which can cause each user to not see the other user's locks. -- Tim Young Elevate Software www.elevatesoft.com |
Tue, Mar 18 2008 1:01 PM | Permanent Link |
Mauricio Campana Nonino | Tim Young,
>>So, the entire operation occurs within a transaction ? Yes. >>Are you using TDBISAMEngine.LargeFileSupport=True at all ? No. >>If so, then that makes it very weird, Yes, it is very weird. I use this kind of code everywhere in my application, and that piece of code is the only one that is causing us problem. The major difference here is that I am deleting a couple of records before inserting other ones. I have the following code in all TDBIsamTable.OnEditError event: if (E is EDBISAMEngineError) and (EDBISAMEngineError(E).ErrorCode = DBISAM_KEYORRECDELETED) and (not TDBISAMTable(DataSet).RecordIsLocked) then begin ID1 := DataSet.GetBookmark; DataSet.Refresh; ID2 := DataSet.GetBookmark; if DataSet.CompareBookmarks(ID1, ID2) = 0 then Action := daRetry else begin MessageDlg('Este registro foi excluído ou teve sua chave primária alterada!', mtError, [mbOK], 0); Action := daAbort; end; DataSet.FreeBookmark(ID1); DataSet.FreeBookmark(ID2); end else begin MessageDlg(E.Message, mtError, [mbOK], 0); Action := daAbort; end; Should I have a similar code to "OnDeleteError" event? Mauricio Campana Nonino Nonino Software |
Tue, Mar 18 2008 1:05 PM | Permanent Link |
Mauricio Campana Nonino | Gregory Sebastian,
Thanks for your interest. >>I'm guessing that the problem could be at the users enviroment. Yes, It is a possibility. But I think the problem is related with the records being deleted before inserting new ones. Mauricio Campana Nonino Nonino Software |
Tue, Mar 18 2008 5:01 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Mauricio,
<< Yes, it is very weird. I use this kind of code everywhere in my application, and that piece of code is the only one that is causing us problem. The major difference here is that I am deleting a couple of records before inserting other ones. I have the following code in all TDBIsamTable.OnEditError event: >> Do you know if the OnEditError is actually getting triggered at all ? << Should I have a similar code to "OnDeleteError" event? >> It wouldn't hurt, since it's possible that it might be needed there also. -- Tim Young Elevate Software www.elevatesoft.com |
Wed, Mar 19 2008 7:31 AM | Permanent Link |
Mauricio Campana Nonino | Tim Young,
<<Do you know if the OnEditError is actually getting triggered at all ?>> I can't say for sure. <<It wouldn't hurt, since it's possible that it might be needed there also.>> I will try. Thanks, Mauricio Campana Nonino Nonino Software |
Fri, May 16 2008 9:44 AM | Permanent Link |
Mauricio Campana Nonino | Tim Young,
Just an update of the occurrence: the customer changed the hardware (server and workstations) and the problem did not come back again. One another thing that was changed is that it used Vmware. Therefore, hardware or Vmware was probably the responsible ones for the situation. Thanks, Mauricio Campana Nonino Nonino Software |
Page 1 of 2 | Next Page » | |
Jump to Page: 1 2 |
This web page was last updated on Thursday, March 28, 2024 at 06:05 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |