title: Reading from RavenDb immediately after writing to it returns inconsistent data
body: <p>I have a reconciliation process where by a background thread that periodically retrieves a list of object ids from an external webservice and attempts to add the missing entities to an embedded RavenDb database. The loop that performs this process is the following:</p>
  
  <pre><code>foreach (var pageId in listOfPageIds)
  {
      if ( _contentService.GetPageByPageId(pageId) == null)
      {
          _contentService.AddPage(pageId);
      }
  }
  </code></pre>
  
  <p>the implementation of the <code>GetPageByPageId()</code> and <code>AddPage()</code> are as follows:</p>
  
  <pre><code>public Page GetPageByPageId(string pageId)
  {
      using (var session = DocumentStore.OpenSession())
      {
          return session.Query&lt;Page&gt;().FirstOrDefault(page =&gt; page.PageId == pageId);
      }
  }
  
  public bool AddPage(string pageId)
  {
      var page = GetPageByPageId(pageId);
      if (page != null)
      {
          return false;
      }
      using (var session = DocumentStore.OpenSession())
      {
          var newPage = new Page() {PageId = pageId};
          session.Store(newPage);
          session.SaveChanges();
      }
      return true;
  }
  </code></pre>
  
  <p>The problem is that if the list has duplicate ids, once it adds the first id and checks for that id again, the result comes back as empty. It is as if a finalization step is missing that would register the newly added entity. If I query the set from a different thread at a later time, the entity with that given id is returned. Can anyone see what the issue is here?</p>
  
  <p>thanks,  </p>