The book Social Problems in a Free Society: Myths, Absurdities, and Realities by Myles J. Kelleher (alt link) documents many of the idiosyncrasies of Soviet planned economy. It mentions the nail story and points to the cartoon in Krokodil, but it gives references for similar anecdotes.
Production managers frequently met their output goals in ways that were logical within the bureaucratic system of incentives, but bizarre in their results. If the success of a nail factory's output was determined solely by numbers, it would produce extraordinary numbers of pinlike nails; if by weight, smaller numbers of very heavy nails. (A cartoon in the satiric magazine Krokodil featured a proud factory manager displaying his record gross output - a single gigantic nail lifted by a crane.) One Soviet shoe factory manufactured 100,000 pairs of shoes for young boys instead of more useful men's shoes in a range of sizes because doing so allowed them to make more shoes from the allotted leather and receive a performance bonus.19
Would have made this a comment, but I lack the necessary rep