Skip to content

[DSIP-56] Refactor JDBC registry support session timeout and data change event #16278

@ruanwenjun

Description

@ruanwenjun

Search before asking

  • I had searched in the DSIP and found no similar DSIP.

Motivation

DS have support to jdbc registry which will rely on mysql/pg to accomplice the service discovery. But there exist some problem in current implementation.

  • The architecture of jdbc registry is not clear, it's hard to maintain the code.
  • The data of client heartbeat is bind to the data, which make it's hard to debug.
  • Client doesn't support configuration e.g. session timeout, this make all client should have the same config.
  • If the a data is changed multiple times, the change event will lost, since the change event is generated by computation of two snapshot data.

Design Detail

image

JdbcRegistryServer

The JdbcRegistryServer represent the server side of JdbcRegistry, each service instance should create a JdbcRegistryServer. The JdbcRegistryServer is responsible to maintain the client's heart and response for the client's request.

Once the client's heartbeat doesn't refreshed success after client's session timeout, then the JdbcRegistryServer will clear the client's relation data.

JdbcRegistryClient

We can use JdbcRegistryClient to creat/delete data、acquire lock、 subscribe the data change event, connection change event.

t_ds_jdbc_registry_client_heartbeat

t_ds_jdbc_registry_client_heartbeat will store the active jdbc client heartbeat, once the jdbc client is dead , the server will delete the record in t_ds_jdbc_registry_client_heartbeat.

t_ds_jdbc_registry_data_change_event

t_ds_jdbc_registry_data_change_event will store the change event of t_ds_jdbc_registry_data, the server will detect the incremental events in this table and trigger data change event. Once we create/delete/update the record in t_ds_jdbc_registry_data, will insert a relation event to t_ds_jdbc_registry_data_change_event. Once the event is insert after 2h then it will be deleted.

Compatibility, Deprecation, and Migration Plan

Not compatibility with the old version, need to recreate the registry table.

Test Plan

No response

Code of Conduct

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions