Preventing out of order deploys in gitlab-ci

Is there anything built in, or anything I need to do, to prevent a ‘Deploy’ stage from a later pipeline before a ‘Deploy’ from an earlier pipeline run?

Eg, suppose I have a simple “Build” and “Deploy” stage, and a fast and slow buildserver, and do two commits in a row.

Suppose the slow server does a Build for commit no.1, and the fast server does a Build for commit no.2. The build succeeds, and the fast server runs the deploy stage for commit no.2, tagging it as the ‘latest’ docker image. Now, the build for commit no.1 completes, and it start its deploy run… and overwrites the ‘latest’ docker image with its own, older, version.

I wonder if anything I can’t find documented would prevent running a deploy stage for a later commit if earlier ones are still running, or if there indeed isn’t, how others solve it ?