baking-bad / tzkt

😼 Awesome Tezos blockchain indexer and API
https://tzkt.io
MIT License
183 stars 35 forks source link

Failed to initialize database when running indexer for testnet #31

Closed hai-nguyen-van closed 3 years ago

hai-nguyen-van commented 3 years ago

I am trying to run the indexer for delphinet as explained at this step. However, I am stuck at this error. I don't understand the error message:

$ dotnet Tzkt.Sync.dll
info: Tzkt.Sync.Program[0]
      Initialize database
crit: Tzkt.Sync.Program[0]
      Failed to initialize database: Resource temporarily unavailable
Unhandled exception. System.Net.Internals.SocketExceptionFactory+ExtendedSocketException (00000001, 11): Resource temporarily unavailable
   at System.Net.Dns.InternalGetHostByName(String hostName)
   at System.Net.Dns.GetHostAddresses(String hostNameOrAddress)
   at Npgsql.NpgsqlConnector.Connect(NpgsqlTimeout timeout)
   at Npgsql.NpgsqlConnector.RawOpen(NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken)
   at Npgsql.NpgsqlConnector.Open(NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken)
   at Npgsql.NpgsqlConnection.<>c__DisplayClass32_0.<<Open>g__OpenLong|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Npgsql.NpgsqlConnection.Open()
   at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlDatabaseCreator.Exists()
   at Microsoft.EntityFrameworkCore.Migrations.HistoryRepository.Exists()
   at Microsoft.EntityFrameworkCore.Migrations.HistoryRepository.GetAppliedMigrations()
   at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.GetAppliedMigrations(DatabaseFacade databaseFacade)
   at Tzkt.Sync.IHostExt.Init(IHost host, Int32 attempt) in /home/nguyen-van/tzkt/Tzkt.Sync/Program.cs:line 60
   at Tzkt.Sync.IHostExt.Init(IHost host, Int32 attempt) in /home/nguyen-van/tzkt/Tzkt.Sync/Program.cs:line 83
   at Tzkt.Sync.IHostExt.Init(IHost host, Int32 attempt) in /home/nguyen-van/tzkt/Tzkt.Sync/Program.cs:line 83
   at Tzkt.Sync.IHostExt.Init(IHost host, Int32 attempt) in /home/nguyen-van/tzkt/Tzkt.Sync/Program.cs:line 83
   at Tzkt.Sync.IHostExt.Init(IHost host, Int32 attempt) in /home/nguyen-van/tzkt/Tzkt.Sync/Program.cs:line 83
   at Tzkt.Sync.IHostExt.Init(IHost host, Int32 attempt) in /home/nguyen-van/tzkt/Tzkt.Sync/Program.cs:line 83
   at Tzkt.Sync.IHostExt.Init(IHost host, Int32 attempt) in /home/nguyen-van/tzkt/Tzkt.Sync/Program.cs:line 83
   at Tzkt.Sync.IHostExt.Init(IHost host, Int32 attempt) in /home/nguyen-van/tzkt/Tzkt.Sync/Program.cs:line 83
   at Tzkt.Sync.IHostExt.Init(IHost host, Int32 attempt) in /home/nguyen-van/tzkt/Tzkt.Sync/Program.cs:line 83
   at Tzkt.Sync.IHostExt.Init(IHost host, Int32 attempt) in /home/nguyen-van/tzkt/Tzkt.Sync/Program.cs:line 83
   at Tzkt.Sync.IHostExt.Init(IHost host, Int32 attempt) in /home/nguyen-van/tzkt/Tzkt.Sync/Program.cs:line 83
   at Tzkt.Sync.Program.Main(String[] args) in /home/nguyen-van/tzkt/Tzkt.Sync/Program.cs:line 20
Aborted (core dumped)

Does this mean that it cannot have access to the database? Or to rpc.tzkt.io/delphinet? Yet, the database is available:

$ nmap -PN localhost
Starting Nmap 7.80 ( https://nmap.org ) at 2020-12-29 12:05 CET
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000068s latency).
Not shown: 998 closed ports
PORT     STATE SERVICE
631/tcp  open  ipp
5432/tcp open  postgresql
Groxan commented 3 years ago

This means that the indexer cannot connect to the database using the connection string you provided. Did you customize the connection string somehow? Also, look at the similar issue https://github.com/npgsql/efcore.pg/issues/619#issuecomment-433383045, and let me know if that helps. You can find allowed connection string parameters here: https://www.npgsql.org/doc/connection-string-parameters.html

Also, try to connect to the database manually via psql with the same user as in the connection string, to make sure the database is available.

hai-nguyen-van commented 3 years ago

My bad! I found the tiny spot of the problem.