Docker-Compose with external database (OD-554)
jewgeni opened 4 years ago

Hello,

Maybe someone could help me. I'm trying to set up onedev via docker-compose with a postgresql database. My docker-compose.yml:

networks:
  internal:
    external: false

services:
  onedev-app:
    container_name: onedev-app
    image: 1dev/server:latest
    ports:
      - 6610:6610
      - 6611:6611
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./data:/opt/onedev
    networks:
      - internal
    restart: unless-stopped
    environment:
      hibarnate_dialect: "org.hibernate.dialect.PostgreSQLDialect"
      hibernate_connection_driver_class: org.postgresql.Driver
      hibernate_connection_url: jdbc:postgresql://onedev-db/onedev
      hibernate_connection_username: onedev
      hibernate_connection_password: password
    depends_on:
      - onedev-db

  onedev-db:
    container_name: onedev-db
    image: postgres:13
    networks:
      - internal
    restart: unless-stopped
    volumes:
      - ./db:/var/lib/postgresql/data
    environment:
      POSTGRES_DB: onedev
      POSTGRES_USER: onedev
      POSTGRES_PASSWORD: password

This results in the following error:

onedev-db     | LOG:  database system is ready to accept connections
onedev-app    | INFO  - Launching application from '/app'...
onedev-app    | INFO  - Cleaning temp directory...
onedev-app    | INFO  - Starting server...
onedev-app    | INFO  - Successfully checked /opt/onedev
onedev-app    | INFO  i.onedev.commons.bootstrap.Bootstrap - Launching application from '/opt/onedev'...
onedev-app    | INFO  i.onedev.commons.bootstrap.Bootstrap - Cleaning temp directory...
onedev-app    | INFO  io.onedev.commons.loader.AppLoader - Starting server...
onedev-db     | ERROR:  syntax error at or near "TRANSACTION" at character 14
onedev-db     | STATEMENT:  SET DATABASE TRANSACTION CONTROL MVCC
onedev-app    | ERROR i.o.s.p.DefaultPersistManager - Error executing sql: SET DATABASE TRANSACTION CONTROL MVCC
onedev-app    | org.postgresql.util.PSQLException: ERROR: syntax error at or near "TRANSACTION"
onedev-app    |   Position: 14
onedev-app    |         at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2497)
...

What am I doing wrong?

  • jewgeni commented 4 years ago

    I tried the same with mariadb as the db.

    Sadly, the same result:

    onedev-app    | ERROR i.o.s.p.DefaultPersistManager - Error executing sql: SET DATABASE TRANSACTION CONTROL MVCC
    onedev-app    | java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'DATABASE TRANSACTION CONTROL MVCC' at line 1
    
  • Robin Shen commented 4 years ago

    This is a bug and will be fixed soon.

  • Robin Shen commented 4 years ago

    HAA.. turns out you've misspelled hibernate_dialect as hibarnate_dialect

  • jewgeni commented 4 years ago

    ??‍♂️Thank you, works now 😃

  • Robin Shen changed state to 'Closed' 4 years ago
    Previous Value Current Value
    Open
    Closed
  • jewgeni changed state to 'Open' 4 years ago
    Previous Value Current Value
    Closed
    Open
  • jewgeni commented 4 years ago

    Hey,

    sry I was wrong. Today I tried to set it up on my server. I can set up the admin account, after that, it crashes (Error 502 bad gateway)

    ERROR i.onedev.commons.bootstrap.Bootstrap - Error booting application
    
    java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    
    at io.onedev.commons.loader.Listener.notify(Listener.java:21)
    
    at io.onedev.commons.loader.DefaultListenerRegistry.post(DefaultListenerRegistry.java:69)
    
    at io.onedev.server.OneDev.postStart(OneDev.java:138)
    
    at io.onedev.server.persistence.SessionInterceptor$1.call(SessionInterceptor.java:23)
    
    at io.onedev.server.persistence.DefaultSessionManager.call(DefaultSessionManager.java:79)
    
    at io.onedev.server.persistence.SessionInterceptor.invoke(SessionInterceptor.java:18)
    
    at io.onedev.commons.loader.DefaultPluginManager.start(DefaultPluginManager.java:48)
    
    at io.onedev.commons.loader.AppLoader.start(AppLoader.java:73)
    
    at io.onedev.commons.bootstrap.Bootstrap.main(Bootstrap.java:189)
    
    Caused by: java.lang.reflect.InvocationTargetException: null
    [...]
    Caused by: javax.persistence.PersistenceException: org.hibernate.HibernateException: org.postgresql.util.PSQLException: Large Objects may not be used in auto-commit mode.
    [...]
    Caused by: org.hibernate.HibernateException: org.postgresql.util.PSQLException: Large Objects may not be used in auto-commit mode.
    [...]
    Caused by: org.postgresql.util.PSQLException: Large Objects may not be used in auto-commit mode.
    [...]
    

    Do you know what I can do about it?

  • Robin Shen commented 4 years ago

    OneDev can connect PostgreSQL NOT running in docker container without any issues. Will investigate what might be wrong with container mode...

  • jewgeni commented 4 years ago

    Thanks.

    I tried to do the same in the container as described in the manual (change database) for bare metal, sadly no success:

    I deleted the environment from onedev-app, so it used SQLite. The services started as expected. Then I executed /bin/bash within the running container.

    docker -it onedev-app /bin/bash
    cd opt/onedev/bin/
    ./server.sh stop
    

    Output:

    OneDev is not running.
    

    Input:

    ./server.sh status
    

    Output:

    OneDev (not installed) is not running.
    

    Input:

    ./backup-db.sh ../backup/backup
    

    Output:

    Running OneDev Backup Database...
    --> Wrapper Started as Console
    Java Service Wrapper Standard Edition 64-bit 3.5.48
      Copyright (C) 1999-2021 Tanuki Software, Ltd. All Rights Reserved.
        http://wrapper.tanukisoftware.com
      Licensed to OneDev for Service Wrapping
    
    Launching a JVM...
    WrapperManager: Initializing...
    INFO  - Launching application from '/opt/onedev'...
    INFO  - Cleaning temp directory...
    INFO  - Starting server...
    ERROR - Please stop server before backing up database
    <-- Wrapper Stopped
    

    The wrapper is starting the server and then the wrapper stops because the server is running? So this method also won't work with the container mode.

    Unfortunately I don't know any Java, otherwise I would tried to help investigate more.

    In Stackoverflow I saw some questions regarding this error (not related to onedev). Solution was to change the database column to Bytea type in PostgreSQL and change the JBPM implementation to use byte[] over java.sql.Blob (in org.jbpm.pvm.internal.lob.Lob class).

  • jewgeni commented 4 years ago

    New try, this time I didn't add the external database through the environment, but I edited the hibernate.properties file and restarted the container. It works.

  • jewgeni changed state to 'Closed' 4 years ago
    Previous Value Current Value
    Open
    Closed
  • Robin Shen commented 4 years ago

    Turns out that you are using wrong dialect for environment hibarnate_dialect. It should be io.onedev.server.persistence.PostgreSQLDialect as specified in hibernate.properties.

    After using the correct dialect, make sure to delete the database first.

    Also you may add the option tty: true to onedev app; otherwise the console output will not be flushed.

issue 1/1
Type
Question
Priority
Normal
Assignee
Issue Votes (0)
Watchers (4)
Reference
OD-554
Please wait...
Connection lost or session expired, reload to recover
Page is in error, reload to recover