tarantool-python icon indicating copy to clipboard operation
tarantool-python copied to clipboard

Managing Transactions

Open enescaglar opened this issue 4 years ago • 5 comments

Hi,

Is there a way to manage transactions through the library?

In tarantool, transaction is started with box.begin() and committed with box.commit() functions. But I couldn't find any methods in the library to manage the transactions.

What I would like to do is, begin a transaction, make updates/inserts to a space and then commit the transaction.

I tried adding some functions like below and calling these functions from the library, but it didn't work.

function begin_transaction(dummy) box.begin() end

function commit_transaction(dummy) box.commit() end

Thank you.

enescaglar avatar Aug 03 '20 16:08 enescaglar

Hi! Tarantool doesn't have interactive transactions (https://github.com/tarantool/tarantool/issues/2016)

You should call box.begin() and box.commit() inside one tarantool event loop iteration. Also you couldn't yield inside transactions. There is only one way to insert/update/... data transactionally from connector - write stored procedure with transaction inside and call it.

So, you can read more about transaction management in Tarantool in our documentation https://www.tarantool.io/en/doc/2.5/book/box/atomic/

olegrok avatar Aug 03 '20 18:08 olegrok

I'll left the issue open as the feature requested blocked on the corresponding tarantool functionality.

Totktonada avatar Aug 03 '20 19:08 Totktonada

Thank you for the answer.

There is only one way to insert/update/... data transactionally from connector - write stored procedure with transaction inside and call it.

I was trying to implement such solution and stuck with this https://github.com/tarantool/tarantool-python/issues/162 Do you have any idea on this? Sample codes inside the documentation are somewhat limited and I couldn't figure out how to call a function with a list input.

Thank you.

enescaglar avatar Aug 03 '20 19:08 enescaglar

I was trying to implement such solution and stuck with this #162

Answered, discussed and resolved :)

Totktonada avatar Aug 03 '20 21:08 Totktonada

https://github.com/tarantool/tarantool/issues/2016 is implemented now, the issue is not blocked anymore.

Totktonada avatar Dec 14 '21 14:12 Totktonada