drop steal users connections on restart

This commit is contained in:
reshke 2020-09-01 17:05:14 +05:00 committed by kirill reshke
parent 15adddf05a
commit 20e97cae09
7 changed files with 63 additions and 4 deletions

View File

@ -1,4 +1,4 @@
daemonize yes
daemonize no
unix_socket_dir "/tmp"
unix_socket_mode "0644"

View File

@ -741,8 +741,23 @@ od_frontend_remote(od_client_t *client)
}
od_server_t *server;
od_instance_t *instance = client->global->instance;
for (;;) {
machine_cond_wait(client->cond, UINT32_MAX);
/* we go to the eternal wait
* mode during normal work and set the timeout to the client
* in 1 minute to perform actions in the shutdown mode */
while (1) {
if (machine_cond_wait(client->cond, 60000) == 0) {
break;
}
if (instance->shutdown_worker_id != -1) {
status = OD_ECLIENT_READ;
break;
}
}
if (od_frontend_status_is_err(status))
break;
/* client operations */
status = od_frontend_ctl(client);

View File

@ -10,4 +10,4 @@
void
od_grac_shutdown_worker(void *arg);
#endif /* ODYSSEY_GRAC_KILLER_H */
#endif /* ODYSSEY_GRAC_KILLER_H */

View File

@ -19,6 +19,7 @@ od_system_gracefully_killer_invoke(od_system_t *system)
"failed to invoke gracefully killer coroutine");
return NOT_OK_RESPONSE;
}
instance->shutdown_worker_id = mid;
return OK_RESPONSE;
}

BIN
test/ody-intergration-test/main Executable file

Binary file not shown.

View File

@ -184,8 +184,52 @@ func sigusr2Test(
return nil
}
func usrNoReadResultWhilesigusr2Test(
ctx context.Context,
) error {
err := ensurePostgresqlRunning(ctx)
if err != nil {
return err
}
if err := ensureOdysseyRunning(ctx); err != nil {
return err
}
db, err := getConn(ctx, databaseName, 1)
if _, err := db.Query("Select 42"); err != nil {
return err
}
if _, err := signalToProc(syscall.SIGUSR2, "odyssey"); err != nil {
return err
}
time.Sleep(30 * time.Second)
if err := db.Ping(); err != nil {
return err
}
time.Sleep(70 * time.Second)
if err := db.Ping(); err != nil {
fmt.Println(err)
return nil
}
return fmt.Errorf("connection not closed!!!\n")
}
func odyClientServerInteractionsTestSet(ctx context.Context) error {
if err := usrNoReadResultWhilesigusr2Test(ctx); err != nil {
err = fmt.Errorf("usrNoReadResultWhilesigusr2 error %w", err)
fmt.Println(err)
return err
}
if err := onlineRestartTest(ctx); err != nil {
err = fmt.Errorf("online restart error %w", err)
fmt.Println(err)

View File

@ -8,7 +8,6 @@ import (
)
func main() {
ctx := context.Background()
for _, f := range []func(ctx2 context.Context) error{