How can I rollback a transaction?

Hi,

I have a Foundry Transform that is incremental, and reads the previous output to create a new output.

Unfortunately there was an error in my code and I would like to reset my output dataset to a previous transaction so that I can run it again. How can I do this in the platform?

1 Like

You could create a master-backup branch pointing to the latest transaction on master with this endpoint.

curl -X POST \
	-H "Content-type: application/json" \
	-H "Authorization: Bearer $TOKEN" \
	"https://$HOSTNAME/api/v1/datasets/ri.foundry.main.dataset.XXX/branches" \
	-d '{"branchId":"master-backup","transactionRid":"LATEST_TRANSACTION_RID"}'

Then you could delete the master branch with:

curl -X DELETE \
	-H "Authorization: Bearer $TOKEN" \
	"https://$HOSTNAME/api/v1/datasets/ri.foundry.main.dataset.XXX/branches/master"

And finally recreate master, pointing to a previous transaction:

curl -X POST \
	-H "Content-type: application/json" \
	-H "Authorization: Bearer $TOKEN" \
	"https://$HOSTNAME/api/v1/datasets/ri.foundry.main.dataset.XXX/branches" \
	-d '{"branchId":"master","transactionRid":"PREVIOUS_TRANSACTION_RID"}'

The first step may be unneeded, as I don’t think deleting branches deletes the underlying transaction anyway, but then it’s probably better to try with a non-production dataset first.