treasure-data / serverengine

A framework to implement robust multiprocess servers like Unicorn
Apache License 2.0
759 stars 86 forks source link

Just for testing multi_spawn_server_spec's behavior on CI #132

Closed daipom closed 2 years ago

daipom commented 2 years ago

This is just for testing CI behavior. Not intended to merge.

daipom commented 2 years ago

Unit testing with Ruby 3.1 on windows-latest

keepalive_workers with only restart_worker_interval

 send stop at: 2022-06-10 08:02:17.8417574 +0000
I, [2022-06-10T08:02:18.369913 #3224]  INFO -- : Worker 0 finished with 
Worker 0 will restart at: 2022-06-10 08:02:28.3749581 +0000
I, [2022-06-10T08:02:18.324392 #3224]  INFO -- : Worker 0 finished with status 0
I, [2022-06-10T08:02:18.874603 #3224]  INFO -- : Worker 1 finished with status 0
I, [2022-06-10T08:02:18.874833 #3224]  INFO -- : Worker 2 finished with status 0
All workers stopped at: 2022-06-10 08:02:18.8750225 +0000
Worker 1 will restart at: 2022-06-10 08:02:35.8751275 +0000
Worker 2 will restart at: 2022-06-10 08:02:35.8751275 +0000
Waiting for all workers to restart: 2022-06-10 08:02:31 20698845153580800741/21990232555520000000 +0000
Worker 0 started at: 2022-06-10 08:02:32 8528062873681779429/21990232555520000000 +0000
Worker 1 started at: 2022-06-10 08:02:35 19855214070844087013/21990232555520000000 +0000
Worker 2 started at: 2022-06-10 08:02:35 4101577274423035233/4398046511104000000 +0000

The following part is strange. This latency causes unexpected timeout errors.

All workers stopped at: 2022-06-10 08:02:18.8750225 +0000
Worker 1 will restart at: 2022-06-10 08:02:35.8751275 +0000
Worker 2 will restart at: 2022-06-10 08:02:35.8751275 +0000
daipom commented 2 years ago

I understand the cause.

https://github.com/treasure-data/serverengine/blob/bf88f9af9d5612c3ddb9f3a8786fda575964a46b/spec/multi_spawn_server_spec.rb#L97-L105

We need sleep-time between this.

If Timecop.freeze(Time.now + restart_worker_interval - mergin_time) runs before setting restat-time to all workers, the restart-time will increase by restart_worker_interval - mergin_time seconds, which is 7s.

daipom commented 2 years ago

We also need sleep-time between this: https://github.com/treasure-data/serverengine/blob/bf88f9af9d5612c3ddb9f3a8786fda575964a46b/spec/multi_spawn_server_spec.rb#L60-L69

because the judge is done before stopping workers.

daipom commented 2 years ago

I confirmed the cause and the suitable fix, so I close this now.