History not starting up

I get the following root cause exception when history fails to start up

history-1  | Caused by: java.lang.IllegalStateException: Storage is not in a ready state.
history-1  | 	at com.noumenadigital.platform.history.config.HistoryConfig.<init>(HistoryConfig.kt:78) ~[classes!/:2025.1.7]

What is the expected ready condition?

psql -U history -h localhost -d postgres
Password for user history:
psql (17.4, server 15.13 (Debian 15.13-1.pgdg120+1))
Type "help" for help.

postgres=> \dn
          List of schemas
      Name      |       Owner
----------------+-------------------
 iou_history    | postgres
 iou_java       | postgres
 iou_keycloak   | postgres
 iou_npl        | postgres
 iou_typescript | postgres
 public         | pg_database_owner
(6 rows)

The history user exists and has create on the database and all on the schema iou_history

    CREATE ROLE "$HISTORY_DB_USER" LOGIN PASSWORD '$HISTORY_DB_PASSWORD' NOINHERIT;
    GRANT CREATE ON DATABASE "$POSTGRES_DB" TO "$HISTORY_DB_USER";
    GRANT ALL ON SCHEMA iou_history TO "$HISTORY_DB_USER";

History configuration

  history:
    image: ghcr.io/noumenadigital/packages/history:2025.1.7
    ports:
      - "12010:12010"
      - "12711:12711"
    environment:
      - HISTORY_DB_URL=jdbc:postgresql://db:5432/postgres
      - HISTORY_DB_USER=history
      - HISTORY_DB_PASSWORD=history-secret
      - HISTORY_DB_ENGINE_SCHEMA=iou_npl
      - HISTORY_DB_SCHEMA=iou_history
    depends_on:
      npl:
        condition: service_healthy

The database initialisation needs to be done like this:

    CREATE ROLE "$HISTORY_DB_USER" LOGIN PASSWORD '$HISTORY_DB_PASSWORD' NOINHERIT;
    GRANT CREATE ON DATABASE "$POSTGRES_DB" TO "$HISTORY_DB_USER";
    GRANT ALL ON SCHEMA iou_history TO "$HISTORY_DB_USER";
    GRANT USAGE ON SCHEMA iou_npl TO "$HISTORY_DB_USER";
    GRANT SELECT ON ALL TABLES IN SCHEMA iou_npl TO "$HISTORY_DB_USER";
1 Like

Hi Sandy, great you could find the solution yourself!