opendatadiscovery / odd-platform

First open-source data discovery and observability platform. We make a life for data practitioners easy so you can focus on your business.
https://opendatadiscovery.org
Apache License 2.0
1.21k stars 100 forks source link

The collector always restarts #1563

Closed huashaoxu closed 9 months ago

huashaoxu commented 10 months ago

version: v0.21.0 deploy: docker-compose

The collector always restarts, and the log information is as follows:

SQL State  : 08001
Error Code : 0
Message    : Connection to 127.0.0.1:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.

        at org.flywaydb.core.internal.jdbc.JdbcUtils.openConnection(JdbcUtils.java:60) ~[flyway-core-9.19.4.jar:na]
        at org.flywaydb.core.internal.jdbc.JdbcConnectionFactory.<init>(JdbcConnectionFactory.java:74) ~[flyway-core-9.19.4.jar:na]
        at org.flywaydb.core.FlywayExecutor.execute(FlywayExecutor.java:134) ~[flyway-core-9.19.4.jar:na]
        at org.flywaydb.core.Flyway.migrate(Flyway.java:140) ~[flyway-core-9.19.4.jar:na]
        at org.springframework.boot.autoconfigure.flyway.FlywayMigrationInitializer.afterPropertiesSet(FlywayMigrationInitializer.java:66) ~[spring-boot-autoconfigure-3.1.0.jar:3.1.0]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1816) ~[spring-beans-6.0.9.jar:6.0.9]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1766) ~[spring-beans-6.0.9.jar:6.0.9]
        ... 60 common frames omitted
Caused by: org.postgresql.util.PSQLException: Connection to 127.0.0.1:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
        at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:342) ~[postgresql-42.6.0.jar:42.6.0]
        at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:54) ~[postgresql-42.6.0.jar:42.6.0]
        at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:263) ~[postgresql-42.6.0.jar:42.6.0]
        at org.postgresql.Driver.makeConnection(Driver.java:443) ~[postgresql-42.6.0.jar:42.6.0]
        at org.postgresql.Driver.connect(Driver.java:297) ~[postgresql-42.6.0.jar:42.6.0]
        at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138) ~[HikariCP-5.0.1.jar:na]
        at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:359) ~[HikariCP-5.0.1.jar:na]
        at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:201) ~[HikariCP-5.0.1.jar:na]
        at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:470) ~[HikariCP-5.0.1.jar:na]
        at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561) ~[HikariCP-5.0.1.jar:na]
        at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:100) ~[HikariCP-5.0.1.jar:na]
        at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112) ~[HikariCP-5.0.1.jar:na]
        at org.flywaydb.core.internal.jdbc.JdbcUtils.openConnection(JdbcUtils.java:48) ~[flyway-core-9.19.4.jar:na]
        ... 66 common frames omitted
Caused by: java.net.ConnectException: Connection refused
        at java.base/sun.nio.ch.Net.pollConnect(Native Method) ~[na:na]
        at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:672) ~[na:na]
        at java.base/sun.nio.ch.NioSocketImpl.timedFinishConnect(NioSocketImpl.java:542) ~[na:na]
        at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:597) ~[na:na]
        at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327) ~[na:na]
        at java.base/java.net.Socket.connect(Socket.java:633) ~[na:na]
        at org.postgresql.core.PGStream.createSocket(PGStream.java:243) ~[postgresql-42.6.0.jar:42.6.0]
        at org.postgresql.core.PGStream.<init>(PGStream.java:98) ~[postgresql-42.6.0.jar:42.6.0]
        at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:132) ~[postgresql-42.6.0.jar:42.6.0]
        at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:258) ~[postgresql-42.6.0.jar:42.6.0]
        ... 78 common frames omitted
Vladysl commented 10 months ago

The root cause of the issue, that odd-platform cannot connect to database. You need to start this docker service

database: image: postgres:13.2-alpine restart: always environment:

huashaoxu commented 10 months ago

