Troubleshooting algorand indexer

Hi guys, i am trying to have algorand indexer in k8s in HA mode…

I have postgresql in HA mode

So if i turn 3 instances of algorand indexer connected to the same database, I assume that all 3 instances are trying to get sync with the algod server, and only one succeed to insert the block…

However when they try to insert the block and do not succeed they crash

{"error":"AddBlock() err: TxWithRetry() err: attemptTx() err: AddBlock() adding block round 19152593 but next round to account is 19152594","level":"error","msg":"adding block 19152593 to database failed","time":"2022-01-15T11:41:31Z"}

Is there any way how i can turn some indexers just to do the query part to the database and not trying to sync with the algod server? i think that might solve the issue… or perhaps if anybody already resolved the TxWithRetry crash before, can he share his insides please?

Indexer v 2.8.0 built with AlgorandNodes/compose-indexer-stable.yaml at main · scholtz/AlgorandNodes · GitHub

Yes, you can have one indexer instance writing and as many as you want reading the database.
Just use the argument --no-algod instead of providing an algod URL/token.

As you discovered, you cannot have multiple indexers writing.

Should you need it, the documentation for setting up a read-only indexer instance is here: GitHub - algorand/indexer: searchable history and current state

i have setup the indexer in 3 instances in read only mode

however, when i run write instance in single mode, it still fails at

{"error":"AddBlock() err: TxWithRetry() err: attemptTx() err: AddBlock() adding block round 19152593 but next round to account is 19152594","level":"error","msg":"adding block 19152593 to database failed","time":"2022-01-15T11:41:31Z"}

this is causing the indexer to be out of sync very often… any idea how to prevent this error?

the most stable solution for me is to run 2 indexers in write mode, and watch if port 8980 is open every second or so

Which version are you using?

Using configuration file: /app/indexer.yaml
2.8.0 compiled at 2021-11-29T16:42:46+0000 from git hash 06e7ca8eec01f907474a50cc2072581c0e662ccb