Files
threshold/internal/db/schema/migrations
Chris Marchesi 5a70875726 internal/servers/controller: Worker failure connection cleanup (#1340)
This commit adds the support to do the following:

* Mark connections for non-reporting workers as closed. This is the
controller counterpart to the worker functionality (see #1330). This is
written as a scheduled job that does the work DB-side in a single atomic
query.

* Works to reconcile states if such a broken controller-worker
connection resumes and a worker reports a connection as connected that
should be disconnected. In this case, the controller will send an update
request, and the worker will honor it and terminate the connection.

* Further refinement of the grace period setting has been added here.
We have converged on the current server "liveness" setting as our
default here, which is half of the previous 30s (15 seconds, in other
words). Additionally, this is now configurable on the controller and
worker side, with the caveat that it's currently impossible to do so in
config as the setting has been untagged in HCL. This is exposed so that
we can run some sophisticated testing scenarios where we skew the grace
period to either the controller or worker to ensure the aforementioned
reconciliation works.

* Some repository functions have been added to support the new
functionality, in addition to some test code to the worker to allow
querying of session state while testing.

* Finally, we've added some add timestamp subtraction functions
as well, basically serving as the opposite of the addition functions.
2021-07-14 09:14:24 -07:00
..

migrations package

This package handles the generation of the database schema in a format that can be compiled into the boundary binary.

Organization

  • ./generate: contains the makefile, code, and templates needed to generate the schema info.
  • ./postgres: contains the versioned schema folders. The contents of these folders, except for dev should not be modified.

Usage

To regenerate the schema information into the format the boundary binary uses run make migrations or make gen to recreate all generated code.

The content of the folders under ./postgres are compiled into the boundary binary and when the boundary database init or boundary database migrate commands are executed they are applied in order of their version.

The ./postgres/dev directory contains schema files that are under development and are not included in a release yet and so it is the only directory where additions and modifications are allowed. When a boundary binary is built when this directory is not empty a special flag is required to run the boundary database init command to indicate the user is aware that this is a development release and running this command can result in a completely broken schema and dataloss.

When a new release is made the contents of the dev directory are moved into a new versioned directory.