# Dataset Parallel writing Collision

**URL:** <https://forum.inductiveautomation.com/t/dataset-parallel-writing-collision/55017>\
**Category:** Ignition\
**Created:** [January 14, 2022, 10:23am UTC](https://forum.inductiveautomation.com/t/dataset-parallel-writing-collision/55017 "2022-01-14T10:23:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![y.parashchuk](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/y.parashchuk/32/37781_2.png) [@y.parashchuk](https://forum.inductiveautomation.com/u/y.parashchuk)\
**Post date:** [January 14, 2022, 10:23am UTC](https://forum.inductiveautomation.com/t/dataset-parallel-writing-collision/55017/1 "2022-01-14T10:23:27Z")

</div>

Is there are a way to update dataset without rewriting it?

I have a data set as memory tag. And i have 2 sources which doing updates in it (on change scripts), I want to update specific cell in dataset etc., but if 2 sources will writing to dataset in the same moment of time - the data from one of the sources will be lost because system.dataset.setValue is not updating dataset - it returning new dataset with updated cell. Script is using new dataset to rewrite the source dataset. So there will be scenario when 2 sources modifying the same dataset - the data be lost. I tested this scenario and the issue is present. Hope i explained well.  
So is somebody has any idea how to made modification to data set with not rewriting whole dataset?

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [January 14, 2022, 10:49am UTC](https://forum.inductiveautomation.com/t/dataset-parallel-writing-collision/55017/2 "2022-01-14T10:49:36Z")

</div>

> [@y.parashchuk](#):
>
> Is there are a way to update dataset without rewriting it?

Datasets are immutable, so no. Consider either moving this to the database, or combining your scripts so that you are writing to the tag once.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 14, 2022, 1:17pm UTC](https://forum.inductiveautomation.com/t/dataset-parallel-writing-collision/55017/3 "2022-01-14T13:17:14Z")

</div>

Instead of writing directly to the dataset, have each possible writer call a gateway message handler, where the actual dataset update is done. Individual handlers are serialized–no parallel writes will happen.

---

<div class="post-metadata">

**Author:** ![y.parashchuk](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/y.parashchuk/32/37781_2.png) [@y.parashchuk](https://forum.inductiveautomation.com/u/y.parashchuk)\
**Post date:** [January 14, 2022, 3:03pm UTC](https://forum.inductiveautomation.com/t/dataset-parallel-writing-collision/55017/4 "2022-01-14T15:03:39Z")

</div>

Thanks for the reply. I understand that possible solution is to have only 1 script which updating/writing to a data set, but that’s not what i am looking for. I replaced dataset to the string array - works better.

Have a nice day!

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [January 14, 2022, 3:12pm UTC](https://forum.inductiveautomation.com/t/dataset-parallel-writing-collision/55017/5 "2022-01-14T15:12:08Z")

</div>

> [@y.parashchuk](#):
>
> I replaced dataset to the string array - works better.

While there's nothing in place to stop you from mutating a String array it's not really supported and may have unintended consequences, like tag change scripts not seeing the mutation.

Using String arrays correctly you would suffer the same problem as Dataset.

---

<div class="post-metadata">

**Author:** ![y.parashchuk](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/y.parashchuk/32/37781_2.png) [@y.parashchuk](https://forum.inductiveautomation.com/u/y.parashchuk)\
**Post date:** [January 14, 2022, 3:51pm UTC](https://forum.inductiveautomation.com/t/dataset-parallel-writing-collision/55017/7 "2022-01-14T15:51:38Z")

</div>

True, but it depends how use it. For my goals all looks good.  
I have 1 source which adding data to empty fields (cells) of array.  
And another script which deleting data after required operations with them.

So i have 2 script units which working with the same String array, but they working all the time with different array cells. And i can update only 1 cell - not the whole array as in dataset case.
