@@ -295,11 +295,17 @@ type participationDB struct {
295295 flushesPending int
296296}
297297
298+ type updatingParticipationRecord struct {
299+ ParticipationRecord
300+
301+ required bool
302+ }
303+
298304type partDBWriteRecord struct {
299305 insertID ParticipationID
300306 insert Participation
301307
302- registerUpdated map [ParticipationID ]ParticipationRecord
308+ registerUpdated map [ParticipationID ]updatingParticipationRecord
303309
304310 delete ParticipationID
305311
@@ -417,16 +423,19 @@ func (db *participationDB) insertInner(record Participation, id ParticipationID)
417423 return err
418424}
419425
420- func (db * participationDB ) registerInner (updated map [ParticipationID ]ParticipationRecord ) error {
426+ func (db * participationDB ) registerInner (updated map [ParticipationID ]updatingParticipationRecord ) error {
421427 var cacheDeletes []ParticipationID
422428 err := db .store .Wdb .Atomic (func (ctx context.Context , tx * sql.Tx ) error {
423429 // Disable active key if there is one
424430 for id , record := range updated {
425- err := updateRollingFields (ctx , tx , record )
431+ err := updateRollingFields (ctx , tx , record . ParticipationRecord )
426432 // Repair the case when no keys were updated
427433 if err == ErrNoKeyForID {
428434 db .log .Warn ("participationDB unable to update key in cache. Removing from cache." )
429435 cacheDeletes = append (cacheDeletes , id )
436+ if ! record .required {
437+ err = nil
438+ }
430439 }
431440 if err != nil {
432441 return fmt .Errorf ("unable to disable old key when registering %s: %w" , id , err )
@@ -723,18 +732,24 @@ func (db *participationDB) Register(id ParticipationID, on basics.Round) error {
723732 }
724733 db .mutex .Unlock ()
725734
726- updated := make (map [ParticipationID ]ParticipationRecord )
735+ updated := make (map [ParticipationID ]updatingParticipationRecord )
727736
728737 // Disable active key if there is one
729738 for _ , record := range toUpdate {
730739 // TODO: this should probably be "on - 1"
731740 record .EffectiveLast = on
732- updated [record .ParticipationID ] = record .Duplicate ()
741+ updated [record .ParticipationID ] = updatingParticipationRecord {
742+ record .Duplicate (),
743+ false ,
744+ }
733745 }
734746 // Mark registered.
735747 recordToRegister .EffectiveFirst = on
736748 recordToRegister .EffectiveLast = recordToRegister .LastValid
737- updated [recordToRegister .ParticipationID ] = recordToRegister
749+ updated [recordToRegister .ParticipationID ] = updatingParticipationRecord {
750+ recordToRegister ,
751+ true ,
752+ }
738753
739754 if len (updated ) != 0 {
740755 db .writeQueue <- partDBWriteRecord {
@@ -743,7 +758,7 @@ func (db *participationDB) Register(id ParticipationID, on basics.Round) error {
743758 db .mutex .Lock ()
744759 for id , record := range updated {
745760 delete (db .dirty , id )
746- db .cache [id ] = record
761+ db .cache [id ] = record . ParticipationRecord
747762 }
748763 db .mutex .Unlock ()
749764 }
0 commit comments