hb_cdxPageSeekKey how to intercept this error

hb_cdxPageSeekKey how to intercept this error

Postby MarcoBoschi » Wed Oct 18, 2023 4:04 pm

Hi to all!
I'd like to intercept this error (see subject) in fact it is different
from other kinds of error that I find in error.log.

I have a question: How can I create a little prg that during execution go into
this error in order to study the way to intercept it and for instance perform
a reindex or simply try write a personlized error.log?

it's painful when it happens

marco
User avatar
MarcoBoschi
 
Posts: 1015
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: hb_cdxPageSeekKey how to intercept this error

Postby cnavarro » Wed Oct 18, 2023 4:11 pm

Would it be possible for you to attach the error obtained in this topic?
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6500
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: hb_cdxPageSeekKey how to intercept this error

Postby MarcoBoschi » Wed Oct 18, 2023 4:20 pm

no the error is a dialog
When I close the dialog
the program stops to run
ad no trace remains
User avatar
MarcoBoschi
 
Posts: 1015
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: hb_cdxPageSeekKey how to intercept this error

Postby Antonio Linares » Wed Oct 18, 2023 4:36 pm

Dear Marco,

try to reindex

You can always use a modified error handler:

SetErrorhandler( { | oError | ... } )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: hb_cdxPageSeekKey how to intercept this error

Postby karinha » Wed Oct 18, 2023 5:02 pm

Show how you INDEX and OPENING the.CDX FILES, please.

Muestre cómo está INDEXANDO y ABRIENDO los ARCHIVOS.CDX, por favor.

Gracias, thanks.

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7213
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: hb_cdxPageSeekKey how to intercept this error

Postby MarcoBoschi » Thu Oct 19, 2023 6:59 am

Dear all,
I open as usual dbf and cdx

SELECT 0
USE customer
SET INDEX TO customer

it rarely happens but when it happens a visual dialog opens even if the program is a console type
and there is no way for me to understand procname() procline and table

For this reason, how can I simulate with an ad hoc program a corruption of an index that sends the program into that error?
When one of my programs goes into error I usually read customized error files and I can often manage the error automatically.
But this error is blocking and when I open the dialog I don't know anything about what happened
Have a nice day
Marco
User avatar
MarcoBoschi
 
Posts: 1015
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: hb_cdxPageSeekKey how to intercept this error

Postby paquitohm » Thu Oct 19, 2023 7:34 am

Hi,

1st. Please show your hb_out.log last trace error


2st. My index corrupted test, used at init critical processes
To use: lCompruebaIndice("Customer")

Code: Select all  Expand view
//-------------------------------------------------------------------------//
// Poner este control antes de empezar los procesos.
FUNCTION lCompruebaIndiceTabla(cAlias)
Local a:= SEntorno({cAlias})
Local nI
Local lOk:= .t.
Local cOrdKey, cIndexKey, lClave, bIndexKey
Local nJ, nFCount
Local oRet        
*
IF Empty(cAlias)
   MERROR_("Necesario el alias !!", cAlias)
   RETURN .F.
ENDIF
*
*

   SELECT (cAlias)
   nFCount:= FCount()
   bIndexKey:= bCOMPILA( IndexKey(0) )
   *
   // Comprueba 2 registros: uno nuevo y uno existente.
   Add_Rec(0)
   FOR nI:= 1 TO 2

      *
      *
      *
      *
      *
      *
      // PRIMERO. Comprueba que las operaciones de a¤adir y replace funcionen
      Rec_Lock(0)
         FOR nJ:= 1 TO Min(6, nFCount)
            FieldPut(nJ, FieldGet(nJ))
         NEXT
         COMMIT
         IF nI == 1
            DELETE
         ENDIF
      UNLOCK
      *
      *
      *
      // SEGUNDO. Comprueba que la clave se corresponda
      cOrdKey:= OrdKeyVal()
      cIndexKey:= ""
      lClave:= cOrdKey != NIL
      IF lClave
         cIndexKey:= Eval(bIndexKey)
         *
         // El left para por las claves
         // super grandes y el maximo es 250.
         IF ValType(cOrdKey) == "C"
            IF Len(cIndexKey) >= 250
               lClave:= Left(cIndexKey, Len(cOrdKey)) == cOrdKey
            ELSE
               lClave:= cIndexKey == cOrdKey
            ENDIF
         ELSE
            lClave:= cIndexKey == cOrdKey
         ENDIF
      ENDIF
      IF !lClave
         lOk:= .f.
         EXIT
      ENDIF
      *
      *
      *
      *
      *
      *
      // Compruebo un registro con datos de los ultimos
      SKIP -5
      IF Bof()
         EXIT
      ENDIF
   NEXT
   *
   // Comprueba con SEEK todos los indices del alias actual
   oRet:= oCompruebaIndicesYClaves()
   IF !oRet:lOk
      lOk:= .f.
   ENDIF
   *

