@@ -161,53 +161,45 @@ func (s *prollyWriteSession) SetOptions(opts editor.Options) {
161161// flush is the inner implementation for Flush that does not acquire any locks
162162func (s * prollyWriteSession ) flush (ctx * sql.Context , autoIncSet bool , manualAutoIncrementsSettings map [string ]uint64 ) (* doltdb.WorkingSet , error ) {
163163 tables := make (map [doltdb.TableName ]* doltdb.Table , len (s .tables ))
164- mu := & sync.Mutex {}
165164
166165 eg , egCtx := errgroup .WithContext (ctx )
167166 sqlEgCtx := ctx .WithContext (egCtx )
168167
169168 for n := range s .tables {
170- name := n // make a copy
171- eg .Go (func () error {
172- wr := s .tables [name ]
173- t , err := wr .table (sqlEgCtx )
169+ wr := s .tables [n ]
170+ t , err := wr .table (sqlEgCtx )
171+ if err != nil {
172+ return nil , err
173+ }
174+
175+ // Update this table's auto increment value if it has one. This value comes from the global state unless an
176+ // override was specified (e.g. if the next value was set explicitly)
177+ if schema .HasAutoIncrement (wr .sch ) {
178+ // TODO: need schema name for auto increment
179+ autoIncVal , err := s .aiTracker .Current (n .Name )
174180 if err != nil {
175- return err
181+ return nil , err
182+ }
183+ override , hasManuallySetAi := manualAutoIncrementsSettings [n .Name ]
184+ if hasManuallySetAi {
185+ autoIncVal = override
176186 }
177187
178- // Update this table's auto increment value if it has one. This value comes from the global state unless an
179- // override was specified (e.g. if the next value was set explicitly)
180- if schema .HasAutoIncrement (wr .sch ) {
181- // TODO: need schema name for auto increment
182- autoIncVal , err := s .aiTracker .Current (name .Name )
188+ // Update the table with the new auto-inc value if necessary. If it was set manually via an ALTER TABLE
189+ // statement, we defer to the tracker to update the value itself, since this impacts the global state.
190+ if hasManuallySetAi {
191+ t , err = s .aiTracker .Set (sqlEgCtx , n .Name , t , s .workingSet .Ref (), autoIncVal )
183192 if err != nil {
184- return err
193+ return nil , err
185194 }
186- override , hasManuallySetAi := manualAutoIncrementsSettings [name .Name ]
187- if hasManuallySetAi {
188- autoIncVal = override
189- }
190-
191- // Update the table with the new auto-inc value if necessary. If it was set manually via an ALTER TABLE
192- // statement, we defer to the tracker to update the value itself, since this impacts the global state.
193- if hasManuallySetAi {
194- t , err = s .aiTracker .Set (sqlEgCtx , name .Name , t , s .workingSet .Ref (), autoIncVal )
195- if err != nil {
196- return err
197- }
198- } else if autoIncSet {
199- t , err = t .SetAutoIncrementValue (sqlEgCtx , autoIncVal )
200- if err != nil {
201- return err
202- }
195+ } else if autoIncSet {
196+ t , err = t .SetAutoIncrementValue (sqlEgCtx , autoIncVal )
197+ if err != nil {
198+ return nil , err
203199 }
204200 }
205-
206- mu .Lock ()
207- defer mu .Unlock ()
208- tables [name ] = t
209- return nil
210- })
201+ }
202+ tables [n ] = t
211203 }
212204 if err := eg .Wait (); err != nil {
213205 return nil , err
0 commit comments