Coder Social home page Coder Social logo

Comments (8)

etschelp avatar etschelp commented on June 20, 2024 2

See pull request. Once merged different agents can share the same database by setting -Doagent.pg.schema=second-agent, default is public. Schemas are separated from each other and can support different agent versions.

from business-partner-agent.

matgnt avatar matgnt commented on June 20, 2024

Switching to another container-internal in-memory (H2) database is not possible because JSONB datatype is only supported in postgres.

from business-partner-agent.

etschelp avatar etschelp commented on June 20, 2024

Yes we specifically use porstgres. Supporting multiple databases would require changing the stack to something like liquibase and hibernate.

Back to original issue, creating databases on the fly is not possible with flyway. The workaround is sharing the same database by using schemas meaning each table has a separate namespace. This can be achieved by exposing a new property. Thats the easy part, the hard part is that our init scripts have the public schema in it, which means we have to reset everything.

from business-partner-agent.

frank-bee avatar frank-bee commented on June 20, 2024

I think docker compose might no be the right tool to handle launching of a larger infrastructure with e.g. several agents being launched. what about switching to a cloud native approach?
Something like: A BPA could be a helm chart which can be configured to launch a database or to use and externally provided one ( ...e.g with another helm chart). For each BPA you need, another helm chart is instantiated....
For postgres clusters there are OSS variants available for K8s: e.g. https://stackgres.io/

from business-partner-agent.

frank-bee avatar frank-bee commented on June 20, 2024

The workaround is sharing the same database by using schemas meaning each table has a separate namespace

Why would you see this more like a workaround , @etschelp ?
If we work with different schemas instead of dbs, would it be possible to launch agents next to each other with different versions?

from business-partner-agent.

matgnt avatar matgnt commented on June 20, 2024

@etschelp Thanks for the quick reaction!

Unfortunately, I can't get it working. I deleted all postgres volumes I could find and added the option -Doagent.pg.schema=...

On the first start, I get the following error:
Anything else to change?

15:59:52.803 [main] INFO  Schema - Creating schema """0fef2b1df326""" ...
15:59:52.815 [main] INFO  JdbcTableSchemaHistory - Creating Schema History table """0fef2b1df326"""."flyway_schema_history" ...
15:59:52.890 [main] INFO  DbMigrate - Current version of schema """0fef2b1df326""": null
15:59:52.946 [main] INFO  DbMigrate - Migrating schema """0fef2b1df326""" to version 1 - create-initial-schema
15:59:52.970 [main] ERROR DbMigrate - Migration of schema """0fef2b1df326""" to version 1 - create-initial-schema failed! Changes successfully rolled back.
15:59:52.973 [main] ERROR Micronaut - Error starting Micronaut server: Bean definition [javax.sql.DataSource] could not be loaded: 
Migration V1__create-initial-schema.sql failed
----------------------------------------------
SQL State  : 3F000
Error Code : 0
Message    : ERROR: no schema has been selected to create in
  Position: 14
Location   : databasemigrations/V1__create-initial-schema.sql (/file:/organizational-agent.jar!/databasemigrations/V1__create-initial-schema.sql)
Line       : 1
Statement  : CREATE TABLE did_doc_web (
    id uuid PRIMARY KEY,
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    did_doc jsonb,
    profile_json jsonb
)

from business-partner-agent.

etschelp avatar etschelp commented on June 20, 2024

Please pull and try again, there was another property missing.

from business-partner-agent.

matgnt avatar matgnt commented on June 20, 2024

Issue resolved. Thank you!

12:49:13.980 [main] INFO  VersionPrinter - Flyway Community Edition 6.5.5 by Redgate
12:49:14.278 [main] INFO  DatabaseFactory - Database: jdbc:postgresql://postgres/bpa (PostgreSQL 12.4)
12:49:14.369 [main] INFO  Schema - Creating schema "8a7acead8d62" ...
12:49:14.379 [main] INFO  JdbcTableSchemaHistory - Creating Schema History table "8a7acead8d62"."flyway_schema_history" ...
12:49:15.318 [main] INFO  DbMigrate - Current version of schema "8a7acead8d62": null
12:49:15.353 [main] INFO  DbMigrate - Migrating schema "8a7acead8d62" to version 1 - create-initial-schema
12:49:16.765 [main] INFO  DbMigrate - Successfully applied 1 migration to schema "8a7acead8d62" (execution time 00:01.453s)
12:49:17.161 [pool-2-thread-1] INFO  DBOperations - Running startup database operations.

from business-partner-agent.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.