fix bug in stage 2 producer and add some logdebug messages