code: func (s *session) commit(r *sessionRecord, trivial bool) (err error) {
  	v := s.version()
  	defer v.release()
  
  	// spawn new version based on current version
  	nv := v.spawn(r, trivial)
  
  	// abandon useless version id to prevent blocking version processing loop.
  	defer func() {
  		if err != nil {
  			s.abandon <- nv.id
  			s.logf("commit@abandon useless vid D%d", nv.id)
  		}
  	}()
  
  	if s.manifest == nil {
  		// manifest journal writer not yet created, create one
  		err = s.newManifest(r, nv)
  	} else {
  		err = s.flushManifest(r)
  	}
  
  	// finally, apply new version if no error rise
  	if err == nil {
  		s.setVersion(r, nv)
  	}
  
  	return
  }
docs: // Commit session; need external synchronization.