When real estate or personal property is attached on mesne process, and in all cases of attachment on trustee process, the attachment shall be vacated upon the defendant or someone in his behalf delivering to the officer who made such attachment, or to the plaintiff or his attorney, a bond to the plaintiff in a penal sum not exceeding the amount of the attachment, such bond to be approved as to penal sum and sureties by the plaintiff or his attorney, or by any Justice or clerk of the Superior Court, conditioned that within 30 days after the rendition of the judgment, or after the adjournment of the court in which it is rendered or after the certificate of decision of the law court shall be received in the county where the cause is pending, he will pay to the plaintiff or his attorney of record the amount of said judgment including costs. The bond shall be returned by the officer with the process, for the benefit of the plaintiff, and thereupon all liability of the officer to the plaintiff by reason of such attachment shall cease. Upon request, the plaintiff or his attorney shall give to the defendant a certificate acknowledging the discharge of such attachment, which may be recorded in the registry of deeds or town clerk's office, as the case may be, in which the return of the attachment is filed. If stock in any corporation is attached, such certificate shall be filed with the officer of the corporation with whom the return of such attachment is filed and he shall record the same. In trustee process the alleged trustee shall not be liable to the principal defendant for the goods, effects and credits in his hands or possession until such certificate shall be delivered to him, and upon receiving such certificate he shall be discharged from further liability in said trustee action and need not disclose and shall not recover costs.