*
*
REntorno(a)
RETURN lOk
*
*
//-------------------------------------------------------------------------//
// Esto puede dar positivo (error) en un entorno compartido donde
// otros usuarios estan añadiendo registros en el momento de comprobar,
// especialmente si otro usuario esta añadiendo registros masivamente
STATIC FUNCTION oCompruebaIndicesYClaves()
Local cAlias:= Alias()
Local a:= SEntorno({cAlias})
Local nItem, nJ
Local xClave
Local lOk:= .t.
Local nSitio
Local oRet
*
SELECT (cAlias)
*
FOR nItem:= 1 TO 40        // H-V
   SET ORDER TO (nItem)
   IF IndexOrd() != nItem
      EXIT                 // No hay mas indices
   ENDIF
   *
   GO BOTTOM
   SKIP -20     // Comprueba los ultimos 20 registros
   DO WHILE !Eof()
      nSitio:= Recno()
      xClave:= & ( IndexKey(0) )
      SEEK xClave  // Debe encontrar la clave actual o una anterior igual
      IF Eof()
         lOk:= .f.
         EXIT
      ENDIF
      GO nSitio
      SKIP
   ENDDO
   *
   IF !lOk
      FLOGMSG_("Error !! Indice incorrecto !!", Alias(), dbInfo(10), IndexKey(0), IndexOrd(), OrdBagName(nItem), OrdName(), xClave)
      EXIT
   ENDIF
NEXT
*
oRet:= ClassVarRapida({"lOk", "cAlias", "cFullFile", "cIndexKey", "xClave"})
oRet:lOk:= lOk
oRet:cAlias:= Alias()
oRet:cFullFile:= dbInfo(10)
IF !lOk
   oRet:cIndexKey:= IndexKey(0)
   oRet:xClave:= xClave
ENDIF
*
REntorno(a)
RETURN oRet
*
*


Regards
paquitohm
 
Posts: 108
Joined: Fri Jan 14, 2022 8:37 am

Re: hb_cdxPageSeekKey how to intercept this error

Postby MarcoBoschi » Thu Oct 19, 2023 9:19 am

I don't have hb_out.log Im' sorry

will there be a way to simulate and fail with that type of error? and then because a dialog appears even if the program is console program
User avatar
MarcoBoschi
 
Posts: 1015
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: hb_cdxPageSeekKey how to intercept this error

Postby Antonio Linares » Thu Oct 19, 2023 10:39 am

Dear Marco,

In Harbour source code we have this:
Code: Select all  Expand view
  if( ! fLeaf )
   {
      hb_cdxPageGetChild( pPage );
#ifdef HB_CDX_DBGCODE
      if( memcmp( hb_cdxPageGetKeyVal( pPage, pPage->iCurKey ),
                  hb_cdxPageGetKeyVal( pPage->Child, pPage->Child->iKeys - 1 ),
                  pPage->TagParent->uiLen ) != 0 ||
          hb_cdxPageGetKeyRec( pPage, pPage->iCurKey ) !=
          hb_cdxPageGetKeyRec( pPage->Child, pPage->Child->iKeys - 1 ) )
      {
         fprintf( stderr, "\r\nkeyLen=%u", pPage->TagParent->uiLen );
         fprintf( stderr, "\r\nparent=%lx, iKey=%d, rec=%lu", pPage->Page, pPage->iCurKey, hb_cdxPageGetKeyRec( pPage, pPage->iCurKey ) );
         fprintf( stderr, "\r\n child=%lx, iKey=%d, rec=%lu", pPage->Child->Page, pPage->Child->iKeys - 1, hb_cdxPageGetKeyRec( pPage->Child, pPage->Child->iKeys - 1 ) );
         fprintf( stderr, "\r\nparent val=[%s]", hb_cdxPageGetKeyVal( pPage, pPage->iCurKey ) );
         fprintf( stderr, "\r\n child val=[%s]", hb_cdxPageGetKeyVal( pPage->Child, pPage->Child->iKeys - 1 ) );
         fflush( stderr );
         hb_cdxErrInternal( "hb_cdxPageSeekKey: wrong parent key." );
      }
#endif
      k = hb_cdxPageSeekKey( pPage->Child, pKey, ulKeyRec );
   }
 

