Error while executing RestartStage OOTB Activity

I have an activity where I am opening the work object which already have an assignment and calling pxRestartStage. When I login to designer studio and run the activity, I am getting this error only for the first time and works fine when I rerun the activity any number of times after that for the work objects. From Tracer I could notice that this error is caused by the Java step which calls pxRemoveOpenStageFlows. Really appreciate any help or suggestion to resolve this.

Error Message from Tracer(same attached here):
trying to calculate the handle of a class whose instances may not be written to the database: Assign-: code: SQLState: Message

Hi @GanapathyG, as you are facing this issue only for the first time, can you please check once if you are using a step page which is not instantiated (Page-New)?

@SaurabhG7134 Thanks for your response. yeah, I figured out that a needed Page was removed and that was causing the issue.