The money stock would not be constant in a market economy with commodity money. Money production would be regulated by profit. If the purchasing power of money was anticipated to rise, then entrepreneurs could profit by producing more commodity money. This process would moderate any price deflation.
People are also free to select which commodity they want to use as money. If they thought gold would be less suitable because it would result in modest price deflation and thereby raise the problem of appreciating real value of debt, they could chose silver instead. In fact, silver (which is not as restrictive in production) not gold is the most widely used commodity money in history. People could even contract their debts in silver and use gold for other purchases. Using more than one commodity as money is called a parallel standard, which has historical precedent as well.