# Data in mutation layer lose when DGraph crash?

**URL:** <https://discuss.dgraph.io/t/data-in-mutation-layer-lose-when-dgraph-crash/1354>\
**Category:** Users\
**Created:** [March 21, 2017, 1:49am UTC](https://discuss.dgraph.io/t/data-in-mutation-layer-lose-when-dgraph-crash/1354 "2017-03-21T01:49:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rader](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/rader/32/1061_2.png) [@Rader](https://discuss.dgraph.io/u/Rader)\
**Post date:** [March 21, 2017, 1:49am UTC](https://discuss.dgraph.io/t/data-in-mutation-layer-lose-when-dgraph-crash/1354/1 "2017-03-21T01:49:03Z")

</div>

I see there is mutation layer on the top of RocksDB, and it will commit the changes every 5 seconds. If the DGraph crash, what will happen to the changes temporary in mutation layer？ I guess we will lose them, right?

---

<div class="post-metadata">

**Author:** ![mrjn](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/mrjn/32/775_2.png) [@mrjn](https://discuss.dgraph.io/u/mrjn)\
**Post date:** [March 21, 2017, 2:45am UTC](https://discuss.dgraph.io/t/data-in-mutation-layer-lose-when-dgraph-crash/1354/2 "2017-03-21T02:45:15Z")

</div>

No, you won’t. Dgraph uses a Write Ahead Log, before any mutation is applied. In case Dgraph crashes, it would replay the WAL from the last snapshot, which would bring the system to the same state.

If you have received an OK reply for a write mutation, we guarantee that you won’t lose that write. Also, Dgraph is (going to be) atomically (instantaneously) consistent; so if a write mutation has been done, every read from then on would see that or a future write.

---

<div class="post-metadata">

**Author:** ![Rader](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/rader/32/1061_2.png) [@Rader](https://discuss.dgraph.io/u/Rader)\
**Post date:** [March 21, 2017, 2:53am UTC](https://discuss.dgraph.io/t/data-in-mutation-layer-lose-when-dgraph-crash/1354/3 "2017-03-21T02:53:42Z")

</div>

I know the RocksDB has a Write Ahead Log. Do you mean the WAL log is updated first before changes arrive the Mutation Layer？

---

<div class="post-metadata">

**Author:** ![mrjn](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/mrjn/32/775_2.png) [@mrjn](https://discuss.dgraph.io/u/mrjn)\
**Post date:** [March 21, 2017, 2:56am UTC](https://discuss.dgraph.io/t/data-in-mutation-layer-lose-when-dgraph-crash/1354/4 "2017-03-21T02:56:33Z")

</div>

I’m not talking about RocksDB WAL. We have our own WAL. We do a synchronous write to WAL before the mutation is applied to Posting List. This way, even if Dgraph crashes or machines goes down, we can get the best guarantee available by the kernel about data being flushed to disk.

---

<div class="post-metadata">

**Author:** ![Rader](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/rader/32/1061_2.png) [@Rader](https://discuss.dgraph.io/u/Rader)\
**Post date:** [March 21, 2017, 7:12am UTC](https://discuss.dgraph.io/t/data-in-mutation-layer-lose-when-dgraph-crash/1354/5 "2017-03-21T07:12:21Z")

</div>

Do you already have the WAL for mutation layer, or are you planning to add it? I don’t find any code related to WAL for mutation layer. could you help me ?

---

<div class="post-metadata">

**Author:** ![mrjn](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/mrjn/32/775_2.png) [@mrjn](https://discuss.dgraph.io/u/mrjn)\
**Post date:** [March 21, 2017, 11:20am UTC](https://discuss.dgraph.io/t/data-in-mutation-layer-lose-when-dgraph-crash/1354/6 "2017-03-21T11:20:00Z")

</div>

Wal is part of Raft code. Every mutation goes via raft. You can see it in node.Ready in draft.go. Sorry, typing from mobile, so can’t give you exact github link.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex007/uploads/dgraph/original/2X/2/2b38fdece2abe5814f2e51bee69d1e67fc304b0a.png) [@system](https://discuss.dgraph.io/u/system)\
**Post date:** [April 20, 2017, 11:20am UTC](https://discuss.dgraph.io/t/data-in-mutation-layer-lose-when-dgraph-crash/1354/7 "2017-04-20T11:20:10Z")

</div>

Closed on April 20, 2017, 11:20am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
