Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature proposal: Batch revert #445

Open
igordreher opened this issue May 31, 2023 · 5 comments
Open

Feature proposal: Batch revert #445

igordreher opened this issue May 31, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@igordreher
Copy link

Is your feature request related to a problem? Please describe.
I would like to revert a bunch of related transactions together and only commit the reversion if none fails to revert.

Summary
Having a way to revert transactions in batch is important to guarantee that a batch of transactions can only be reverted if all can.

Solution proposal
Add an endpoint to revert a list of transactions and this would only revert the transactions if none fails to revert.
Another possible solution would be to add an endpoint to check if a transaction can be reverted.

Describe alternatives you've considered
Check if all transactions can be reverted (the source accounts have enough money) before reverting them one by one. This isn't a guarantee and it isn't clear what are all the rules that are used to verify if a transaction can be reverted (I didn't find it documented anywhere).

@igordreher igordreher added the enhancement New feature or request label May 31, 2023
@gfyrag
Copy link
Collaborator

gfyrag commented May 31, 2023

@igordreher Hello!
Can you elaborate on your use case?
Today, the batch is used mainly to avoid network latencies, not to enforce the commitment of a set of transactions.
The ledger use a single sql transaction, and thus, the whole is either committed or rollback, but this is not the main idea of the batch feature. For your information, we are working on a v2 where the batch will not be available. Instead we will probably implements a bulk request feature. With these bulk requests, you will be able to push a batch of transactions, but each one will be independent.
So, reverting a batch of transactions feels like a non sense for me.
Do you have seen you can create transactions with multiple postings? Using this instead of multiple transactions could allow you to revert all at once juste by reverting the single transaction you created at first.

@igordreher
Copy link
Author

igordreher commented Jun 2, 2023

Hey @gfyrag, thanks for replying!

Do you have seen you can create transactions with multiple postings? Using this instead of multiple transactions could allow you to revert all at once juste by reverting the single transaction you created at first.

Yes and we use it already in some cases. But, we can't revert a single posting of a transaction.

Can you elaborate on your use case?

We are making a wrapper around Ledger with a design that depends on this behavior to guarantee a consistent relation between transactions.
We want to be able to create related transactions atomically and have the option to revert a few of them or revert them all together.
If we use a single transaction with various postings, we wouldn't be able to do this, since I can't revert only a portion of a transaction. We will not be able to undo only e.g. tax or discount (both distinct txids) of a batch transaction using multiple postings as they have the same txid.
And there are moments we would like to revert these atomic transactions all together. If we try to do so, there is a risk this operation fails and can't be completed for reasons such as conflicting transactions happening at the same time.

About the batch not being available on v2, is there any remote possibility that this behavior remains available instead of being replaced? (Adding a bulk endpoint, instead of replacing the current batch endpoint)
I ask this since I'm currently depending on this batch behavior

FYI @lucasfcnunes

@lucasfcnunes
Copy link

ping @gfyrag

@NathanFirmo
Copy link

Any update??

@thiagolinsx
Copy link

Nothing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants