<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="384281" data-post-id="384281">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Asd" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Asd
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="jstimps" data-post="14" data-topic="74409">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jstimps/48/37213_2.png" class="avatar"> jstimps:</div>
<blockquote>
<p>Thus, the state mutations are distributed across several nodes</p>
</blockquote>
</aside>
<p>Oh, so thats a <a href="https://en.wikipedia.org/wiki/State_machine_replication" rel="noopener nofollow ugc">replicated state machine</a> then. And this one is backed strictly by Foundation DB. There were some other projects which did similar replicated state machines on other databases, however I can’t remember any names</p>
<aside class="quote no-group" data-username="jstimps" data-post="14" data-topic="74409">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jstimps/48/37213_2.png" class="avatar"> jstimps:</div>
<blockquote>
<p>DGen is not saving Erlang process messages to a datastore. It saves the cast/call request portion only</p>
</blockquote>
</aside>
<p>Thats better, but still, I don’t understand why input must come from messages. If you had input provided into the state machine by a function call (not GenServer.call or cast), you could atomically add batches of input, you could perform dirty actions without this returning-the-closure pattern, you wouldn’t have a problem of some unexpected casts arriving, these messages having temporary data, etc.. And even if user wants to have input coming from messages, they could write their own wrapper GenServer which would have very explicit control on what gets added to the replicated state machine input queue and what gets ignored.</p>
<aside class="quote no-group" data-username="jstimps" data-post="14" data-topic="74409">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jstimps/48/37213_2.png" class="avatar"> jstimps:</div>
<blockquote>
<p>If the <code>DGenServer</code> module name is too bold, I welcome the requests to change it</p>
</blockquote>
</aside>
<p>I’d suggest something like FDBReplicatedStateMachine or fdb_rsm_server or FoundationReplicatedServer, because it describes what your program does. Key words here are “Replicated”, “State machine” and “FoundationDB”</p>
<hr>
<p>I am still reading the library code. So far, there is a lot of room for optimization. For example, there is unnecessary double await in <code>call</code>. There is <code>case dgen_queue:length(...) of 0 -&gt;</code> code, which can be optimized to not compute length and just check if empty</p>
<p>There are also some strange design decisions. For example, if <code>dgen_config:init</code> is not called, config will work, it will just ignore user provided values. And it makes it impossible to have two DGenServers with different backends.<br>
Next thing is that current <code>dgen_backend</code> behaviour simply matches <code>erlfdb</code> interface. I think that you should limit a behaviour and make it more generic, cause not all distributed databases support futures, directory and keyspace operations. Otherwise you won’t see any other backends in the future. For example, this sophisticated state encoding/decoding approach you’re using is only a subject to erlfdb implementation, because If I were to implement a postgres backend, I would not need this encoding approach</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="384281" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/dgen-a-distributed-genserver/74409/22">Post #21</a>
	                </div>
	            </div>
              <div id="likers-container-384281" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="384281"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #21"></div>
  </section>
</div>
    <div class="postbit" id="384282" data-post-id="384282">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="garrison" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  garrison
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Also, I think <a class="mention" href="/u/asd" rel="nofollow">@Asd</a> is probably right about the name making no sense, but there is a strong counterpoint to be made that calling the library “degen server” is <em>extremely</em> funny.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="384282" data-batch-url="/posts/batch_likers">
                        3
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/dgen-a-distributed-genserver/74409/23">Post #22</a>
	                </div>
	            </div>
              <div id="likers-container-384282" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="384282"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #22"></div>
  </section>
</div>
    <div class="postbit" id="384359" data-post-id="384359">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="alexandre" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/alexandre/120/678_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  alexandre
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>The original idea of a GenServer was that if there is a bug in execution state, it crashes and start over, to recover execution from a blank state.</p>
<p>If you start over with the same state, then you have the same bug. If you need persistence, why not just use a proper database?</p>
<p>I read everything, but still can’t get the point. Is it an experiment to learn?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="384359" data-batch-url="/posts/batch_likers">
                        3
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/dgen-a-distributed-genserver/74409/24">Post #23</a>
	                </div>
	            </div>
              <div id="likers-container-384359" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="384359"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #23"></div>
  </section>
