emqx/apps/emqx_bridge_pgsql
Thales Macedo Garitezi 7a16ff4f04 fix(postgres_bridge): fix table existence check and handle sync_required
Fixes https://emqx.atlassian.net/browse/EMQX-10629

During health checking, we check whether tables in the SQL statement
exist.  Such check was done by asking the backend to parse the
statement using a named prepared statements.  Concurrent health checks
could then result in the error:

```erlang
{error,{error,error,<<"42P05">>,duplicate_prepared_statement,<<"prepared statement \"get_status\" already exists">>,[{file,<<"prepare.c">>},{line,<<"451">>},{routine,<<"StorePreparedStatement">>},{severity,<<"ERROR">>}]}}
```

This could lead to an inconsistent state in the driver process, which
would crash later when a message from the backend (`READY_FOR_QUERY`, "idle"):

```
  2023-07-24T13:05:58.892043+00:00 [error] Generic server <0.2134.0> terminating. Reason: {'module could not be loaded',[{undefined,handle_message,[90,<<"I">>,...
```

Added calls to `epgsql:sync/1` for functions that could return
`{error, sync_required}`.

Also, redundant calls to `parse2` were removed to reduce the number of requests.
2023-07-25 09:15:14 -03:00
..
src fix(machine_boot): ensure emqx_bridge starts after its companion apps 2023-07-20 13:11:44 -03:00
test fix(postgres_bridge): fix table existence check and handle sync_required 2023-07-25 09:15:14 -03:00
BSL.txt chore: create dirs and README template for all ee bridges 2023-04-18 09:36:41 +08:00
docker-ct refactor(pgsql): move pgsql && matrix && timescale bridges into their own app 2023-05-10 16:51:33 +08:00
README.md docs: fix invalid links 2023-05-15 11:18:09 +08:00
rebar.config refactor(pgsql): move pgsql && matrix && timescale bridges into their own app 2023-05-10 16:51:33 +08:00

EMQX PostgreSQL Bridge

PostgreSQL is an open-source relational database management system (RDBMS) that uses and extends the SQL language. It is known for its reliability, data integrity, and advanced features such as support for JSON, XML, and other data formats.

The application is used to connect EMQX and PostgreSQL. User can create a rule and easily ingest IoT data into PostgreSQL by leveraging EMQX Rules.

Documentation

HTTP APIs

  • Several APIs are provided for bridge management, which includes create bridge, update bridge, get bridge, stop or restart bridge and list bridges etc.

    Refer to API Docs - Bridges for more detailed information.

Contributing

Please see our contributing.md.

License

EMQ Business Source License 1.1, refer to LICENSE.