Counter example of upper semicontinuity of global fiber dimension on the source We know that if $f : X\to Y$ is a morphism between two affine varieties over an algebraically closed field $k$, then the function that assigns to each point of $X$ the dimension of the fiber it belongs to is upper semicontinuous on $X$.
Does anyone know of a simple counterexample when $X$ is not irreducible (but remains an algebraic set over $k$, i.e a finitely generated $k$-algebra) to the global statement?
Edit: to avoid ambiguity I am looking for a counterexample in case $X$ is not irreducible when the dimension of the fibers is measured globally, i.e. $n\geq 0$, the set of $x\in X$ such that $\dim(f^{-1}(f(x) ) ) \geq n$ is closed in $X$.
Edit2: in his comments @dorebell linked an answer here https://mathoverflow.net/a/184925/3333 where a counterexample to the upper semicontinuity of global dimension on the source is given with $X$ and $Y$ affine and irreducible (it works even if the counterexample is explained looking at the dimension of fibers from the target)
 A: Let $X = (\mathbb{A}^2 \setminus \{x = 0\}) \coprod \mathbb{A}^1$, let $Y = \mathbb{A}^1$, and let $f$ be projection onto the first coordinate on the first component and the identity on the second. Then every point of $X$ lives in a one-dimensional fiber except the origin of the second component.
A: For what its worth, I can give you a non-Noetherian example, even with both schemes affine, irreducible (and of finite Krull dimension).
Set $R = k[x,y,x/y, x/y^2, x/y^3, ...]$ and $S = k[y]$.  We have the obvious map $S \hookrightarrow R$ which induces
$$
X = \text{Spec }R \to Y = \text{Spec }S.
$$
Now, away from the origin of $S$, $y$ is invertible and $R[y^{-1}] = k[x,y,y^{-1}]$ has all fibers with dimension $1$.  On the other hand, once we set $y = 0$ in $R$, we notice that $x = (x/y) y$ is a multiple, as is $(x/y) = (x/y^2) y$, and so is $(x/y^n)$ for all $n$.  This is already a maximal ideal, so the fiber over $y = 0$ is $0$-dimensional.  
A: Let $ X = \mathbb A^2 \cup pt$, let $Y = \mathbb P^1$. Let $f(\mathbb A^2) = \mathbb A^1$ by projection, and let $f(pt)=\infty$. Then the generic fiber dimension is $1$, but at one point the fiber dimension is $0$.