and hb_cdxErrInternal() has this code:
Code: Select all  Expand view
static void hb_cdxErrInternal( const char * szMsg )
{
   hb_errInternal( 9201, szMsg ? szMsg : "hb_cdxErrInternal: data integrity error.", NULL, NULL );
}
 

You can modify it to force the error. What exactly is what you want to avoid ? Please provide a screenshot
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: hb_cdxPageSeekKey how to intercept this error

Postby MarcoBoschi » Thu Oct 19, 2023 1:03 pm

Antonio,
next time it happens I provide screenshot.
1) I create a screenshot
1) I save dbf+fpt+cdx
2) reindex
4) restart app
5) post in this forum the screenshot

Many thanks to all
User avatar
MarcoBoschi
 
Posts: 1015
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: hb_cdxPageSeekKey how to intercept this error

Postby MarcoBoschi » Tue Mar 12, 2024 12:04 pm

Antonio,
It happens another time
Image
http://www.marcoboschi.it/public/cattura.jpg

This dialog appears if I use emagdbu or if I use a console program
Have a nice day
User avatar
MarcoBoschi
 
Posts: 1015
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: hb_cdxPageSeekKey how to intercept this error

Postby karinha » Tue Mar 12, 2024 1:13 pm

MarcoBoschi wrote:Antonio,
It happens another time
Image
http://www.marcoboschi.it/public/cattura.jpg

This dialog appears if I use emagdbu or if I use a console program
Have a nice day


Good morning Marcos, did you download EMAGDBU.exe from this link? AVG anti virus is reporting problems with the executable.

Buenos días Marcos, ¿descargaste EMAGDBU.exe desde este enlace? El antivirus AVG informa problemas con el ejecutable.

https://www.emagsoftware.it/Download.asp

Gracias, tks.

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7213
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: hb_cdxPageSeekKey how to intercept this error

Postby MarcoBoschi » Tue Mar 12, 2024 1:35 pm

I don't remember I'm sorry
User avatar
MarcoBoschi
 
Posts: 1015
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: hb_cdxPageSeekKey how to intercept this error

Postby karinha » Tue Mar 12, 2024 1:52 pm

MarcoBoschi wrote:I don't remember I'm sorry


Marcos, I downloaded this link from this link, and this version of EMAGDBU.exe is working fine. Please test it as DBU2.exe.

Marcos, descargué desde este Link y desde este link esta versión de EMAGDBU.exe está funcionando bien. Pruébelo como DBU2.exe.

https://linguagemclipper.com.br/content/dbu-para-windows#google_vignette

Gracias, tks.

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7213
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: hb_cdxPageSeekKey how to intercept this error

Postby Enrico Maria Giordano » Tue Mar 12, 2024 2:48 pm

karinha wrote:Good morning Marcos, did you download EMAGDBU.exe from this link? AVG anti virus is reporting problems with the executable.

Buenos días Marcos, ¿descargaste EMAGDBU.exe desde este enlace? El antivirus AVG informa problemas con el ejecutable.

https://www.emagsoftware.it/Download.asp


It is a false positive. Anyway, I just update the release to 2.75 (with a little fix to the messagebar tooltips). Please check, although I think that it will receive the same false alert. :-(
User avatar
Enrico Maria Giordano
 
Posts: 8315
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 51 guests