baking-bad/tzkt

TzKt connected to local flextesa returns the wrong Head info

ac10n opened this issue · 3 comments

ac10n commented

I have connected TzKt to a local FlexTesa sandbox.
The local sandbox is at level 3000, but TzKt returns this for /v1/head:

{
  "chain": "private",
  "chainId": "NetXmGq7LPFBoxA",
  "cycle": 6,
  "level": 52,
  "hash": "BKrUrKmYYByPobctsS7WYYEJZqtmSXY5AA7nkzTjQA2tNqkoDxT",
  "protocol": "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK",
  "nextProtocol": "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK",
  "timestamp": "2022-08-17T23:31:22Z",
  "votingEpoch": 3,
  "votingPeriod": 3,
  "knownLevel": 52,
  "lastSync": "2022-08-17T16:31:22Z",
  "synced": true,
  "quoteLevel": 52,
  "quoteBtc": 0.00008064180433753636,
  "quoteEur": 1.848423050861913,
  "quoteUsd": 1.8808259198083772,
  "quoteCny": 12.753880562220555,
  "quoteJpy": 254.14848324002614,
  "quoteKrw": 2472.9213754747293,
  "quoteEth": 0.0010261347976775258,
  "quoteGbp": 1.5616290721317734
}

When looking at the database, I see that all blocks are indexed and new blocks keep getting indexed. Same is evident from TzKt.Sync logs.

What can be the cause of this behaviour?

ac10n commented

Restarting TzKt.Api fixes this for a moment, but then it stays at that level again and does not go up.

That's due to some issues with DB triggers (in particular, state_hash_changed), which are used for revalidating API cache. So, that may happen when either the DB doesn't have necessary triggers for some reason or the API fails to connect and listen the triggers.

So, first of all, check the API logs, if there are any error messages. Then make sure the triggers are not missed (execute select tgenabled from pg_trigger where tgname='state_hash_changed'; - this shoud return O).

Please, let me know the results.

ac10n commented

Thank you @Groxan
The problem was that I had re-created the migrations and the triggers were missing. Closing.