This is what I did. I have executed the deployment according to the configuration of demo.yaml, and the database has been started and can be accessed normally in navicat. But collect cannot access it normally.

Vladysl commented 10 months ago

This exception was thrown by odd-platform, not by collector. Collector always restarts because odd-platform cannot start and collector trying to reach it. From this exception, I can assume, that smth wrong with your DB. could you please double check, is there postgresql://127.0.0.1:5432/odd-platform DB ?

huashaoxu commented 10 months ago

odd-platform can start normally and can be accessed normally using a web browser. When I used the collector to collect another database, I found that collect was not working properly and always restarted.

Vladysl commented 10 months ago

could you please let me know 1) Do you start. all this in Docker? If yes, could you please share a list of your docker containers ?  2) It is strange that you are trying to access 127.0.0.1:5432 localhost instead of jdbc:postgresql://database:5432/${POSTGRES_DATABASE} 3) Could you please share your docker compose file in case you made some modifications in there ?

huashaoxu commented 10 months ago

docker-compose.yaml:

version: '3.3'
services:
  database:
    image: postgres:13.2-alpine
    restart: always
    env_file: .env
    environment:
      - POSTGRES_USER=${POSTGRES_USER}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - POSTGRES_DATABASE=${POSTGRES_DATABASE}
    ports:
      - 5432:5432
    volumes:
      - odd_platform_db_home:/var/lib/postgresql/data

  odd-platform:
    image: dsatair2023/odd-platform:0.21.0
    restart: always
    environment:
      - SPRING_DATASOURCE_URL=jdbc:postgresql://database:5432/${POSTGRES_DATABASE}
      - SPRING_DATASOURCE_USERNAME=${POSTGRES_USER}
      - SPRING_DATASOURCE_PASSWORD=${POSTGRES_PASSWORD}
    env_file: .env
    ports:
      - 8080:8080

  odd-platform-enricher:
    image: python:3.9.12-alpine3.15
    volumes:
      - ./injector:/injector
      - ./config/injector:/samples
    command:
      - sh
      - ./injector/start.sh
    env_file: .env
    environment:
      - PLATFORM_HOST_URL=${PLATFORM_HOST_URL}
      - PYTHONUNBUFFERED=1
    depends_on:
      - odd-platform

  sample-postgresql:
    image: postgres:13.2-alpine
    restart: always
    env_file: .env
    volumes:
      - ./config/dump.sql:/docker-entrypoint-initdb.d/init.sql
    environment:
      - POSTGRES_USER=${SAMPLE_POSTGRES_USER}
      - POSTGRES_PASSWORD=${SAMPLE_POSTGRES_PASSWORD}
      - POSTGRES_DATABASE=${SAMPLE_POSTGRES_DATABASE}

  odd-collector:
    image: dsatair2023/odd-platform:0.21.0
    restart: always
    env_file: .env
    volumes:
      - ./config/collector_config.yaml:/app/collector_config.yaml
    environment:
      - PLATFORM_HOST_URL=${PLATFORM_HOST_URL}

volumes:
  odd_platform_db_home:
    external: false

.env file:

POSTGRES_USER=odd-platform
POSTGRES_PASSWORD=odd-platform-password
POSTGRES_DATABASE=odd-platform

PLATFORM_HOST_URL=http://odd-platform:8080

SAMPLE_POSTGRES_USER=sample_odd_platform
SAMPLE_POSTGRES_PASSWORD=sample_odd_platform_password
SAMPLE_POSTGRES_DATABASE=sample_odd_platform
Vladysl commented 10 months ago

odd-collector: image: dsatair2023/odd-platform:0.21.0 restart: always env_file: .env volumes:

You are using odd-platform image for odd-collector For odd-collector we expect smth like image: ghcr.io/opendatadiscovery/odd-collector:latest

RamanDamayeu commented 9 months ago

Seems the issue was due to the miss configuration of docker-compose: we have to use different images for platform and for collectors.