</div>
    <div class="postbit" id="384573" data-post-id="384573">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="jstimps" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jstimps/120/37213_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  jstimps
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Thanks for taking the time to review the project.</p>
<aside class="quote no-group" data-username="Asd" data-post="22" data-topic="74409">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/a/c68b51/48.png" class="avatar"> Asd:</div>
<blockquote>
<p>I am still reading the library code. So far, there is a lot of room for optimization. For example, there is unnecessary double await in <code>call</code>.</p>
</blockquote>
</aside>
<p>w.r.t. the double await, I think you’re talking about <code>dgen:call/4</code>. The first wait is to a BEAM process. This puts the message onto the durable kv-queue and returns a sentinel key from which the caller can receive the final result. Given the current design, this is necessary because the caller doesn’t know the details about the queue’s identity. Via regular BEAM message passing, DGen allows anyone to push a message, as long as they have a pid, or can look one up. I could have instead chosen to represent the queue details in a struct that the caller must have in order to push. This choice would violate the premise, which was to mimic the GenServer interface, because I like it and find it useful for composing programs. You may disagree with the premise, which is fine, but this is not an unnecessary action.</p>
<p>The second wait in that <code>dgen:call/4</code> is receiving that final result, which comes from the server-pushed resolution of the watch future. In this case the message comes from the storage backend rather than the DGenServer process. The result of the operation is then retrieved.</p>
<aside class="quote no-group" data-username="Asd" data-post="22" data-topic="74409">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/a/c68b51/48.png" class="avatar"> Asd:</div>
<blockquote>
<p>There is <code>case dgen_queue:length(...) of 0 -&gt;</code> code, which can be optimized to not compute length and just check if empty</p>
</blockquote>
</aside>
<p>This is not correct. The length of <code>:dgen_queue</code> is computed by the difference of two values in the kv store = (number of pushes - number of pops). It does not have a key that represents “emptiness” of the queue. Adding such a key would force us to add more key conflicts to the push and pop functions. This would likely slow them down. As it stands now, we retrieve 2 values concurrently.</p>
<aside class="quote no-group" data-username="Asd" data-post="22" data-topic="74409">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/a/c68b51/48.png" class="avatar"> Asd:</div>
<blockquote>
<p>For example, if <code>dgen_config:init</code> is not called, config will work, it will just ignore user provided values. And it makes it impossible to have two DGenServers with different backends.</p>
</blockquote>
</aside>
<p>You’re right. It’s awkward and wrong.</p>
<aside class="quote no-group" data-username="Asd" data-post="22" data-topic="74409">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/a/c68b51/48.png" class="avatar"> Asd:</div>
<blockquote>
<p>Next thing is that current <code>dgen_backend</code> behaviour simply matches <code>erlfdb</code> interface.</p>
</blockquote>
</aside>
<p>I tried to be clear about this in the post: I don’t know how to put another backend in here, but I desperately want to, and the interface of <code>:dgen_backend</code> will definitely have to change a lot.</p>
<p>So why do this at all? I find FDB Layers useful. They can be composed into higher level abstractions, and it results in the most ergonomic state management I’ve ever worked in. However, they necessarily tie you to FDB. While I happily run FDB, I don’t want to forever. Since there are other great projects developing that are inspired by FDB, I hope DGen becomes a real Layer that can be compatible with those projects. A Postgres backend is not interesting - the community already has Oban.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="384573" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/dgen-a-distributed-genserver/74409/25">Post #24</a>
	                </div>
	            </div>
              <div id="likers-container-384573" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="384573"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #24"></div>
  </section>
</div>
    <div class="postbit" id="384575" data-post-id="384575">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="jstimps" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jstimps/120/37213_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  jstimps
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="alexandre" data-post="24" data-topic="74409">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/alexandre/48/678_2.png" class="avatar"> alexandre:</div>
<blockquote>
<p>The original idea of a GenServer was that if there is a bug in execution state, it crashes and start over, to recover execution from a blank state.</p>
</blockquote>
</aside>
<p>At risk of being overly pedantic, I’m going to challenge this, but only slightly. The original idea of <code>supervisor</code> is to do this, but <code>gen_server</code> itself is not opinionated about how, when, or why it’s restarted, or if it is at all.</p>
<p>Of course, the design of <code>gen_server</code> is amenable to being used by the <code>supervisor</code> in a powerful and useful way, just like you describe. I’m a direct beneficiary of the genius design of this simple idea.</p>
<p>DGenServer breaks the rules a little bit. It can still be stopped and restarted by the supervisor, but if a poison message is the result of the crash, it may very well require an operator to intervene - either by correcting database state, fixing a bug in the code, or changing some upstream service. I agree this is a weakness in the design.</p>
<aside class="quote no-group" data-username="alexandre" data-post="24" data-topic="74409">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/alexandre/48/678_2.png" class="avatar"> alexandre:</div>
<blockquote>
<p>If you need persistence, why not just use a proper database?</p>
</blockquote>
</aside>
<p>This is dismissing FoundationDB as a proper database. Why?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="384575" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/dgen-a-distributed-genserver/74409/26">Post #25</a>
	                </div>
	            </div>
              <div id="likers-container-384575" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="384575"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #25"></div>
  </section>
