You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Containers in 'creating' state should not be preemptively garbage-collected #1576
Today our container collector will find CREATING containers and garbage-collect them by forcing them into CREATED state. This introduces an inconsistency if there were volumes being created for the container, and also results in possibly-unsafe-or-at-least-inelegant destroying of the container while it's being created in Garden.
Here's a sample of an error that can result from this unsafe state transition:
STATEMENT: DELETE FROM containers WHERE id = $1 AND state = $2
CONTEXT: SQL statement "UPDATE ONLY "public"."volumes" SET "container_id" = NULL WHERE $1 OPERATOR(pg_catalog.=) "container_id""
DETAIL: Failing row contains (1904179, 0e3b2247-0b32-45d3-583b-b0b2f1c99104, null, null, concourse-windows-worker, null, null, /tmp/build/a1ce2fc4, null, null, null, 16, creating, null, null, null, null, null).
ERROR: new row for relation "volumes" violates check constraint "cannot_invalidate_during_initialization"
This results in un-deleteable rows from the database: the container can't be deleted, because there's a 'creating' volume present for it. The volume will not be garbage-collected, as it's still referencing the container.
Ideally, we wouldn't even look at CREATING containers during garbage-collection. We should be able to rely on the container eventually making it to CREATED. However there may be cases we need to handle, such as failure to create the container in Garden. We'd also have to make sure it's truly eventually-consistent, so we don't end up with any orphaned CREATING containers.
As of today, we no longer garbage-collect CREATING containers, and the cannot_invalidate_during_initialization constraint has been removed. However we still emit metrics, and I can see that we have quite a few containers stuck in CREATING state.
I'm going to leave this issue open because we technically have no exit from the state machine when a container is stuck CREATING. I think it'll take some time to catalogue the reasons why these containers didn't make it any further, though, and since it's pretty harmless at the moment I'm willing to leave it be.
Activity
jama22 commentedon Sep 11, 2017
We will know this worked if...
Let's first remove today's GCing of
CREATINGcontainers, and try a few things that may result in "stuck"CREATINGcontainers:Once we've reproduced the issue, let's figure out a safe way to remove them, with the following constraints:
CREATEDshould always mean that everything went as expected, and the container is definitely on the worker.DESTROYINGshould always mean that we've started to remove it via the garbage-collector.bump atc
bump atc
topherbullock commentedon Oct 24, 2017
Still seeing the database schema errors outlined in the issue.
https://papertrailapp.com/groups/1390664/events?q=new%20row%20for%20relation%20%22volumes%22%20violates%20check%20constraint%20%22cannot_invalidate_during_initialization%22%20&selected=859435071659216907-859435445036159003
vito commentedon Jun 28, 2018
As of today, we no longer garbage-collect
CREATINGcontainers, and thecannot_invalidate_during_initializationconstraint has been removed. However we still emit metrics, and I can see that we have quite a few containers stuck inCREATINGstate.I'm going to leave this issue open because we technically have no exit from the state machine when a container is stuck
CREATING. I think it'll take some time to catalogue the reasons why these containers didn't make it any further, though, and since it's pretty harmless at the moment I'm willing to leave it be.bump etree tsa handlers mux clockwork goxmldsig genproto grpc
stale commentedon Aug 8, 2019
Beep boop! This issue has been idle for long enough that it's time to check in and see if it's still important.
If it is, what is blocking it? Would anyone be interested in submitting a PR or continuing the discussion to help move things forward?
If no activity is observed within the next week, this issue will be
exterminatedclosed, in accordance with our stale issue process.