Page 1 of 2

hb_cdxPageSeekKey how to intercept this error

PostPosted: Wed Oct 18, 2023 4:04 pm
by MarcoBoschi
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

Re: hb_cdxPageSeekKey how to intercept this error

PostPosted: Wed Oct 18, 2023 4:11 pm
by cnavarro
Would it be possible for you to attach the error obtained in this topic?

Re: hb_cdxPageSeekKey how to intercept this error

PostPosted: Wed Oct 18, 2023 4:20 pm
by MarcoBoschi
no the error is a dialog
When I close the dialog
the program stops to run
ad no trace remains

Re: hb_cdxPageSeekKey how to intercept this error

PostPosted: Wed Oct 18, 2023 4:36 pm
by Antonio Linares
Dear Marco,

try to reindex

You can always use a modified error handler:

SetErrorhandler( { | oError | ... } )

Re: hb_cdxPageSeekKey how to intercept this error

PostPosted: Wed Oct 18, 2023 5:02 pm
by karinha
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.

Re: hb_cdxPageSeekKey how to intercept this error

PostPosted: Thu Oct 19, 2023 6:59 am
by MarcoBoschi
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

Re: hb_cdxPageSeekKey how to intercept this error

PostPosted: Thu Oct 19, 2023 7:34 am
by paquitohm
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

Re: hb_cdxPageSeekKey how to intercept this error

PostPosted: Thu Oct 19, 2023 9:19 am
by MarcoBoschi
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

Re: hb_cdxPageSeekKey how to intercept this error

PostPosted: Thu Oct 19, 2023 10:39 am
by Antonio Linares
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

Re: hb_cdxPageSeekKey how to intercept this error

PostPosted: Thu Oct 19, 2023 1:03 pm
by MarcoBoschi
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

Re: hb_cdxPageSeekKey how to intercept this error

PostPosted: Tue Mar 12, 2024 12:04 pm
by MarcoBoschi
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

Re: hb_cdxPageSeekKey how to intercept this error

PostPosted: Tue Mar 12, 2024 1:13 pm
by karinha
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.

Re: hb_cdxPageSeekKey how to intercept this error

PostPosted: Tue Mar 12, 2024 1:35 pm
by MarcoBoschi
I don't remember I'm sorry

Re: hb_cdxPageSeekKey how to intercept this error

PostPosted: Tue Mar 12, 2024 1:52 pm
by karinha
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.

Re: hb_cdxPageSeekKey how to intercept this error

PostPosted: Tue Mar 12, 2024 2:48 pm
by Enrico Maria Giordano
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. :-(