</div>
    <div class="postbit" id="384577" data-post-id="384577">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="derek-zhou" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/derek-zhou/120/19943_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  derek-zhou
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group quote-modified" data-username="jstimps" data-post="26" data-topic="74409">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jstimps/48/37213_2.png" class="avatar"> jstimps:</div>
<blockquote>
<aside class="quote no-group" data-username="alexandre" data-post="24" data-topic="74409">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/alexandre/48/678_2.png" class="avatar"> alexandre:</div>
<blockquote>
<p>If you need persistence, why not just use a proper database?</p>
</blockquote>
</aside>
<p>This is dismissing FoundationDB as a proper database. Why?</p>
</blockquote>
</aside>
<p>This is a prime example of why asking a one-line “why” question in a forum is such a bad idea. I am sure both of you have good intentions, but because of the lack of common context, trading a bunch of short “why” questions will only steer the discussion further away from truth seeking.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="384577" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/dgen-a-distributed-genserver/74409/27">Post #26</a>
	                </div>
	            </div>
              <div id="likers-container-384577" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="384577"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #26"></div>
  </section>
</div>
    <div class="postbit" id="384579" data-post-id="384579">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="alexandre" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/alexandre/120/678_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  alexandre
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="jstimps" data-post="26" data-topic="74409">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jstimps/48/37213_2.png" class="avatar"> jstimps:</div>
<blockquote>
<p>This is dismissing FoundationDB as a proper database. Why?</p>
</blockquote>
</aside>
<p>Oh not at all. It can be FoundationDB for sure. That was dismissing gen_server as a proper database.</p>
<p>Now I understand the idea further, thanks a lot for taking the time to explain!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="384579" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/dgen-a-distributed-genserver/74409/28">Post #27</a>
	                </div>
	            </div>
              <div id="likers-container-384579" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="384579"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #27"></div>
  </section>
</div>
    <div class="postbit" id="385120" data-post-id="385120">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="garrison" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  garrison
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Indeed, any stateful program will be at risk of persisting a bugged state. This leads to the uncomfortable realization that one of Erlang’s core ideas is probably wrong, or at least inadequate for large swaths of real-world programs. Aggressive correctness testing (FoundationDB is a good example) is a more fruitful path to ensuring that such states are unreachable.</p>
<p>Another fruitful path is to structure your code in such a way that bugged states are less likely to arise. Programming in a declarative style, where the program rebuilds its state by re-executing itself from the top rather than transitioning between states through piecemeal manipulation, is a helpful strategy. OTP supervisors offer a form of this, but they are fairly primitive. React’s engine is a much more sophisticated tool in this area, as it allows for stateful components with incremental execution and has escape hatches to integrate with non-incremental code.</p>
<p>Something that looks less like a state machine and more like a React (function) component is what I would like to see. But all experimentation is valuable, and what’s special about the “layers” paradigm is that it enables experimentation. You do not one-shot great tools, they are evolved.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="385120" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/dgen-a-distributed-genserver/74409/29">Post #28</a>
	                </div>
	            </div>
              <div id="likers-container-385120" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="385120"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #28"></div>
  </section>
</div>
    <div class="postbit" id="385144" data-post-id="385144">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="hauleth" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/hauleth/120/18942_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  hauleth
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="garrison" data-post="29" data-topic="74409">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/g/3bc359/48.png" class="avatar"> garrison:</div>
<blockquote>
<p>one of Erlang’s core ideas is probably wrong, or at least inadequate for large swaths of real-world programs</p>
</blockquote>
</aside>
<p>How did you come up with that idea? The point of supervisors in Erlang is that if there is abnormal state, then it is better to restart and start again with <em>known</em> state. Just like restarting a computer with borked state in RAM.</p>
<p>So you do not restart to previous state, as this indeed would be pointless, but you restart to “clean” state in hope, that it was one-time error that was out of your control.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="385144" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/dgen-a-distributed-genserver/74409/30">Post #29</a>
	                </div>
	            </div>
              <div id="likers-container-385144" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="385144"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #29"></div>
  </section>
</div>
    <div class="postbit" id="385147" data-post-id="385147">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="mudasobwa" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/mudasobwa/120/5298_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  mudasobwa
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Creator of Cure</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="hauleth" data-post="30" data-topic="74409">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/hauleth/48/18942_2.png" class="avatar"> hauleth:</div>
<blockquote>
<p>you do not restart to previous state, as this indeed would be pointless, but you restart to “clean” state</p>
</blockquote>
</aside>
<p>There is no such a dichotomy in there.</p>
<p>The error might be provoked by wrong message sent to the process, not by the project inner state in the first place. In such a case it makes total sense to restart preserving the latest state.</p>
<p>The error might be provoked by a wrong state+message combination.</p>
<p>Andalso, the error might be provoked by the wrong state indeed, but the previous state was all right and it might make sense to rollback to this “previous” state rather than to the point blank one.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="385147" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/dgen-a-distributed-genserver/74409/31">Post #30</a>
	                </div>
	            </div>
              <div id="likers-container-385147" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="385147"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #30"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <a class="load-more-button" data-turbo-stream="true" href="/topics/74409/load_more?page=4">Load more posts (11 remaining)</a>
</div></template></turbo-stream>