Question about interactive transactions
I'm reading the docs about interactive transactions and it mentionts to try to not do network requests inside of them. I am trying to create an entry in a playlist table which has a url to a thumbnail. I was going to name the thumbnail using a trigger so the file name can contain playlist Id.
The actual thumbnail image is uploaded to S3 after getting the playlist id to name it. I don't want the entry in the database to be created if the image upload fails. Is there a better way to go about this if interactive transactions doc says this is a bad idea?
2 Replies
Hi @SimplyEmu š
One way to go about this is to:
1. Perform the S3 upload operation before any database transaction. This ensures that the network request is completed successfully before proceeding with database operations.
2. Use a Transaction to Create the Playlist Entry: Once the image is successfully uploaded, start a transaction to create the playlist entry and update it with the thumbnail URL.
for example:
I think I just need to come up with a different file naming scheme. Iām trying to prevent creating the playlist if the file upload fails. Probably a horrible way to go about it but it is what it is i guess.