# Batch Transaction in Yugabyte

**URL:** <https://forum.yugabyte.com/t/batch-transaction-in-yugabyte/1732>\
**Category:** General\
**Created:** [August 18, 2022, 12:14am UTC](https://forum.yugabyte.com/t/batch-transaction-in-yugabyte/1732 "2022-08-18T00:14:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tyuengithub](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.yugabyte.com/tyuengithub/32/561_2.png) [@tyuengithub](https://forum.yugabyte.com/u/tyuengithub)\
**Post date:** [August 18, 2022, 12:14am UTC](https://forum.yugabyte.com/t/batch-transaction-in-yugabyte/1732/1 "2022-08-18T00:14:58Z")

</div>

Hi,

If have a batch transaction of multiple insert statements, and the last one failed, will it revert the entire transaction.

Background:

- there are 50 nodes and below script will insert 3 different tablet leaders
- from documentation, my understanding is that it will split into 3 separate insert statement and send to the tablet leaders

Questions:  
(1) if the tablet leaders for "3, ‘monkey’, ‘thrush’) is down, what will the client get back as a response?  
(2) Same question as (1), but if the raft\_heartbeat\_interval\_ms = 1000 and leader\_failure\_max\_missed\_heartbeat\_periods = 5, will that client get back as a response?  
(2.a) will client get failure / timeout

Sample Insert (from [https://docs.yugabyte.com](https://docs.yugabyte.com)’s documentation)

```sql
INSERT INTO sample(id, c1, c2)
 VALUES (1, 'cat' , 'sparrow'), (2, 'dog', 'blackbird'), (3, 'monkey' , 'thrush');

```

Regards,  
Tommy

---

<div class="post-metadata">

**Author:** ![dorian\_yugabyte](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.yugabyte.com/dorian_yugabyte/32/206_2.png) [@dorian\_yugabyte](https://forum.yugabyte.com/u/dorian_yugabyte)\
**Post date:** [August 18, 2022, 12:12pm UTC](https://forum.yugabyte.com/t/batch-transaction-in-yugabyte/1732/2 "2022-08-18T12:12:29Z")

</div>

Hi @tyuengithub

Assuming you’re taking examples from here [INSERT statement [YSQL] | YugabyteDB Docs](https://docs.yugabyte.com/preview/api/ysql/the-sql-language/statements/dml_insert/#examples)

> [@tyuengithub](#):
>
> If have a batch transaction of multiple insert statements, and the last one failed, will it revert the entire transaction.

Yes, it will be transactional.

> [@tyuengithub](#):
>
> (1) if the tablet leaders for "3, ‘monkey’, ‘thrush’) is down, what will the client get back as a response?

If you’re directly connecting to this server that is down (say, using a smart client), then the connection will be closed.

If you’re connected to another server, then you will be able to send the query but the write won’t happen, you’ll get failure.

> [@tyuengithub](#):
>
> (2) Same question as (1), but if the raft\_heartbeat\_interval\_ms = 1000 and leader\_failure\_max\_missed\_heartbeat\_periods = 5, will that client get back as a response?  
> (2.a) will client get failure / timeout

At 5 heartbeats, the db will still again try to contact the leader, but will timeout. After the 6th heartbeat, a new leader will start to be elected.
