github.com/haalcala/mattermost-server-change-repo/v5@v5.33.2/store/retrylayer/retrylayer.go (about)

     1  // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
     2  // See LICENSE.txt for license information.
     3  
     4  // Code generated by "make store-layers"
     5  // DO NOT EDIT
     6  
     7  package retrylayer
     8  
     9  import (
    10  	"context"
    11  
    12  	"github.com/go-sql-driver/mysql"
    13  	"github.com/lib/pq"
    14  	"github.com/mattermost/mattermost-server/v5/model"
    15  	"github.com/mattermost/mattermost-server/v5/store"
    16  	"github.com/pkg/errors"
    17  )
    18  
    19  const mySQLDeadlockCode = uint16(1213)
    20  
    21  type RetryLayer struct {
    22  	store.Store
    23  	AuditStore                store.AuditStore
    24  	BotStore                  store.BotStore
    25  	ChannelStore              store.ChannelStore
    26  	ChannelMemberHistoryStore store.ChannelMemberHistoryStore
    27  	ClusterDiscoveryStore     store.ClusterDiscoveryStore
    28  	CommandStore              store.CommandStore
    29  	CommandWebhookStore       store.CommandWebhookStore
    30  	ComplianceStore           store.ComplianceStore
    31  	EmojiStore                store.EmojiStore
    32  	FileInfoStore             store.FileInfoStore
    33  	GroupStore                store.GroupStore
    34  	JobStore                  store.JobStore
    35  	LicenseStore              store.LicenseStore
    36  	LinkMetadataStore         store.LinkMetadataStore
    37  	OAuthStore                store.OAuthStore
    38  	PluginStore               store.PluginStore
    39  	PostStore                 store.PostStore
    40  	PreferenceStore           store.PreferenceStore
    41  	ProductNoticesStore       store.ProductNoticesStore
    42  	ReactionStore             store.ReactionStore
    43  	RoleStore                 store.RoleStore
    44  	SchemeStore               store.SchemeStore
    45  	SessionStore              store.SessionStore
    46  	StatusStore               store.StatusStore
    47  	SystemStore               store.SystemStore
    48  	TeamStore                 store.TeamStore
    49  	TermsOfServiceStore       store.TermsOfServiceStore
    50  	ThreadStore               store.ThreadStore
    51  	TokenStore                store.TokenStore
    52  	UploadSessionStore        store.UploadSessionStore
    53  	UserStore                 store.UserStore
    54  	UserAccessTokenStore      store.UserAccessTokenStore
    55  	UserTermsOfServiceStore   store.UserTermsOfServiceStore
    56  	WebhookStore              store.WebhookStore
    57  }
    58  
    59  func (s *RetryLayer) Audit() store.AuditStore {
    60  	return s.AuditStore
    61  }
    62  
    63  func (s *RetryLayer) Bot() store.BotStore {
    64  	return s.BotStore
    65  }
    66  
    67  func (s *RetryLayer) Channel() store.ChannelStore {
    68  	return s.ChannelStore
    69  }
    70  
    71  func (s *RetryLayer) ChannelMemberHistory() store.ChannelMemberHistoryStore {
    72  	return s.ChannelMemberHistoryStore
    73  }
    74  
    75  func (s *RetryLayer) ClusterDiscovery() store.ClusterDiscoveryStore {
    76  	return s.ClusterDiscoveryStore
    77  }
    78  
    79  func (s *RetryLayer) Command() store.CommandStore {
    80  	return s.CommandStore
    81  }
    82  
    83  func (s *RetryLayer) CommandWebhook() store.CommandWebhookStore {
    84  	return s.CommandWebhookStore
    85  }
    86  
    87  func (s *RetryLayer) Compliance() store.ComplianceStore {
    88  	return s.ComplianceStore
    89  }
    90  
    91  func (s *RetryLayer) Emoji() store.EmojiStore {
    92  	return s.EmojiStore
    93  }
    94  
    95  func (s *RetryLayer) FileInfo() store.FileInfoStore {
    96  	return s.FileInfoStore
    97  }
    98  
    99  func (s *RetryLayer) Group() store.GroupStore {
   100  	return s.GroupStore
   101  }
   102  
   103  func (s *RetryLayer) Job() store.JobStore {
   104  	return s.JobStore
   105  }
   106  
   107  func (s *RetryLayer) License() store.LicenseStore {
   108  	return s.LicenseStore
   109  }
   110  
   111  func (s *RetryLayer) LinkMetadata() store.LinkMetadataStore {
   112  	return s.LinkMetadataStore
   113  }
   114  
   115  func (s *RetryLayer) OAuth() store.OAuthStore {
   116  	return s.OAuthStore
   117  }
   118  
   119  func (s *RetryLayer) Plugin() store.PluginStore {
   120  	return s.PluginStore
   121  }
   122  
   123  func (s *RetryLayer) Post() store.PostStore {
   124  	return s.PostStore
   125  }
   126  
   127  func (s *RetryLayer) Preference() store.PreferenceStore {
   128  	return s.PreferenceStore
   129  }
   130  
   131  func (s *RetryLayer) ProductNotices() store.ProductNoticesStore {
   132  	return s.ProductNoticesStore
   133  }
   134  
   135  func (s *RetryLayer) Reaction() store.ReactionStore {
   136  	return s.ReactionStore
   137  }
   138  
   139  func (s *RetryLayer) Role() store.RoleStore {
   140  	return s.RoleStore
   141  }
   142  
   143  func (s *RetryLayer) Scheme() store.SchemeStore {
   144  	return s.SchemeStore
   145  }
   146  
   147  func (s *RetryLayer) Session() store.SessionStore {
   148  	return s.SessionStore
   149  }
   150  
   151  func (s *RetryLayer) Status() store.StatusStore {
   152  	return s.StatusStore
   153  }
   154  
   155  func (s *RetryLayer) System() store.SystemStore {
   156  	return s.SystemStore
   157  }
   158  
   159  func (s *RetryLayer) Team() store.TeamStore {
   160  	return s.TeamStore
   161  }
   162  
   163  func (s *RetryLayer) TermsOfService() store.TermsOfServiceStore {
   164  	return s.TermsOfServiceStore
   165  }
   166  
   167  func (s *RetryLayer) Thread() store.ThreadStore {
   168  	return s.ThreadStore
   169  }
   170  
   171  func (s *RetryLayer) Token() store.TokenStore {
   172  	return s.TokenStore
   173  }
   174  
   175  func (s *RetryLayer) UploadSession() store.UploadSessionStore {
   176  	return s.UploadSessionStore
   177  }
   178  
   179  func (s *RetryLayer) User() store.UserStore {
   180  	return s.UserStore
   181  }
   182  
   183  func (s *RetryLayer) UserAccessToken() store.UserAccessTokenStore {
   184  	return s.UserAccessTokenStore
   185  }
   186  
   187  func (s *RetryLayer) UserTermsOfService() store.UserTermsOfServiceStore {
   188  	return s.UserTermsOfServiceStore
   189  }
   190  
   191  func (s *RetryLayer) Webhook() store.WebhookStore {
   192  	return s.WebhookStore
   193  }
   194  
   195  type RetryLayerAuditStore struct {
   196  	store.AuditStore
   197  	Root *RetryLayer
   198  }
   199  
   200  type RetryLayerBotStore struct {
   201  	store.BotStore
   202  	Root *RetryLayer
   203  }
   204  
   205  type RetryLayerChannelStore struct {
   206  	store.ChannelStore
   207  	Root *RetryLayer
   208  }
   209  
   210  type RetryLayerChannelMemberHistoryStore struct {
   211  	store.ChannelMemberHistoryStore
   212  	Root *RetryLayer
   213  }
   214  
   215  type RetryLayerClusterDiscoveryStore struct {
   216  	store.ClusterDiscoveryStore
   217  	Root *RetryLayer
   218  }
   219  
   220  type RetryLayerCommandStore struct {
   221  	store.CommandStore
   222  	Root *RetryLayer
   223  }
   224  
   225  type RetryLayerCommandWebhookStore struct {
   226  	store.CommandWebhookStore
   227  	Root *RetryLayer
   228  }
   229  
   230  type RetryLayerComplianceStore struct {
   231  	store.ComplianceStore
   232  	Root *RetryLayer
   233  }
   234  
   235  type RetryLayerEmojiStore struct {
   236  	store.EmojiStore
   237  	Root *RetryLayer
   238  }
   239  
   240  type RetryLayerFileInfoStore struct {
   241  	store.FileInfoStore
   242  	Root *RetryLayer
   243  }
   244  
   245  type RetryLayerGroupStore struct {
   246  	store.GroupStore
   247  	Root *RetryLayer
   248  }
   249  
   250  type RetryLayerJobStore struct {
   251  	store.JobStore
   252  	Root *RetryLayer
   253  }
   254  
   255  type RetryLayerLicenseStore struct {
   256  	store.LicenseStore
   257  	Root *RetryLayer
   258  }
   259  
   260  type RetryLayerLinkMetadataStore struct {
   261  	store.LinkMetadataStore
   262  	Root *RetryLayer
   263  }
   264  
   265  type RetryLayerOAuthStore struct {
   266  	store.OAuthStore
   267  	Root *RetryLayer
   268  }
   269  
   270  type RetryLayerPluginStore struct {
   271  	store.PluginStore
   272  	Root *RetryLayer
   273  }
   274  
   275  type RetryLayerPostStore struct {
   276  	store.PostStore
   277  	Root *RetryLayer
   278  }
   279  
   280  type RetryLayerPreferenceStore struct {
   281  	store.PreferenceStore
   282  	Root *RetryLayer
   283  }
   284  
   285  type RetryLayerProductNoticesStore struct {
   286  	store.ProductNoticesStore
   287  	Root *RetryLayer
   288  }
   289  
   290  type RetryLayerReactionStore struct {
   291  	store.ReactionStore
   292  	Root *RetryLayer
   293  }
   294  
   295  type RetryLayerRoleStore struct {
   296  	store.RoleStore
   297  	Root *RetryLayer
   298  }
   299  
   300  type RetryLayerSchemeStore struct {
   301  	store.SchemeStore
   302  	Root *RetryLayer
   303  }
   304  
   305  type RetryLayerSessionStore struct {
   306  	store.SessionStore
   307  	Root *RetryLayer
   308  }
   309  
   310  type RetryLayerStatusStore struct {
   311  	store.StatusStore
   312  	Root *RetryLayer
   313  }
   314  
   315  type RetryLayerSystemStore struct {
   316  	store.SystemStore
   317  	Root *RetryLayer
   318  }
   319  
   320  type RetryLayerTeamStore struct {
   321  	store.TeamStore
   322  	Root *RetryLayer
   323  }
   324  
   325  type RetryLayerTermsOfServiceStore struct {
   326  	store.TermsOfServiceStore
   327  	Root *RetryLayer
   328  }
   329  
   330  type RetryLayerThreadStore struct {
   331  	store.ThreadStore
   332  	Root *RetryLayer
   333  }
   334  
   335  type RetryLayerTokenStore struct {
   336  	store.TokenStore
   337  	Root *RetryLayer
   338  }
   339  
   340  type RetryLayerUploadSessionStore struct {
   341  	store.UploadSessionStore
   342  	Root *RetryLayer
   343  }
   344  
   345  type RetryLayerUserStore struct {
   346  	store.UserStore
   347  	Root *RetryLayer
   348  }
   349  
   350  type RetryLayerUserAccessTokenStore struct {
   351  	store.UserAccessTokenStore
   352  	Root *RetryLayer
   353  }
   354  
   355  type RetryLayerUserTermsOfServiceStore struct {
   356  	store.UserTermsOfServiceStore
   357  	Root *RetryLayer
   358  }
   359  
   360  type RetryLayerWebhookStore struct {
   361  	store.WebhookStore
   362  	Root *RetryLayer
   363  }
   364  
   365  func isRepeatableError(err error) bool {
   366  	var pqErr *pq.Error
   367  	var mysqlErr *mysql.MySQLError
   368  	switch {
   369  	case errors.As(errors.Cause(err), &pqErr):
   370  		if pqErr.Code == "40001" || pqErr.Code == "40P01" {
   371  			return true
   372  		}
   373  	case errors.As(errors.Cause(err), &mysqlErr):
   374  		if mysqlErr.Number == mySQLDeadlockCode {
   375  			return true
   376  		}
   377  	}
   378  	return false
   379  }
   380  
   381  func (s *RetryLayerAuditStore) Get(user_id string, offset int, limit int) (model.Audits, error) {
   382  
   383  	tries := 0
   384  	for {
   385  		result, err := s.AuditStore.Get(user_id, offset, limit)
   386  		if err == nil {
   387  			return result, nil
   388  		}
   389  		if !isRepeatableError(err) {
   390  			return result, err
   391  		}
   392  		tries++
   393  		if tries >= 3 {
   394  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
   395  			return result, err
   396  		}
   397  	}
   398  
   399  }
   400  
   401  func (s *RetryLayerAuditStore) PermanentDeleteByUser(userId string) error {
   402  
   403  	tries := 0
   404  	for {
   405  		err := s.AuditStore.PermanentDeleteByUser(userId)
   406  		if err == nil {
   407  			return nil
   408  		}
   409  		if !isRepeatableError(err) {
   410  			return err
   411  		}
   412  		tries++
   413  		if tries >= 3 {
   414  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
   415  			return err
   416  		}
   417  	}
   418  
   419  }
   420  
   421  func (s *RetryLayerAuditStore) Save(audit *model.Audit) error {
   422  
   423  	tries := 0
   424  	for {
   425  		err := s.AuditStore.Save(audit)
   426  		if err == nil {
   427  			return nil
   428  		}
   429  		if !isRepeatableError(err) {
   430  			return err
   431  		}
   432  		tries++
   433  		if tries >= 3 {
   434  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
   435  			return err
   436  		}
   437  	}
   438  
   439  }
   440  
   441  func (s *RetryLayerBotStore) Get(userId string, includeDeleted bool) (*model.Bot, error) {
   442  
   443  	tries := 0
   444  	for {
   445  		result, err := s.BotStore.Get(userId, includeDeleted)
   446  		if err == nil {
   447  			return result, nil
   448  		}
   449  		if !isRepeatableError(err) {
   450  			return result, err
   451  		}
   452  		tries++
   453  		if tries >= 3 {
   454  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
   455  			return result, err
   456  		}
   457  	}
   458  
   459  }
   460  
   461  func (s *RetryLayerBotStore) GetAll(options *model.BotGetOptions) ([]*model.Bot, error) {
   462  
   463  	tries := 0
   464  	for {
   465  		result, err := s.BotStore.GetAll(options)
   466  		if err == nil {
   467  			return result, nil
   468  		}
   469  		if !isRepeatableError(err) {
   470  			return result, err
   471  		}
   472  		tries++
   473  		if tries >= 3 {
   474  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
   475  			return result, err
   476  		}
   477  	}
   478  
   479  }
   480  
   481  func (s *RetryLayerBotStore) PermanentDelete(userId string) error {
   482  
   483  	tries := 0
   484  	for {
   485  		err := s.BotStore.PermanentDelete(userId)
   486  		if err == nil {
   487  			return nil
   488  		}
   489  		if !isRepeatableError(err) {
   490  			return err
   491  		}
   492  		tries++
   493  		if tries >= 3 {
   494  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
   495  			return err
   496  		}
   497  	}
   498  
   499  }
   500  
   501  func (s *RetryLayerBotStore) Save(bot *model.Bot) (*model.Bot, error) {
   502  
   503  	tries := 0
   504  	for {
   505  		result, err := s.BotStore.Save(bot)
   506  		if err == nil {
   507  			return result, nil
   508  		}
   509  		if !isRepeatableError(err) {
   510  			return result, err
   511  		}
   512  		tries++
   513  		if tries >= 3 {
   514  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
   515  			return result, err
   516  		}
   517  	}
   518  
   519  }
   520  
   521  func (s *RetryLayerBotStore) Update(bot *model.Bot) (*model.Bot, error) {
   522  
   523  	tries := 0
   524  	for {
   525  		result, err := s.BotStore.Update(bot)
   526  		if err == nil {
   527  			return result, nil
   528  		}
   529  		if !isRepeatableError(err) {
   530  			return result, err
   531  		}
   532  		tries++
   533  		if tries >= 3 {
   534  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
   535  			return result, err
   536  		}
   537  	}
   538  
   539  }
   540  
   541  func (s *RetryLayerChannelStore) AnalyticsDeletedTypeCount(teamId string, channelType string) (int64, error) {
   542  
   543  	tries := 0
   544  	for {
   545  		result, err := s.ChannelStore.AnalyticsDeletedTypeCount(teamId, channelType)
   546  		if err == nil {
   547  			return result, nil
   548  		}
   549  		if !isRepeatableError(err) {
   550  			return result, err
   551  		}
   552  		tries++
   553  		if tries >= 3 {
   554  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
   555  			return result, err
   556  		}
   557  	}
   558  
   559  }
   560  
   561  func (s *RetryLayerChannelStore) AnalyticsTypeCount(teamId string, channelType string) (int64, error) {
   562  
   563  	tries := 0
   564  	for {
   565  		result, err := s.ChannelStore.AnalyticsTypeCount(teamId, channelType)
   566  		if err == nil {
   567  			return result, nil
   568  		}
   569  		if !isRepeatableError(err) {
   570  			return result, err
   571  		}
   572  		tries++
   573  		if tries >= 3 {
   574  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
   575  			return result, err
   576  		}
   577  	}
   578  
   579  }
   580  
   581  func (s *RetryLayerChannelStore) AutocompleteInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, error) {
   582  
   583  	tries := 0
   584  	for {
   585  		result, err := s.ChannelStore.AutocompleteInTeam(teamId, term, includeDeleted)
   586  		if err == nil {
   587  			return result, nil
   588  		}
   589  		if !isRepeatableError(err) {
   590  			return result, err
   591  		}
   592  		tries++
   593  		if tries >= 3 {
   594  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
   595  			return result, err
   596  		}
   597  	}
   598  
   599  }
   600  
   601  func (s *RetryLayerChannelStore) AutocompleteInTeamForSearch(teamId string, userId string, term string, includeDeleted bool) (*model.ChannelList, error) {
   602  
   603  	tries := 0
   604  	for {
   605  		result, err := s.ChannelStore.AutocompleteInTeamForSearch(teamId, userId, term, includeDeleted)
   606  		if err == nil {
   607  			return result, nil
   608  		}
   609  		if !isRepeatableError(err) {
   610  			return result, err
   611  		}
   612  		tries++
   613  		if tries >= 3 {
   614  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
   615  			return result, err
   616  		}
   617  	}
   618  
   619  }
   620  
   621  func (s *RetryLayerChannelStore) ClearAllCustomRoleAssignments() error {
   622  
   623  	tries := 0
   624  	for {
   625  		err := s.ChannelStore.ClearAllCustomRoleAssignments()
   626  		if err == nil {
   627  			return nil
   628  		}
   629  		if !isRepeatableError(err) {
   630  			return err
   631  		}
   632  		tries++
   633  		if tries >= 3 {
   634  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
   635  			return err
   636  		}
   637  	}
   638  
   639  }
   640  
   641  func (s *RetryLayerChannelStore) ClearCaches() {
   642  
   643  	s.ChannelStore.ClearCaches()
   644  
   645  }
   646  
   647  func (s *RetryLayerChannelStore) ClearSidebarOnTeamLeave(userId string, teamId string) error {
   648  
   649  	tries := 0
   650  	for {
   651  		err := s.ChannelStore.ClearSidebarOnTeamLeave(userId, teamId)
   652  		if err == nil {
   653  			return nil
   654  		}
   655  		if !isRepeatableError(err) {
   656  			return err
   657  		}
   658  		tries++
   659  		if tries >= 3 {
   660  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
   661  			return err
   662  		}
   663  	}
   664  
   665  }
   666  
   667  func (s *RetryLayerChannelStore) CountPostsAfter(channelId string, timestamp int64, userId string) (int, error) {
   668  
   669  	tries := 0
   670  	for {
   671  		result, err := s.ChannelStore.CountPostsAfter(channelId, timestamp, userId)
   672  		if err == nil {
   673  			return result, nil
   674  		}
   675  		if !isRepeatableError(err) {
   676  			return result, err
   677  		}
   678  		tries++
   679  		if tries >= 3 {
   680  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
   681  			return result, err
   682  		}
   683  	}
   684  
   685  }
   686  
   687  func (s *RetryLayerChannelStore) CreateDirectChannel(userId *model.User, otherUserId *model.User) (*model.Channel, error) {
   688  
   689  	tries := 0
   690  	for {
   691  		result, err := s.ChannelStore.CreateDirectChannel(userId, otherUserId)
   692  		if err == nil {
   693  			return result, nil
   694  		}
   695  		if !isRepeatableError(err) {
   696  			return result, err
   697  		}
   698  		tries++
   699  		if tries >= 3 {
   700  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
   701  			return result, err
   702  		}
   703  	}
   704  
   705  }
   706  
   707  func (s *RetryLayerChannelStore) CreateInitialSidebarCategories(userId string, teamId string) error {
   708  
   709  	tries := 0
   710  	for {
   711  		err := s.ChannelStore.CreateInitialSidebarCategories(userId, teamId)
   712  		if err == nil {
   713  			return nil
   714  		}
   715  		if !isRepeatableError(err) {
   716  			return err
   717  		}
   718  		tries++
   719  		if tries >= 3 {
   720  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
   721  			return err
   722  		}
   723  	}
   724  
   725  }
   726  
   727  func (s *RetryLayerChannelStore) CreateSidebarCategory(userId string, teamId string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, error) {
   728  
   729  	tries := 0
   730  	for {
   731  		result, err := s.ChannelStore.CreateSidebarCategory(userId, teamId, newCategory)
   732  		if err == nil {
   733  			return result, nil
   734  		}
   735  		if !isRepeatableError(err) {
   736  			return result, err
   737  		}
   738  		tries++
   739  		if tries >= 3 {
   740  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
   741  			return result, err
   742  		}
   743  	}
   744  
   745  }
   746  
   747  func (s *RetryLayerChannelStore) Delete(channelId string, time int64) error {
   748  
   749  	tries := 0
   750  	for {
   751  		err := s.ChannelStore.Delete(channelId, time)
   752  		if err == nil {
   753  			return nil
   754  		}
   755  		if !isRepeatableError(err) {
   756  			return err
   757  		}
   758  		tries++
   759  		if tries >= 3 {
   760  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
   761  			return err
   762  		}
   763  	}
   764  
   765  }
   766  
   767  func (s *RetryLayerChannelStore) DeleteSidebarCategory(categoryId string) error {
   768  
   769  	tries := 0
   770  	for {
   771  		err := s.ChannelStore.DeleteSidebarCategory(categoryId)
   772  		if err == nil {
   773  			return nil
   774  		}
   775  		if !isRepeatableError(err) {
   776  			return err
   777  		}
   778  		tries++
   779  		if tries >= 3 {
   780  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
   781  			return err
   782  		}
   783  	}
   784  
   785  }
   786  
   787  func (s *RetryLayerChannelStore) DeleteSidebarChannelsByPreferences(preferences *model.Preferences) error {
   788  
   789  	tries := 0
   790  	for {
   791  		err := s.ChannelStore.DeleteSidebarChannelsByPreferences(preferences)
   792  		if err == nil {
   793  			return nil
   794  		}
   795  		if !isRepeatableError(err) {
   796  			return err
   797  		}
   798  		tries++
   799  		if tries >= 3 {
   800  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
   801  			return err
   802  		}
   803  	}
   804  
   805  }
   806  
   807  func (s *RetryLayerChannelStore) Get(id string, allowFromCache bool) (*model.Channel, error) {
   808  
   809  	tries := 0
   810  	for {
   811  		result, err := s.ChannelStore.Get(id, allowFromCache)
   812  		if err == nil {
   813  			return result, nil
   814  		}
   815  		if !isRepeatableError(err) {
   816  			return result, err
   817  		}
   818  		tries++
   819  		if tries >= 3 {
   820  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
   821  			return result, err
   822  		}
   823  	}
   824  
   825  }
   826  
   827  func (s *RetryLayerChannelStore) GetAll(teamId string) ([]*model.Channel, error) {
   828  
   829  	tries := 0
   830  	for {
   831  		result, err := s.ChannelStore.GetAll(teamId)
   832  		if err == nil {
   833  			return result, nil
   834  		}
   835  		if !isRepeatableError(err) {
   836  			return result, err
   837  		}
   838  		tries++
   839  		if tries >= 3 {
   840  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
   841  			return result, err
   842  		}
   843  	}
   844  
   845  }
   846  
   847  func (s *RetryLayerChannelStore) GetAllChannelMembersForUser(userId string, allowFromCache bool, includeDeleted bool) (map[string]string, error) {
   848  
   849  	tries := 0
   850  	for {
   851  		result, err := s.ChannelStore.GetAllChannelMembersForUser(userId, allowFromCache, includeDeleted)
   852  		if err == nil {
   853  			return result, nil
   854  		}
   855  		if !isRepeatableError(err) {
   856  			return result, err
   857  		}
   858  		tries++
   859  		if tries >= 3 {
   860  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
   861  			return result, err
   862  		}
   863  	}
   864  
   865  }
   866  
   867  func (s *RetryLayerChannelStore) GetAllChannelMembersNotifyPropsForChannel(channelId string, allowFromCache bool) (map[string]model.StringMap, error) {
   868  
   869  	tries := 0
   870  	for {
   871  		result, err := s.ChannelStore.GetAllChannelMembersNotifyPropsForChannel(channelId, allowFromCache)
   872  		if err == nil {
   873  			return result, nil
   874  		}
   875  		if !isRepeatableError(err) {
   876  			return result, err
   877  		}
   878  		tries++
   879  		if tries >= 3 {
   880  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
   881  			return result, err
   882  		}
   883  	}
   884  
   885  }
   886  
   887  func (s *RetryLayerChannelStore) GetAllChannels(page int, perPage int, opts store.ChannelSearchOpts) (*model.ChannelListWithTeamData, error) {
   888  
   889  	tries := 0
   890  	for {
   891  		result, err := s.ChannelStore.GetAllChannels(page, perPage, opts)
   892  		if err == nil {
   893  			return result, nil
   894  		}
   895  		if !isRepeatableError(err) {
   896  			return result, err
   897  		}
   898  		tries++
   899  		if tries >= 3 {
   900  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
   901  			return result, err
   902  		}
   903  	}
   904  
   905  }
   906  
   907  func (s *RetryLayerChannelStore) GetAllChannelsCount(opts store.ChannelSearchOpts) (int64, error) {
   908  
   909  	tries := 0
   910  	for {
   911  		result, err := s.ChannelStore.GetAllChannelsCount(opts)
   912  		if err == nil {
   913  			return result, nil
   914  		}
   915  		if !isRepeatableError(err) {
   916  			return result, err
   917  		}
   918  		tries++
   919  		if tries >= 3 {
   920  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
   921  			return result, err
   922  		}
   923  	}
   924  
   925  }
   926  
   927  func (s *RetryLayerChannelStore) GetAllChannelsForExportAfter(limit int, afterId string) ([]*model.ChannelForExport, error) {
   928  
   929  	tries := 0
   930  	for {
   931  		result, err := s.ChannelStore.GetAllChannelsForExportAfter(limit, afterId)
   932  		if err == nil {
   933  			return result, nil
   934  		}
   935  		if !isRepeatableError(err) {
   936  			return result, err
   937  		}
   938  		tries++
   939  		if tries >= 3 {
   940  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
   941  			return result, err
   942  		}
   943  	}
   944  
   945  }
   946  
   947  func (s *RetryLayerChannelStore) GetAllDirectChannelsForExportAfter(limit int, afterId string) ([]*model.DirectChannelForExport, error) {
   948  
   949  	tries := 0
   950  	for {
   951  		result, err := s.ChannelStore.GetAllDirectChannelsForExportAfter(limit, afterId)
   952  		if err == nil {
   953  			return result, nil
   954  		}
   955  		if !isRepeatableError(err) {
   956  			return result, err
   957  		}
   958  		tries++
   959  		if tries >= 3 {
   960  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
   961  			return result, err
   962  		}
   963  	}
   964  
   965  }
   966  
   967  func (s *RetryLayerChannelStore) GetByName(team_id string, name string, allowFromCache bool) (*model.Channel, error) {
   968  
   969  	tries := 0
   970  	for {
   971  		result, err := s.ChannelStore.GetByName(team_id, name, allowFromCache)
   972  		if err == nil {
   973  			return result, nil
   974  		}
   975  		if !isRepeatableError(err) {
   976  			return result, err
   977  		}
   978  		tries++
   979  		if tries >= 3 {
   980  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
   981  			return result, err
   982  		}
   983  	}
   984  
   985  }
   986  
   987  func (s *RetryLayerChannelStore) GetByNameIncludeDeleted(team_id string, name string, allowFromCache bool) (*model.Channel, error) {
   988  
   989  	tries := 0
   990  	for {
   991  		result, err := s.ChannelStore.GetByNameIncludeDeleted(team_id, name, allowFromCache)
   992  		if err == nil {
   993  			return result, nil
   994  		}
   995  		if !isRepeatableError(err) {
   996  			return result, err
   997  		}
   998  		tries++
   999  		if tries >= 3 {
  1000  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1001  			return result, err
  1002  		}
  1003  	}
  1004  
  1005  }
  1006  
  1007  func (s *RetryLayerChannelStore) GetByNames(team_id string, names []string, allowFromCache bool) ([]*model.Channel, error) {
  1008  
  1009  	tries := 0
  1010  	for {
  1011  		result, err := s.ChannelStore.GetByNames(team_id, names, allowFromCache)
  1012  		if err == nil {
  1013  			return result, nil
  1014  		}
  1015  		if !isRepeatableError(err) {
  1016  			return result, err
  1017  		}
  1018  		tries++
  1019  		if tries >= 3 {
  1020  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1021  			return result, err
  1022  		}
  1023  	}
  1024  
  1025  }
  1026  
  1027  func (s *RetryLayerChannelStore) GetChannelCounts(teamId string, userId string) (*model.ChannelCounts, error) {
  1028  
  1029  	tries := 0
  1030  	for {
  1031  		result, err := s.ChannelStore.GetChannelCounts(teamId, userId)
  1032  		if err == nil {
  1033  			return result, nil
  1034  		}
  1035  		if !isRepeatableError(err) {
  1036  			return result, err
  1037  		}
  1038  		tries++
  1039  		if tries >= 3 {
  1040  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1041  			return result, err
  1042  		}
  1043  	}
  1044  
  1045  }
  1046  
  1047  func (s *RetryLayerChannelStore) GetChannelMembersForExport(userId string, teamId string) ([]*model.ChannelMemberForExport, error) {
  1048  
  1049  	tries := 0
  1050  	for {
  1051  		result, err := s.ChannelStore.GetChannelMembersForExport(userId, teamId)
  1052  		if err == nil {
  1053  			return result, nil
  1054  		}
  1055  		if !isRepeatableError(err) {
  1056  			return result, err
  1057  		}
  1058  		tries++
  1059  		if tries >= 3 {
  1060  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1061  			return result, err
  1062  		}
  1063  	}
  1064  
  1065  }
  1066  
  1067  func (s *RetryLayerChannelStore) GetChannelMembersTimezones(channelId string) ([]model.StringMap, error) {
  1068  
  1069  	tries := 0
  1070  	for {
  1071  		result, err := s.ChannelStore.GetChannelMembersTimezones(channelId)
  1072  		if err == nil {
  1073  			return result, nil
  1074  		}
  1075  		if !isRepeatableError(err) {
  1076  			return result, err
  1077  		}
  1078  		tries++
  1079  		if tries >= 3 {
  1080  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1081  			return result, err
  1082  		}
  1083  	}
  1084  
  1085  }
  1086  
  1087  func (s *RetryLayerChannelStore) GetChannelUnread(channelId string, userId string) (*model.ChannelUnread, error) {
  1088  
  1089  	tries := 0
  1090  	for {
  1091  		result, err := s.ChannelStore.GetChannelUnread(channelId, userId)
  1092  		if err == nil {
  1093  			return result, nil
  1094  		}
  1095  		if !isRepeatableError(err) {
  1096  			return result, err
  1097  		}
  1098  		tries++
  1099  		if tries >= 3 {
  1100  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1101  			return result, err
  1102  		}
  1103  	}
  1104  
  1105  }
  1106  
  1107  func (s *RetryLayerChannelStore) GetChannels(teamId string, userId string, includeDeleted bool, lastDeleteAt int) (*model.ChannelList, error) {
  1108  
  1109  	tries := 0
  1110  	for {
  1111  		result, err := s.ChannelStore.GetChannels(teamId, userId, includeDeleted, lastDeleteAt)
  1112  		if err == nil {
  1113  			return result, nil
  1114  		}
  1115  		if !isRepeatableError(err) {
  1116  			return result, err
  1117  		}
  1118  		tries++
  1119  		if tries >= 3 {
  1120  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1121  			return result, err
  1122  		}
  1123  	}
  1124  
  1125  }
  1126  
  1127  func (s *RetryLayerChannelStore) GetChannelsBatchForIndexing(startTime int64, endTime int64, limit int) ([]*model.Channel, error) {
  1128  
  1129  	tries := 0
  1130  	for {
  1131  		result, err := s.ChannelStore.GetChannelsBatchForIndexing(startTime, endTime, limit)
  1132  		if err == nil {
  1133  			return result, nil
  1134  		}
  1135  		if !isRepeatableError(err) {
  1136  			return result, err
  1137  		}
  1138  		tries++
  1139  		if tries >= 3 {
  1140  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1141  			return result, err
  1142  		}
  1143  	}
  1144  
  1145  }
  1146  
  1147  func (s *RetryLayerChannelStore) GetChannelsByIds(channelIds []string, includeDeleted bool) ([]*model.Channel, error) {
  1148  
  1149  	tries := 0
  1150  	for {
  1151  		result, err := s.ChannelStore.GetChannelsByIds(channelIds, includeDeleted)
  1152  		if err == nil {
  1153  			return result, nil
  1154  		}
  1155  		if !isRepeatableError(err) {
  1156  			return result, err
  1157  		}
  1158  		tries++
  1159  		if tries >= 3 {
  1160  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1161  			return result, err
  1162  		}
  1163  	}
  1164  
  1165  }
  1166  
  1167  func (s *RetryLayerChannelStore) GetChannelsByScheme(schemeId string, offset int, limit int) (model.ChannelList, error) {
  1168  
  1169  	tries := 0
  1170  	for {
  1171  		result, err := s.ChannelStore.GetChannelsByScheme(schemeId, offset, limit)
  1172  		if err == nil {
  1173  			return result, nil
  1174  		}
  1175  		if !isRepeatableError(err) {
  1176  			return result, err
  1177  		}
  1178  		tries++
  1179  		if tries >= 3 {
  1180  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1181  			return result, err
  1182  		}
  1183  	}
  1184  
  1185  }
  1186  
  1187  func (s *RetryLayerChannelStore) GetDeleted(team_id string, offset int, limit int, userId string) (*model.ChannelList, error) {
  1188  
  1189  	tries := 0
  1190  	for {
  1191  		result, err := s.ChannelStore.GetDeleted(team_id, offset, limit, userId)
  1192  		if err == nil {
  1193  			return result, nil
  1194  		}
  1195  		if !isRepeatableError(err) {
  1196  			return result, err
  1197  		}
  1198  		tries++
  1199  		if tries >= 3 {
  1200  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1201  			return result, err
  1202  		}
  1203  	}
  1204  
  1205  }
  1206  
  1207  func (s *RetryLayerChannelStore) GetDeletedByName(team_id string, name string) (*model.Channel, error) {
  1208  
  1209  	tries := 0
  1210  	for {
  1211  		result, err := s.ChannelStore.GetDeletedByName(team_id, name)
  1212  		if err == nil {
  1213  			return result, nil
  1214  		}
  1215  		if !isRepeatableError(err) {
  1216  			return result, err
  1217  		}
  1218  		tries++
  1219  		if tries >= 3 {
  1220  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1221  			return result, err
  1222  		}
  1223  	}
  1224  
  1225  }
  1226  
  1227  func (s *RetryLayerChannelStore) GetForPost(postId string) (*model.Channel, error) {
  1228  
  1229  	tries := 0
  1230  	for {
  1231  		result, err := s.ChannelStore.GetForPost(postId)
  1232  		if err == nil {
  1233  			return result, nil
  1234  		}
  1235  		if !isRepeatableError(err) {
  1236  			return result, err
  1237  		}
  1238  		tries++
  1239  		if tries >= 3 {
  1240  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1241  			return result, err
  1242  		}
  1243  	}
  1244  
  1245  }
  1246  
  1247  func (s *RetryLayerChannelStore) GetFromMaster(id string) (*model.Channel, error) {
  1248  
  1249  	tries := 0
  1250  	for {
  1251  		result, err := s.ChannelStore.GetFromMaster(id)
  1252  		if err == nil {
  1253  			return result, nil
  1254  		}
  1255  		if !isRepeatableError(err) {
  1256  			return result, err
  1257  		}
  1258  		tries++
  1259  		if tries >= 3 {
  1260  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1261  			return result, err
  1262  		}
  1263  	}
  1264  
  1265  }
  1266  
  1267  func (s *RetryLayerChannelStore) GetGuestCount(channelId string, allowFromCache bool) (int64, error) {
  1268  
  1269  	tries := 0
  1270  	for {
  1271  		result, err := s.ChannelStore.GetGuestCount(channelId, allowFromCache)
  1272  		if err == nil {
  1273  			return result, nil
  1274  		}
  1275  		if !isRepeatableError(err) {
  1276  			return result, err
  1277  		}
  1278  		tries++
  1279  		if tries >= 3 {
  1280  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1281  			return result, err
  1282  		}
  1283  	}
  1284  
  1285  }
  1286  
  1287  func (s *RetryLayerChannelStore) GetMember(channelId string, userId string) (*model.ChannelMember, error) {
  1288  
  1289  	tries := 0
  1290  	for {
  1291  		result, err := s.ChannelStore.GetMember(channelId, userId)
  1292  		if err == nil {
  1293  			return result, nil
  1294  		}
  1295  		if !isRepeatableError(err) {
  1296  			return result, err
  1297  		}
  1298  		tries++
  1299  		if tries >= 3 {
  1300  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1301  			return result, err
  1302  		}
  1303  	}
  1304  
  1305  }
  1306  
  1307  func (s *RetryLayerChannelStore) GetMemberCount(channelId string, allowFromCache bool) (int64, error) {
  1308  
  1309  	tries := 0
  1310  	for {
  1311  		result, err := s.ChannelStore.GetMemberCount(channelId, allowFromCache)
  1312  		if err == nil {
  1313  			return result, nil
  1314  		}
  1315  		if !isRepeatableError(err) {
  1316  			return result, err
  1317  		}
  1318  		tries++
  1319  		if tries >= 3 {
  1320  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1321  			return result, err
  1322  		}
  1323  	}
  1324  
  1325  }
  1326  
  1327  func (s *RetryLayerChannelStore) GetMemberCountFromCache(channelId string) int64 {
  1328  
  1329  	return s.ChannelStore.GetMemberCountFromCache(channelId)
  1330  
  1331  }
  1332  
  1333  func (s *RetryLayerChannelStore) GetMemberCountsByGroup(channelID string, includeTimezones bool) ([]*model.ChannelMemberCountByGroup, error) {
  1334  
  1335  	tries := 0
  1336  	for {
  1337  		result, err := s.ChannelStore.GetMemberCountsByGroup(channelID, includeTimezones)
  1338  		if err == nil {
  1339  			return result, nil
  1340  		}
  1341  		if !isRepeatableError(err) {
  1342  			return result, err
  1343  		}
  1344  		tries++
  1345  		if tries >= 3 {
  1346  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1347  			return result, err
  1348  		}
  1349  	}
  1350  
  1351  }
  1352  
  1353  func (s *RetryLayerChannelStore) GetMemberForPost(postId string, userId string) (*model.ChannelMember, error) {
  1354  
  1355  	tries := 0
  1356  	for {
  1357  		result, err := s.ChannelStore.GetMemberForPost(postId, userId)
  1358  		if err == nil {
  1359  			return result, nil
  1360  		}
  1361  		if !isRepeatableError(err) {
  1362  			return result, err
  1363  		}
  1364  		tries++
  1365  		if tries >= 3 {
  1366  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1367  			return result, err
  1368  		}
  1369  	}
  1370  
  1371  }
  1372  
  1373  func (s *RetryLayerChannelStore) GetMembers(channelId string, offset int, limit int) (*model.ChannelMembers, error) {
  1374  
  1375  	tries := 0
  1376  	for {
  1377  		result, err := s.ChannelStore.GetMembers(channelId, offset, limit)
  1378  		if err == nil {
  1379  			return result, nil
  1380  		}
  1381  		if !isRepeatableError(err) {
  1382  			return result, err
  1383  		}
  1384  		tries++
  1385  		if tries >= 3 {
  1386  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1387  			return result, err
  1388  		}
  1389  	}
  1390  
  1391  }
  1392  
  1393  func (s *RetryLayerChannelStore) GetMembersByChannelIds(channelIds []string, userId string) (*model.ChannelMembers, error) {
  1394  
  1395  	tries := 0
  1396  	for {
  1397  		result, err := s.ChannelStore.GetMembersByChannelIds(channelIds, userId)
  1398  		if err == nil {
  1399  			return result, nil
  1400  		}
  1401  		if !isRepeatableError(err) {
  1402  			return result, err
  1403  		}
  1404  		tries++
  1405  		if tries >= 3 {
  1406  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1407  			return result, err
  1408  		}
  1409  	}
  1410  
  1411  }
  1412  
  1413  func (s *RetryLayerChannelStore) GetMembersByIds(channelId string, userIds []string) (*model.ChannelMembers, error) {
  1414  
  1415  	tries := 0
  1416  	for {
  1417  		result, err := s.ChannelStore.GetMembersByIds(channelId, userIds)
  1418  		if err == nil {
  1419  			return result, nil
  1420  		}
  1421  		if !isRepeatableError(err) {
  1422  			return result, err
  1423  		}
  1424  		tries++
  1425  		if tries >= 3 {
  1426  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1427  			return result, err
  1428  		}
  1429  	}
  1430  
  1431  }
  1432  
  1433  func (s *RetryLayerChannelStore) GetMembersForUser(teamId string, userId string) (*model.ChannelMembers, error) {
  1434  
  1435  	tries := 0
  1436  	for {
  1437  		result, err := s.ChannelStore.GetMembersForUser(teamId, userId)
  1438  		if err == nil {
  1439  			return result, nil
  1440  		}
  1441  		if !isRepeatableError(err) {
  1442  			return result, err
  1443  		}
  1444  		tries++
  1445  		if tries >= 3 {
  1446  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1447  			return result, err
  1448  		}
  1449  	}
  1450  
  1451  }
  1452  
  1453  func (s *RetryLayerChannelStore) GetMembersForUserWithPagination(teamId string, userId string, page int, perPage int) (*model.ChannelMembers, error) {
  1454  
  1455  	tries := 0
  1456  	for {
  1457  		result, err := s.ChannelStore.GetMembersForUserWithPagination(teamId, userId, page, perPage)
  1458  		if err == nil {
  1459  			return result, nil
  1460  		}
  1461  		if !isRepeatableError(err) {
  1462  			return result, err
  1463  		}
  1464  		tries++
  1465  		if tries >= 3 {
  1466  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1467  			return result, err
  1468  		}
  1469  	}
  1470  
  1471  }
  1472  
  1473  func (s *RetryLayerChannelStore) GetMoreChannels(teamId string, userId string, offset int, limit int) (*model.ChannelList, error) {
  1474  
  1475  	tries := 0
  1476  	for {
  1477  		result, err := s.ChannelStore.GetMoreChannels(teamId, userId, offset, limit)
  1478  		if err == nil {
  1479  			return result, nil
  1480  		}
  1481  		if !isRepeatableError(err) {
  1482  			return result, err
  1483  		}
  1484  		tries++
  1485  		if tries >= 3 {
  1486  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1487  			return result, err
  1488  		}
  1489  	}
  1490  
  1491  }
  1492  
  1493  func (s *RetryLayerChannelStore) GetPinnedPostCount(channelId string, allowFromCache bool) (int64, error) {
  1494  
  1495  	tries := 0
  1496  	for {
  1497  		result, err := s.ChannelStore.GetPinnedPostCount(channelId, allowFromCache)
  1498  		if err == nil {
  1499  			return result, nil
  1500  		}
  1501  		if !isRepeatableError(err) {
  1502  			return result, err
  1503  		}
  1504  		tries++
  1505  		if tries >= 3 {
  1506  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1507  			return result, err
  1508  		}
  1509  	}
  1510  
  1511  }
  1512  
  1513  func (s *RetryLayerChannelStore) GetPinnedPosts(channelId string) (*model.PostList, error) {
  1514  
  1515  	tries := 0
  1516  	for {
  1517  		result, err := s.ChannelStore.GetPinnedPosts(channelId)
  1518  		if err == nil {
  1519  			return result, nil
  1520  		}
  1521  		if !isRepeatableError(err) {
  1522  			return result, err
  1523  		}
  1524  		tries++
  1525  		if tries >= 3 {
  1526  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1527  			return result, err
  1528  		}
  1529  	}
  1530  
  1531  }
  1532  
  1533  func (s *RetryLayerChannelStore) GetPrivateChannelsForTeam(teamId string, offset int, limit int) (*model.ChannelList, error) {
  1534  
  1535  	tries := 0
  1536  	for {
  1537  		result, err := s.ChannelStore.GetPrivateChannelsForTeam(teamId, offset, limit)
  1538  		if err == nil {
  1539  			return result, nil
  1540  		}
  1541  		if !isRepeatableError(err) {
  1542  			return result, err
  1543  		}
  1544  		tries++
  1545  		if tries >= 3 {
  1546  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1547  			return result, err
  1548  		}
  1549  	}
  1550  
  1551  }
  1552  
  1553  func (s *RetryLayerChannelStore) GetPublicChannelsByIdsForTeam(teamId string, channelIds []string) (*model.ChannelList, error) {
  1554  
  1555  	tries := 0
  1556  	for {
  1557  		result, err := s.ChannelStore.GetPublicChannelsByIdsForTeam(teamId, channelIds)
  1558  		if err == nil {
  1559  			return result, nil
  1560  		}
  1561  		if !isRepeatableError(err) {
  1562  			return result, err
  1563  		}
  1564  		tries++
  1565  		if tries >= 3 {
  1566  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1567  			return result, err
  1568  		}
  1569  	}
  1570  
  1571  }
  1572  
  1573  func (s *RetryLayerChannelStore) GetPublicChannelsForTeam(teamId string, offset int, limit int) (*model.ChannelList, error) {
  1574  
  1575  	tries := 0
  1576  	for {
  1577  		result, err := s.ChannelStore.GetPublicChannelsForTeam(teamId, offset, limit)
  1578  		if err == nil {
  1579  			return result, nil
  1580  		}
  1581  		if !isRepeatableError(err) {
  1582  			return result, err
  1583  		}
  1584  		tries++
  1585  		if tries >= 3 {
  1586  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1587  			return result, err
  1588  		}
  1589  	}
  1590  
  1591  }
  1592  
  1593  func (s *RetryLayerChannelStore) GetSidebarCategories(userId string, teamId string) (*model.OrderedSidebarCategories, error) {
  1594  
  1595  	tries := 0
  1596  	for {
  1597  		result, err := s.ChannelStore.GetSidebarCategories(userId, teamId)
  1598  		if err == nil {
  1599  			return result, nil
  1600  		}
  1601  		if !isRepeatableError(err) {
  1602  			return result, err
  1603  		}
  1604  		tries++
  1605  		if tries >= 3 {
  1606  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1607  			return result, err
  1608  		}
  1609  	}
  1610  
  1611  }
  1612  
  1613  func (s *RetryLayerChannelStore) GetSidebarCategory(categoryId string) (*model.SidebarCategoryWithChannels, error) {
  1614  
  1615  	tries := 0
  1616  	for {
  1617  		result, err := s.ChannelStore.GetSidebarCategory(categoryId)
  1618  		if err == nil {
  1619  			return result, nil
  1620  		}
  1621  		if !isRepeatableError(err) {
  1622  			return result, err
  1623  		}
  1624  		tries++
  1625  		if tries >= 3 {
  1626  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1627  			return result, err
  1628  		}
  1629  	}
  1630  
  1631  }
  1632  
  1633  func (s *RetryLayerChannelStore) GetSidebarCategoryOrder(userId string, teamId string) ([]string, error) {
  1634  
  1635  	tries := 0
  1636  	for {
  1637  		result, err := s.ChannelStore.GetSidebarCategoryOrder(userId, teamId)
  1638  		if err == nil {
  1639  			return result, nil
  1640  		}
  1641  		if !isRepeatableError(err) {
  1642  			return result, err
  1643  		}
  1644  		tries++
  1645  		if tries >= 3 {
  1646  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1647  			return result, err
  1648  		}
  1649  	}
  1650  
  1651  }
  1652  
  1653  func (s *RetryLayerChannelStore) GetTeamChannels(teamId string) (*model.ChannelList, error) {
  1654  
  1655  	tries := 0
  1656  	for {
  1657  		result, err := s.ChannelStore.GetTeamChannels(teamId)
  1658  		if err == nil {
  1659  			return result, nil
  1660  		}
  1661  		if !isRepeatableError(err) {
  1662  			return result, err
  1663  		}
  1664  		tries++
  1665  		if tries >= 3 {
  1666  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1667  			return result, err
  1668  		}
  1669  	}
  1670  
  1671  }
  1672  
  1673  func (s *RetryLayerChannelStore) GroupSyncedChannelCount() (int64, error) {
  1674  
  1675  	tries := 0
  1676  	for {
  1677  		result, err := s.ChannelStore.GroupSyncedChannelCount()
  1678  		if err == nil {
  1679  			return result, nil
  1680  		}
  1681  		if !isRepeatableError(err) {
  1682  			return result, err
  1683  		}
  1684  		tries++
  1685  		if tries >= 3 {
  1686  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1687  			return result, err
  1688  		}
  1689  	}
  1690  
  1691  }
  1692  
  1693  func (s *RetryLayerChannelStore) IncrementMentionCount(channelId string, userId string, updateThreads bool) error {
  1694  
  1695  	tries := 0
  1696  	for {
  1697  		err := s.ChannelStore.IncrementMentionCount(channelId, userId, updateThreads)
  1698  		if err == nil {
  1699  			return nil
  1700  		}
  1701  		if !isRepeatableError(err) {
  1702  			return err
  1703  		}
  1704  		tries++
  1705  		if tries >= 3 {
  1706  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1707  			return err
  1708  		}
  1709  	}
  1710  
  1711  }
  1712  
  1713  func (s *RetryLayerChannelStore) InvalidateAllChannelMembersForUser(userId string) {
  1714  
  1715  	s.ChannelStore.InvalidateAllChannelMembersForUser(userId)
  1716  
  1717  }
  1718  
  1719  func (s *RetryLayerChannelStore) InvalidateCacheForChannelMembersNotifyProps(channelId string) {
  1720  
  1721  	s.ChannelStore.InvalidateCacheForChannelMembersNotifyProps(channelId)
  1722  
  1723  }
  1724  
  1725  func (s *RetryLayerChannelStore) InvalidateChannel(id string) {
  1726  
  1727  	s.ChannelStore.InvalidateChannel(id)
  1728  
  1729  }
  1730  
  1731  func (s *RetryLayerChannelStore) InvalidateChannelByName(teamId string, name string) {
  1732  
  1733  	s.ChannelStore.InvalidateChannelByName(teamId, name)
  1734  
  1735  }
  1736  
  1737  func (s *RetryLayerChannelStore) InvalidateGuestCount(channelId string) {
  1738  
  1739  	s.ChannelStore.InvalidateGuestCount(channelId)
  1740  
  1741  }
  1742  
  1743  func (s *RetryLayerChannelStore) InvalidateMemberCount(channelId string) {
  1744  
  1745  	s.ChannelStore.InvalidateMemberCount(channelId)
  1746  
  1747  }
  1748  
  1749  func (s *RetryLayerChannelStore) InvalidatePinnedPostCount(channelId string) {
  1750  
  1751  	s.ChannelStore.InvalidatePinnedPostCount(channelId)
  1752  
  1753  }
  1754  
  1755  func (s *RetryLayerChannelStore) IsUserInChannelUseCache(userId string, channelId string) bool {
  1756  
  1757  	return s.ChannelStore.IsUserInChannelUseCache(userId, channelId)
  1758  
  1759  }
  1760  
  1761  func (s *RetryLayerChannelStore) MigrateChannelMembers(fromChannelId string, fromUserId string) (map[string]string, error) {
  1762  
  1763  	tries := 0
  1764  	for {
  1765  		result, err := s.ChannelStore.MigrateChannelMembers(fromChannelId, fromUserId)
  1766  		if err == nil {
  1767  			return result, nil
  1768  		}
  1769  		if !isRepeatableError(err) {
  1770  			return result, err
  1771  		}
  1772  		tries++
  1773  		if tries >= 3 {
  1774  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1775  			return result, err
  1776  		}
  1777  	}
  1778  
  1779  }
  1780  
  1781  func (s *RetryLayerChannelStore) MigratePublicChannels() error {
  1782  
  1783  	tries := 0
  1784  	for {
  1785  		err := s.ChannelStore.MigratePublicChannels()
  1786  		if err == nil {
  1787  			return nil
  1788  		}
  1789  		if !isRepeatableError(err) {
  1790  			return err
  1791  		}
  1792  		tries++
  1793  		if tries >= 3 {
  1794  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1795  			return err
  1796  		}
  1797  	}
  1798  
  1799  }
  1800  
  1801  func (s *RetryLayerChannelStore) PermanentDelete(channelId string) error {
  1802  
  1803  	tries := 0
  1804  	for {
  1805  		err := s.ChannelStore.PermanentDelete(channelId)
  1806  		if err == nil {
  1807  			return nil
  1808  		}
  1809  		if !isRepeatableError(err) {
  1810  			return err
  1811  		}
  1812  		tries++
  1813  		if tries >= 3 {
  1814  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1815  			return err
  1816  		}
  1817  	}
  1818  
  1819  }
  1820  
  1821  func (s *RetryLayerChannelStore) PermanentDeleteByTeam(teamId string) error {
  1822  
  1823  	tries := 0
  1824  	for {
  1825  		err := s.ChannelStore.PermanentDeleteByTeam(teamId)
  1826  		if err == nil {
  1827  			return nil
  1828  		}
  1829  		if !isRepeatableError(err) {
  1830  			return err
  1831  		}
  1832  		tries++
  1833  		if tries >= 3 {
  1834  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1835  			return err
  1836  		}
  1837  	}
  1838  
  1839  }
  1840  
  1841  func (s *RetryLayerChannelStore) PermanentDeleteMembersByChannel(channelId string) error {
  1842  
  1843  	tries := 0
  1844  	for {
  1845  		err := s.ChannelStore.PermanentDeleteMembersByChannel(channelId)
  1846  		if err == nil {
  1847  			return nil
  1848  		}
  1849  		if !isRepeatableError(err) {
  1850  			return err
  1851  		}
  1852  		tries++
  1853  		if tries >= 3 {
  1854  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1855  			return err
  1856  		}
  1857  	}
  1858  
  1859  }
  1860  
  1861  func (s *RetryLayerChannelStore) PermanentDeleteMembersByUser(userId string) error {
  1862  
  1863  	tries := 0
  1864  	for {
  1865  		err := s.ChannelStore.PermanentDeleteMembersByUser(userId)
  1866  		if err == nil {
  1867  			return nil
  1868  		}
  1869  		if !isRepeatableError(err) {
  1870  			return err
  1871  		}
  1872  		tries++
  1873  		if tries >= 3 {
  1874  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1875  			return err
  1876  		}
  1877  	}
  1878  
  1879  }
  1880  
  1881  func (s *RetryLayerChannelStore) RemoveAllDeactivatedMembers(channelId string) error {
  1882  
  1883  	tries := 0
  1884  	for {
  1885  		err := s.ChannelStore.RemoveAllDeactivatedMembers(channelId)
  1886  		if err == nil {
  1887  			return nil
  1888  		}
  1889  		if !isRepeatableError(err) {
  1890  			return err
  1891  		}
  1892  		tries++
  1893  		if tries >= 3 {
  1894  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1895  			return err
  1896  		}
  1897  	}
  1898  
  1899  }
  1900  
  1901  func (s *RetryLayerChannelStore) RemoveMember(channelId string, userId string) error {
  1902  
  1903  	tries := 0
  1904  	for {
  1905  		err := s.ChannelStore.RemoveMember(channelId, userId)
  1906  		if err == nil {
  1907  			return nil
  1908  		}
  1909  		if !isRepeatableError(err) {
  1910  			return err
  1911  		}
  1912  		tries++
  1913  		if tries >= 3 {
  1914  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1915  			return err
  1916  		}
  1917  	}
  1918  
  1919  }
  1920  
  1921  func (s *RetryLayerChannelStore) RemoveMembers(channelId string, userIds []string) error {
  1922  
  1923  	tries := 0
  1924  	for {
  1925  		err := s.ChannelStore.RemoveMembers(channelId, userIds)
  1926  		if err == nil {
  1927  			return nil
  1928  		}
  1929  		if !isRepeatableError(err) {
  1930  			return err
  1931  		}
  1932  		tries++
  1933  		if tries >= 3 {
  1934  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1935  			return err
  1936  		}
  1937  	}
  1938  
  1939  }
  1940  
  1941  func (s *RetryLayerChannelStore) ResetAllChannelSchemes() error {
  1942  
  1943  	tries := 0
  1944  	for {
  1945  		err := s.ChannelStore.ResetAllChannelSchemes()
  1946  		if err == nil {
  1947  			return nil
  1948  		}
  1949  		if !isRepeatableError(err) {
  1950  			return err
  1951  		}
  1952  		tries++
  1953  		if tries >= 3 {
  1954  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1955  			return err
  1956  		}
  1957  	}
  1958  
  1959  }
  1960  
  1961  func (s *RetryLayerChannelStore) Restore(channelId string, time int64) error {
  1962  
  1963  	tries := 0
  1964  	for {
  1965  		err := s.ChannelStore.Restore(channelId, time)
  1966  		if err == nil {
  1967  			return nil
  1968  		}
  1969  		if !isRepeatableError(err) {
  1970  			return err
  1971  		}
  1972  		tries++
  1973  		if tries >= 3 {
  1974  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1975  			return err
  1976  		}
  1977  	}
  1978  
  1979  }
  1980  
  1981  func (s *RetryLayerChannelStore) Save(channel *model.Channel, maxChannelsPerTeam int64) (*model.Channel, error) {
  1982  
  1983  	tries := 0
  1984  	for {
  1985  		result, err := s.ChannelStore.Save(channel, maxChannelsPerTeam)
  1986  		if err == nil {
  1987  			return result, nil
  1988  		}
  1989  		if !isRepeatableError(err) {
  1990  			return result, err
  1991  		}
  1992  		tries++
  1993  		if tries >= 3 {
  1994  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  1995  			return result, err
  1996  		}
  1997  	}
  1998  
  1999  }
  2000  
  2001  func (s *RetryLayerChannelStore) SaveDirectChannel(channel *model.Channel, member1 *model.ChannelMember, member2 *model.ChannelMember) (*model.Channel, error) {
  2002  
  2003  	tries := 0
  2004  	for {
  2005  		result, err := s.ChannelStore.SaveDirectChannel(channel, member1, member2)
  2006  		if err == nil {
  2007  			return result, nil
  2008  		}
  2009  		if !isRepeatableError(err) {
  2010  			return result, err
  2011  		}
  2012  		tries++
  2013  		if tries >= 3 {
  2014  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2015  			return result, err
  2016  		}
  2017  	}
  2018  
  2019  }
  2020  
  2021  func (s *RetryLayerChannelStore) SaveMember(member *model.ChannelMember) (*model.ChannelMember, error) {
  2022  
  2023  	tries := 0
  2024  	for {
  2025  		result, err := s.ChannelStore.SaveMember(member)
  2026  		if err == nil {
  2027  			return result, nil
  2028  		}
  2029  		if !isRepeatableError(err) {
  2030  			return result, err
  2031  		}
  2032  		tries++
  2033  		if tries >= 3 {
  2034  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2035  			return result, err
  2036  		}
  2037  	}
  2038  
  2039  }
  2040  
  2041  func (s *RetryLayerChannelStore) SaveMultipleMembers(members []*model.ChannelMember) ([]*model.ChannelMember, error) {
  2042  
  2043  	tries := 0
  2044  	for {
  2045  		result, err := s.ChannelStore.SaveMultipleMembers(members)
  2046  		if err == nil {
  2047  			return result, nil
  2048  		}
  2049  		if !isRepeatableError(err) {
  2050  			return result, err
  2051  		}
  2052  		tries++
  2053  		if tries >= 3 {
  2054  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2055  			return result, err
  2056  		}
  2057  	}
  2058  
  2059  }
  2060  
  2061  func (s *RetryLayerChannelStore) SearchAllChannels(term string, opts store.ChannelSearchOpts) (*model.ChannelListWithTeamData, int64, error) {
  2062  
  2063  	tries := 0
  2064  	for {
  2065  		result, resultVar1, err := s.ChannelStore.SearchAllChannels(term, opts)
  2066  		if err == nil {
  2067  			return result, resultVar1, nil
  2068  		}
  2069  		if !isRepeatableError(err) {
  2070  			return result, resultVar1, err
  2071  		}
  2072  		tries++
  2073  		if tries >= 3 {
  2074  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2075  			return result, resultVar1, err
  2076  		}
  2077  	}
  2078  
  2079  }
  2080  
  2081  func (s *RetryLayerChannelStore) SearchArchivedInTeam(teamId string, term string, userId string) (*model.ChannelList, error) {
  2082  
  2083  	tries := 0
  2084  	for {
  2085  		result, err := s.ChannelStore.SearchArchivedInTeam(teamId, term, userId)
  2086  		if err == nil {
  2087  			return result, nil
  2088  		}
  2089  		if !isRepeatableError(err) {
  2090  			return result, err
  2091  		}
  2092  		tries++
  2093  		if tries >= 3 {
  2094  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2095  			return result, err
  2096  		}
  2097  	}
  2098  
  2099  }
  2100  
  2101  func (s *RetryLayerChannelStore) SearchForUserInTeam(userId string, teamId string, term string, includeDeleted bool) (*model.ChannelList, error) {
  2102  
  2103  	tries := 0
  2104  	for {
  2105  		result, err := s.ChannelStore.SearchForUserInTeam(userId, teamId, term, includeDeleted)
  2106  		if err == nil {
  2107  			return result, nil
  2108  		}
  2109  		if !isRepeatableError(err) {
  2110  			return result, err
  2111  		}
  2112  		tries++
  2113  		if tries >= 3 {
  2114  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2115  			return result, err
  2116  		}
  2117  	}
  2118  
  2119  }
  2120  
  2121  func (s *RetryLayerChannelStore) SearchGroupChannels(userId string, term string) (*model.ChannelList, error) {
  2122  
  2123  	tries := 0
  2124  	for {
  2125  		result, err := s.ChannelStore.SearchGroupChannels(userId, term)
  2126  		if err == nil {
  2127  			return result, nil
  2128  		}
  2129  		if !isRepeatableError(err) {
  2130  			return result, err
  2131  		}
  2132  		tries++
  2133  		if tries >= 3 {
  2134  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2135  			return result, err
  2136  		}
  2137  	}
  2138  
  2139  }
  2140  
  2141  func (s *RetryLayerChannelStore) SearchInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, error) {
  2142  
  2143  	tries := 0
  2144  	for {
  2145  		result, err := s.ChannelStore.SearchInTeam(teamId, term, includeDeleted)
  2146  		if err == nil {
  2147  			return result, nil
  2148  		}
  2149  		if !isRepeatableError(err) {
  2150  			return result, err
  2151  		}
  2152  		tries++
  2153  		if tries >= 3 {
  2154  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2155  			return result, err
  2156  		}
  2157  	}
  2158  
  2159  }
  2160  
  2161  func (s *RetryLayerChannelStore) SearchMore(userId string, teamId string, term string) (*model.ChannelList, error) {
  2162  
  2163  	tries := 0
  2164  	for {
  2165  		result, err := s.ChannelStore.SearchMore(userId, teamId, term)
  2166  		if err == nil {
  2167  			return result, nil
  2168  		}
  2169  		if !isRepeatableError(err) {
  2170  			return result, err
  2171  		}
  2172  		tries++
  2173  		if tries >= 3 {
  2174  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2175  			return result, err
  2176  		}
  2177  	}
  2178  
  2179  }
  2180  
  2181  func (s *RetryLayerChannelStore) SetDeleteAt(channelId string, deleteAt int64, updateAt int64) error {
  2182  
  2183  	tries := 0
  2184  	for {
  2185  		err := s.ChannelStore.SetDeleteAt(channelId, deleteAt, updateAt)
  2186  		if err == nil {
  2187  			return nil
  2188  		}
  2189  		if !isRepeatableError(err) {
  2190  			return err
  2191  		}
  2192  		tries++
  2193  		if tries >= 3 {
  2194  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2195  			return err
  2196  		}
  2197  	}
  2198  
  2199  }
  2200  
  2201  func (s *RetryLayerChannelStore) Update(channel *model.Channel) (*model.Channel, error) {
  2202  
  2203  	tries := 0
  2204  	for {
  2205  		result, err := s.ChannelStore.Update(channel)
  2206  		if err == nil {
  2207  			return result, nil
  2208  		}
  2209  		if !isRepeatableError(err) {
  2210  			return result, err
  2211  		}
  2212  		tries++
  2213  		if tries >= 3 {
  2214  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2215  			return result, err
  2216  		}
  2217  	}
  2218  
  2219  }
  2220  
  2221  func (s *RetryLayerChannelStore) UpdateLastViewedAt(channelIds []string, userId string, updateThreads bool) (map[string]int64, error) {
  2222  
  2223  	tries := 0
  2224  	for {
  2225  		result, err := s.ChannelStore.UpdateLastViewedAt(channelIds, userId, updateThreads)
  2226  		if err == nil {
  2227  			return result, nil
  2228  		}
  2229  		if !isRepeatableError(err) {
  2230  			return result, err
  2231  		}
  2232  		tries++
  2233  		if tries >= 3 {
  2234  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2235  			return result, err
  2236  		}
  2237  	}
  2238  
  2239  }
  2240  
  2241  func (s *RetryLayerChannelStore) UpdateLastViewedAtPost(unreadPost *model.Post, userID string, mentionCount int, updateThreads bool) (*model.ChannelUnreadAt, error) {
  2242  
  2243  	tries := 0
  2244  	for {
  2245  		result, err := s.ChannelStore.UpdateLastViewedAtPost(unreadPost, userID, mentionCount, updateThreads)
  2246  		if err == nil {
  2247  			return result, nil
  2248  		}
  2249  		if !isRepeatableError(err) {
  2250  			return result, err
  2251  		}
  2252  		tries++
  2253  		if tries >= 3 {
  2254  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2255  			return result, err
  2256  		}
  2257  	}
  2258  
  2259  }
  2260  
  2261  func (s *RetryLayerChannelStore) UpdateMember(member *model.ChannelMember) (*model.ChannelMember, error) {
  2262  
  2263  	tries := 0
  2264  	for {
  2265  		result, err := s.ChannelStore.UpdateMember(member)
  2266  		if err == nil {
  2267  			return result, nil
  2268  		}
  2269  		if !isRepeatableError(err) {
  2270  			return result, err
  2271  		}
  2272  		tries++
  2273  		if tries >= 3 {
  2274  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2275  			return result, err
  2276  		}
  2277  	}
  2278  
  2279  }
  2280  
  2281  func (s *RetryLayerChannelStore) UpdateMembersRole(channelID string, userIDs []string) error {
  2282  
  2283  	tries := 0
  2284  	for {
  2285  		err := s.ChannelStore.UpdateMembersRole(channelID, userIDs)
  2286  		if err == nil {
  2287  			return nil
  2288  		}
  2289  		if !isRepeatableError(err) {
  2290  			return err
  2291  		}
  2292  		tries++
  2293  		if tries >= 3 {
  2294  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2295  			return err
  2296  		}
  2297  	}
  2298  
  2299  }
  2300  
  2301  func (s *RetryLayerChannelStore) UpdateMultipleMembers(members []*model.ChannelMember) ([]*model.ChannelMember, error) {
  2302  
  2303  	tries := 0
  2304  	for {
  2305  		result, err := s.ChannelStore.UpdateMultipleMembers(members)
  2306  		if err == nil {
  2307  			return result, nil
  2308  		}
  2309  		if !isRepeatableError(err) {
  2310  			return result, err
  2311  		}
  2312  		tries++
  2313  		if tries >= 3 {
  2314  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2315  			return result, err
  2316  		}
  2317  	}
  2318  
  2319  }
  2320  
  2321  func (s *RetryLayerChannelStore) UpdateSidebarCategories(userId string, teamId string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, []*model.SidebarCategoryWithChannels, error) {
  2322  
  2323  	tries := 0
  2324  	for {
  2325  		result, resultVar1, err := s.ChannelStore.UpdateSidebarCategories(userId, teamId, categories)
  2326  		if err == nil {
  2327  			return result, resultVar1, nil
  2328  		}
  2329  		if !isRepeatableError(err) {
  2330  			return result, resultVar1, err
  2331  		}
  2332  		tries++
  2333  		if tries >= 3 {
  2334  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2335  			return result, resultVar1, err
  2336  		}
  2337  	}
  2338  
  2339  }
  2340  
  2341  func (s *RetryLayerChannelStore) UpdateSidebarCategoryOrder(userId string, teamId string, categoryOrder []string) error {
  2342  
  2343  	tries := 0
  2344  	for {
  2345  		err := s.ChannelStore.UpdateSidebarCategoryOrder(userId, teamId, categoryOrder)
  2346  		if err == nil {
  2347  			return nil
  2348  		}
  2349  		if !isRepeatableError(err) {
  2350  			return err
  2351  		}
  2352  		tries++
  2353  		if tries >= 3 {
  2354  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2355  			return err
  2356  		}
  2357  	}
  2358  
  2359  }
  2360  
  2361  func (s *RetryLayerChannelStore) UpdateSidebarChannelCategoryOnMove(channel *model.Channel, newTeamId string) error {
  2362  
  2363  	tries := 0
  2364  	for {
  2365  		err := s.ChannelStore.UpdateSidebarChannelCategoryOnMove(channel, newTeamId)
  2366  		if err == nil {
  2367  			return nil
  2368  		}
  2369  		if !isRepeatableError(err) {
  2370  			return err
  2371  		}
  2372  		tries++
  2373  		if tries >= 3 {
  2374  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2375  			return err
  2376  		}
  2377  	}
  2378  
  2379  }
  2380  
  2381  func (s *RetryLayerChannelStore) UpdateSidebarChannelsByPreferences(preferences *model.Preferences) error {
  2382  
  2383  	tries := 0
  2384  	for {
  2385  		err := s.ChannelStore.UpdateSidebarChannelsByPreferences(preferences)
  2386  		if err == nil {
  2387  			return nil
  2388  		}
  2389  		if !isRepeatableError(err) {
  2390  			return err
  2391  		}
  2392  		tries++
  2393  		if tries >= 3 {
  2394  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2395  			return err
  2396  		}
  2397  	}
  2398  
  2399  }
  2400  
  2401  func (s *RetryLayerChannelStore) UserBelongsToChannels(userId string, channelIds []string) (bool, error) {
  2402  
  2403  	tries := 0
  2404  	for {
  2405  		result, err := s.ChannelStore.UserBelongsToChannels(userId, channelIds)
  2406  		if err == nil {
  2407  			return result, nil
  2408  		}
  2409  		if !isRepeatableError(err) {
  2410  			return result, err
  2411  		}
  2412  		tries++
  2413  		if tries >= 3 {
  2414  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2415  			return result, err
  2416  		}
  2417  	}
  2418  
  2419  }
  2420  
  2421  func (s *RetryLayerChannelMemberHistoryStore) GetUsersInChannelDuring(startTime int64, endTime int64, channelId string) ([]*model.ChannelMemberHistoryResult, error) {
  2422  
  2423  	tries := 0
  2424  	for {
  2425  		result, err := s.ChannelMemberHistoryStore.GetUsersInChannelDuring(startTime, endTime, channelId)
  2426  		if err == nil {
  2427  			return result, nil
  2428  		}
  2429  		if !isRepeatableError(err) {
  2430  			return result, err
  2431  		}
  2432  		tries++
  2433  		if tries >= 3 {
  2434  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2435  			return result, err
  2436  		}
  2437  	}
  2438  
  2439  }
  2440  
  2441  func (s *RetryLayerChannelMemberHistoryStore) LogJoinEvent(userId string, channelId string, joinTime int64) error {
  2442  
  2443  	tries := 0
  2444  	for {
  2445  		err := s.ChannelMemberHistoryStore.LogJoinEvent(userId, channelId, joinTime)
  2446  		if err == nil {
  2447  			return nil
  2448  		}
  2449  		if !isRepeatableError(err) {
  2450  			return err
  2451  		}
  2452  		tries++
  2453  		if tries >= 3 {
  2454  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2455  			return err
  2456  		}
  2457  	}
  2458  
  2459  }
  2460  
  2461  func (s *RetryLayerChannelMemberHistoryStore) LogLeaveEvent(userId string, channelId string, leaveTime int64) error {
  2462  
  2463  	tries := 0
  2464  	for {
  2465  		err := s.ChannelMemberHistoryStore.LogLeaveEvent(userId, channelId, leaveTime)
  2466  		if err == nil {
  2467  			return nil
  2468  		}
  2469  		if !isRepeatableError(err) {
  2470  			return err
  2471  		}
  2472  		tries++
  2473  		if tries >= 3 {
  2474  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2475  			return err
  2476  		}
  2477  	}
  2478  
  2479  }
  2480  
  2481  func (s *RetryLayerChannelMemberHistoryStore) PermanentDeleteBatch(endTime int64, limit int64) (int64, error) {
  2482  
  2483  	tries := 0
  2484  	for {
  2485  		result, err := s.ChannelMemberHistoryStore.PermanentDeleteBatch(endTime, limit)
  2486  		if err == nil {
  2487  			return result, nil
  2488  		}
  2489  		if !isRepeatableError(err) {
  2490  			return result, err
  2491  		}
  2492  		tries++
  2493  		if tries >= 3 {
  2494  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2495  			return result, err
  2496  		}
  2497  	}
  2498  
  2499  }
  2500  
  2501  func (s *RetryLayerClusterDiscoveryStore) Cleanup() error {
  2502  
  2503  	tries := 0
  2504  	for {
  2505  		err := s.ClusterDiscoveryStore.Cleanup()
  2506  		if err == nil {
  2507  			return nil
  2508  		}
  2509  		if !isRepeatableError(err) {
  2510  			return err
  2511  		}
  2512  		tries++
  2513  		if tries >= 3 {
  2514  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2515  			return err
  2516  		}
  2517  	}
  2518  
  2519  }
  2520  
  2521  func (s *RetryLayerClusterDiscoveryStore) Delete(discovery *model.ClusterDiscovery) (bool, error) {
  2522  
  2523  	tries := 0
  2524  	for {
  2525  		result, err := s.ClusterDiscoveryStore.Delete(discovery)
  2526  		if err == nil {
  2527  			return result, nil
  2528  		}
  2529  		if !isRepeatableError(err) {
  2530  			return result, err
  2531  		}
  2532  		tries++
  2533  		if tries >= 3 {
  2534  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2535  			return result, err
  2536  		}
  2537  	}
  2538  
  2539  }
  2540  
  2541  func (s *RetryLayerClusterDiscoveryStore) Exists(discovery *model.ClusterDiscovery) (bool, error) {
  2542  
  2543  	tries := 0
  2544  	for {
  2545  		result, err := s.ClusterDiscoveryStore.Exists(discovery)
  2546  		if err == nil {
  2547  			return result, nil
  2548  		}
  2549  		if !isRepeatableError(err) {
  2550  			return result, err
  2551  		}
  2552  		tries++
  2553  		if tries >= 3 {
  2554  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2555  			return result, err
  2556  		}
  2557  	}
  2558  
  2559  }
  2560  
  2561  func (s *RetryLayerClusterDiscoveryStore) GetAll(discoveryType string, clusterName string) ([]*model.ClusterDiscovery, error) {
  2562  
  2563  	tries := 0
  2564  	for {
  2565  		result, err := s.ClusterDiscoveryStore.GetAll(discoveryType, clusterName)
  2566  		if err == nil {
  2567  			return result, nil
  2568  		}
  2569  		if !isRepeatableError(err) {
  2570  			return result, err
  2571  		}
  2572  		tries++
  2573  		if tries >= 3 {
  2574  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2575  			return result, err
  2576  		}
  2577  	}
  2578  
  2579  }
  2580  
  2581  func (s *RetryLayerClusterDiscoveryStore) Save(discovery *model.ClusterDiscovery) error {
  2582  
  2583  	tries := 0
  2584  	for {
  2585  		err := s.ClusterDiscoveryStore.Save(discovery)
  2586  		if err == nil {
  2587  			return nil
  2588  		}
  2589  		if !isRepeatableError(err) {
  2590  			return err
  2591  		}
  2592  		tries++
  2593  		if tries >= 3 {
  2594  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2595  			return err
  2596  		}
  2597  	}
  2598  
  2599  }
  2600  
  2601  func (s *RetryLayerClusterDiscoveryStore) SetLastPingAt(discovery *model.ClusterDiscovery) error {
  2602  
  2603  	tries := 0
  2604  	for {
  2605  		err := s.ClusterDiscoveryStore.SetLastPingAt(discovery)
  2606  		if err == nil {
  2607  			return nil
  2608  		}
  2609  		if !isRepeatableError(err) {
  2610  			return err
  2611  		}
  2612  		tries++
  2613  		if tries >= 3 {
  2614  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2615  			return err
  2616  		}
  2617  	}
  2618  
  2619  }
  2620  
  2621  func (s *RetryLayerCommandStore) AnalyticsCommandCount(teamId string) (int64, error) {
  2622  
  2623  	tries := 0
  2624  	for {
  2625  		result, err := s.CommandStore.AnalyticsCommandCount(teamId)
  2626  		if err == nil {
  2627  			return result, nil
  2628  		}
  2629  		if !isRepeatableError(err) {
  2630  			return result, err
  2631  		}
  2632  		tries++
  2633  		if tries >= 3 {
  2634  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2635  			return result, err
  2636  		}
  2637  	}
  2638  
  2639  }
  2640  
  2641  func (s *RetryLayerCommandStore) Delete(commandId string, time int64) error {
  2642  
  2643  	tries := 0
  2644  	for {
  2645  		err := s.CommandStore.Delete(commandId, time)
  2646  		if err == nil {
  2647  			return nil
  2648  		}
  2649  		if !isRepeatableError(err) {
  2650  			return err
  2651  		}
  2652  		tries++
  2653  		if tries >= 3 {
  2654  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2655  			return err
  2656  		}
  2657  	}
  2658  
  2659  }
  2660  
  2661  func (s *RetryLayerCommandStore) Get(id string) (*model.Command, error) {
  2662  
  2663  	tries := 0
  2664  	for {
  2665  		result, err := s.CommandStore.Get(id)
  2666  		if err == nil {
  2667  			return result, nil
  2668  		}
  2669  		if !isRepeatableError(err) {
  2670  			return result, err
  2671  		}
  2672  		tries++
  2673  		if tries >= 3 {
  2674  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2675  			return result, err
  2676  		}
  2677  	}
  2678  
  2679  }
  2680  
  2681  func (s *RetryLayerCommandStore) GetByTeam(teamId string) ([]*model.Command, error) {
  2682  
  2683  	tries := 0
  2684  	for {
  2685  		result, err := s.CommandStore.GetByTeam(teamId)
  2686  		if err == nil {
  2687  			return result, nil
  2688  		}
  2689  		if !isRepeatableError(err) {
  2690  			return result, err
  2691  		}
  2692  		tries++
  2693  		if tries >= 3 {
  2694  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2695  			return result, err
  2696  		}
  2697  	}
  2698  
  2699  }
  2700  
  2701  func (s *RetryLayerCommandStore) GetByTrigger(teamId string, trigger string) (*model.Command, error) {
  2702  
  2703  	tries := 0
  2704  	for {
  2705  		result, err := s.CommandStore.GetByTrigger(teamId, trigger)
  2706  		if err == nil {
  2707  			return result, nil
  2708  		}
  2709  		if !isRepeatableError(err) {
  2710  			return result, err
  2711  		}
  2712  		tries++
  2713  		if tries >= 3 {
  2714  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2715  			return result, err
  2716  		}
  2717  	}
  2718  
  2719  }
  2720  
  2721  func (s *RetryLayerCommandStore) PermanentDeleteByTeam(teamId string) error {
  2722  
  2723  	tries := 0
  2724  	for {
  2725  		err := s.CommandStore.PermanentDeleteByTeam(teamId)
  2726  		if err == nil {
  2727  			return nil
  2728  		}
  2729  		if !isRepeatableError(err) {
  2730  			return err
  2731  		}
  2732  		tries++
  2733  		if tries >= 3 {
  2734  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2735  			return err
  2736  		}
  2737  	}
  2738  
  2739  }
  2740  
  2741  func (s *RetryLayerCommandStore) PermanentDeleteByUser(userId string) error {
  2742  
  2743  	tries := 0
  2744  	for {
  2745  		err := s.CommandStore.PermanentDeleteByUser(userId)
  2746  		if err == nil {
  2747  			return nil
  2748  		}
  2749  		if !isRepeatableError(err) {
  2750  			return err
  2751  		}
  2752  		tries++
  2753  		if tries >= 3 {
  2754  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2755  			return err
  2756  		}
  2757  	}
  2758  
  2759  }
  2760  
  2761  func (s *RetryLayerCommandStore) Save(webhook *model.Command) (*model.Command, error) {
  2762  
  2763  	tries := 0
  2764  	for {
  2765  		result, err := s.CommandStore.Save(webhook)
  2766  		if err == nil {
  2767  			return result, nil
  2768  		}
  2769  		if !isRepeatableError(err) {
  2770  			return result, err
  2771  		}
  2772  		tries++
  2773  		if tries >= 3 {
  2774  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2775  			return result, err
  2776  		}
  2777  	}
  2778  
  2779  }
  2780  
  2781  func (s *RetryLayerCommandStore) Update(hook *model.Command) (*model.Command, error) {
  2782  
  2783  	tries := 0
  2784  	for {
  2785  		result, err := s.CommandStore.Update(hook)
  2786  		if err == nil {
  2787  			return result, nil
  2788  		}
  2789  		if !isRepeatableError(err) {
  2790  			return result, err
  2791  		}
  2792  		tries++
  2793  		if tries >= 3 {
  2794  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2795  			return result, err
  2796  		}
  2797  	}
  2798  
  2799  }
  2800  
  2801  func (s *RetryLayerCommandWebhookStore) Cleanup() {
  2802  
  2803  	s.CommandWebhookStore.Cleanup()
  2804  
  2805  }
  2806  
  2807  func (s *RetryLayerCommandWebhookStore) Get(id string) (*model.CommandWebhook, error) {
  2808  
  2809  	tries := 0
  2810  	for {
  2811  		result, err := s.CommandWebhookStore.Get(id)
  2812  		if err == nil {
  2813  			return result, nil
  2814  		}
  2815  		if !isRepeatableError(err) {
  2816  			return result, err
  2817  		}
  2818  		tries++
  2819  		if tries >= 3 {
  2820  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2821  			return result, err
  2822  		}
  2823  	}
  2824  
  2825  }
  2826  
  2827  func (s *RetryLayerCommandWebhookStore) Save(webhook *model.CommandWebhook) (*model.CommandWebhook, error) {
  2828  
  2829  	tries := 0
  2830  	for {
  2831  		result, err := s.CommandWebhookStore.Save(webhook)
  2832  		if err == nil {
  2833  			return result, nil
  2834  		}
  2835  		if !isRepeatableError(err) {
  2836  			return result, err
  2837  		}
  2838  		tries++
  2839  		if tries >= 3 {
  2840  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2841  			return result, err
  2842  		}
  2843  	}
  2844  
  2845  }
  2846  
  2847  func (s *RetryLayerCommandWebhookStore) TryUse(id string, limit int) error {
  2848  
  2849  	tries := 0
  2850  	for {
  2851  		err := s.CommandWebhookStore.TryUse(id, limit)
  2852  		if err == nil {
  2853  			return nil
  2854  		}
  2855  		if !isRepeatableError(err) {
  2856  			return err
  2857  		}
  2858  		tries++
  2859  		if tries >= 3 {
  2860  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2861  			return err
  2862  		}
  2863  	}
  2864  
  2865  }
  2866  
  2867  func (s *RetryLayerComplianceStore) ComplianceExport(compliance *model.Compliance) ([]*model.CompliancePost, error) {
  2868  
  2869  	tries := 0
  2870  	for {
  2871  		result, err := s.ComplianceStore.ComplianceExport(compliance)
  2872  		if err == nil {
  2873  			return result, nil
  2874  		}
  2875  		if !isRepeatableError(err) {
  2876  			return result, err
  2877  		}
  2878  		tries++
  2879  		if tries >= 3 {
  2880  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2881  			return result, err
  2882  		}
  2883  	}
  2884  
  2885  }
  2886  
  2887  func (s *RetryLayerComplianceStore) Get(id string) (*model.Compliance, error) {
  2888  
  2889  	tries := 0
  2890  	for {
  2891  		result, err := s.ComplianceStore.Get(id)
  2892  		if err == nil {
  2893  			return result, nil
  2894  		}
  2895  		if !isRepeatableError(err) {
  2896  			return result, err
  2897  		}
  2898  		tries++
  2899  		if tries >= 3 {
  2900  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2901  			return result, err
  2902  		}
  2903  	}
  2904  
  2905  }
  2906  
  2907  func (s *RetryLayerComplianceStore) GetAll(offset int, limit int) (model.Compliances, error) {
  2908  
  2909  	tries := 0
  2910  	for {
  2911  		result, err := s.ComplianceStore.GetAll(offset, limit)
  2912  		if err == nil {
  2913  			return result, nil
  2914  		}
  2915  		if !isRepeatableError(err) {
  2916  			return result, err
  2917  		}
  2918  		tries++
  2919  		if tries >= 3 {
  2920  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2921  			return result, err
  2922  		}
  2923  	}
  2924  
  2925  }
  2926  
  2927  func (s *RetryLayerComplianceStore) MessageExport(after int64, limit int) ([]*model.MessageExport, error) {
  2928  
  2929  	tries := 0
  2930  	for {
  2931  		result, err := s.ComplianceStore.MessageExport(after, limit)
  2932  		if err == nil {
  2933  			return result, nil
  2934  		}
  2935  		if !isRepeatableError(err) {
  2936  			return result, err
  2937  		}
  2938  		tries++
  2939  		if tries >= 3 {
  2940  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2941  			return result, err
  2942  		}
  2943  	}
  2944  
  2945  }
  2946  
  2947  func (s *RetryLayerComplianceStore) Save(compliance *model.Compliance) (*model.Compliance, error) {
  2948  
  2949  	tries := 0
  2950  	for {
  2951  		result, err := s.ComplianceStore.Save(compliance)
  2952  		if err == nil {
  2953  			return result, nil
  2954  		}
  2955  		if !isRepeatableError(err) {
  2956  			return result, err
  2957  		}
  2958  		tries++
  2959  		if tries >= 3 {
  2960  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2961  			return result, err
  2962  		}
  2963  	}
  2964  
  2965  }
  2966  
  2967  func (s *RetryLayerComplianceStore) Update(compliance *model.Compliance) (*model.Compliance, error) {
  2968  
  2969  	tries := 0
  2970  	for {
  2971  		result, err := s.ComplianceStore.Update(compliance)
  2972  		if err == nil {
  2973  			return result, nil
  2974  		}
  2975  		if !isRepeatableError(err) {
  2976  			return result, err
  2977  		}
  2978  		tries++
  2979  		if tries >= 3 {
  2980  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  2981  			return result, err
  2982  		}
  2983  	}
  2984  
  2985  }
  2986  
  2987  func (s *RetryLayerEmojiStore) Delete(emoji *model.Emoji, time int64) error {
  2988  
  2989  	tries := 0
  2990  	for {
  2991  		err := s.EmojiStore.Delete(emoji, time)
  2992  		if err == nil {
  2993  			return nil
  2994  		}
  2995  		if !isRepeatableError(err) {
  2996  			return err
  2997  		}
  2998  		tries++
  2999  		if tries >= 3 {
  3000  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3001  			return err
  3002  		}
  3003  	}
  3004  
  3005  }
  3006  
  3007  func (s *RetryLayerEmojiStore) Get(id string, allowFromCache bool) (*model.Emoji, error) {
  3008  
  3009  	tries := 0
  3010  	for {
  3011  		result, err := s.EmojiStore.Get(id, allowFromCache)
  3012  		if err == nil {
  3013  			return result, nil
  3014  		}
  3015  		if !isRepeatableError(err) {
  3016  			return result, err
  3017  		}
  3018  		tries++
  3019  		if tries >= 3 {
  3020  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3021  			return result, err
  3022  		}
  3023  	}
  3024  
  3025  }
  3026  
  3027  func (s *RetryLayerEmojiStore) GetByName(name string, allowFromCache bool) (*model.Emoji, error) {
  3028  
  3029  	tries := 0
  3030  	for {
  3031  		result, err := s.EmojiStore.GetByName(name, allowFromCache)
  3032  		if err == nil {
  3033  			return result, nil
  3034  		}
  3035  		if !isRepeatableError(err) {
  3036  			return result, err
  3037  		}
  3038  		tries++
  3039  		if tries >= 3 {
  3040  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3041  			return result, err
  3042  		}
  3043  	}
  3044  
  3045  }
  3046  
  3047  func (s *RetryLayerEmojiStore) GetList(offset int, limit int, sort string) ([]*model.Emoji, error) {
  3048  
  3049  	tries := 0
  3050  	for {
  3051  		result, err := s.EmojiStore.GetList(offset, limit, sort)
  3052  		if err == nil {
  3053  			return result, nil
  3054  		}
  3055  		if !isRepeatableError(err) {
  3056  			return result, err
  3057  		}
  3058  		tries++
  3059  		if tries >= 3 {
  3060  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3061  			return result, err
  3062  		}
  3063  	}
  3064  
  3065  }
  3066  
  3067  func (s *RetryLayerEmojiStore) GetMultipleByName(names []string) ([]*model.Emoji, error) {
  3068  
  3069  	tries := 0
  3070  	for {
  3071  		result, err := s.EmojiStore.GetMultipleByName(names)
  3072  		if err == nil {
  3073  			return result, nil
  3074  		}
  3075  		if !isRepeatableError(err) {
  3076  			return result, err
  3077  		}
  3078  		tries++
  3079  		if tries >= 3 {
  3080  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3081  			return result, err
  3082  		}
  3083  	}
  3084  
  3085  }
  3086  
  3087  func (s *RetryLayerEmojiStore) Save(emoji *model.Emoji) (*model.Emoji, error) {
  3088  
  3089  	tries := 0
  3090  	for {
  3091  		result, err := s.EmojiStore.Save(emoji)
  3092  		if err == nil {
  3093  			return result, nil
  3094  		}
  3095  		if !isRepeatableError(err) {
  3096  			return result, err
  3097  		}
  3098  		tries++
  3099  		if tries >= 3 {
  3100  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3101  			return result, err
  3102  		}
  3103  	}
  3104  
  3105  }
  3106  
  3107  func (s *RetryLayerEmojiStore) Search(name string, prefixOnly bool, limit int) ([]*model.Emoji, error) {
  3108  
  3109  	tries := 0
  3110  	for {
  3111  		result, err := s.EmojiStore.Search(name, prefixOnly, limit)
  3112  		if err == nil {
  3113  			return result, nil
  3114  		}
  3115  		if !isRepeatableError(err) {
  3116  			return result, err
  3117  		}
  3118  		tries++
  3119  		if tries >= 3 {
  3120  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3121  			return result, err
  3122  		}
  3123  	}
  3124  
  3125  }
  3126  
  3127  func (s *RetryLayerFileInfoStore) AttachToPost(fileId string, postId string, creatorId string) error {
  3128  
  3129  	tries := 0
  3130  	for {
  3131  		err := s.FileInfoStore.AttachToPost(fileId, postId, creatorId)
  3132  		if err == nil {
  3133  			return nil
  3134  		}
  3135  		if !isRepeatableError(err) {
  3136  			return err
  3137  		}
  3138  		tries++
  3139  		if tries >= 3 {
  3140  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3141  			return err
  3142  		}
  3143  	}
  3144  
  3145  }
  3146  
  3147  func (s *RetryLayerFileInfoStore) ClearCaches() {
  3148  
  3149  	s.FileInfoStore.ClearCaches()
  3150  
  3151  }
  3152  
  3153  func (s *RetryLayerFileInfoStore) DeleteForPost(postId string) (string, error) {
  3154  
  3155  	tries := 0
  3156  	for {
  3157  		result, err := s.FileInfoStore.DeleteForPost(postId)
  3158  		if err == nil {
  3159  			return result, nil
  3160  		}
  3161  		if !isRepeatableError(err) {
  3162  			return result, err
  3163  		}
  3164  		tries++
  3165  		if tries >= 3 {
  3166  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3167  			return result, err
  3168  		}
  3169  	}
  3170  
  3171  }
  3172  
  3173  func (s *RetryLayerFileInfoStore) Get(id string) (*model.FileInfo, error) {
  3174  
  3175  	tries := 0
  3176  	for {
  3177  		result, err := s.FileInfoStore.Get(id)
  3178  		if err == nil {
  3179  			return result, nil
  3180  		}
  3181  		if !isRepeatableError(err) {
  3182  			return result, err
  3183  		}
  3184  		tries++
  3185  		if tries >= 3 {
  3186  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3187  			return result, err
  3188  		}
  3189  	}
  3190  
  3191  }
  3192  
  3193  func (s *RetryLayerFileInfoStore) GetByIds(ids []string) ([]*model.FileInfo, error) {
  3194  
  3195  	tries := 0
  3196  	for {
  3197  		result, err := s.FileInfoStore.GetByIds(ids)
  3198  		if err == nil {
  3199  			return result, nil
  3200  		}
  3201  		if !isRepeatableError(err) {
  3202  			return result, err
  3203  		}
  3204  		tries++
  3205  		if tries >= 3 {
  3206  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3207  			return result, err
  3208  		}
  3209  	}
  3210  
  3211  }
  3212  
  3213  func (s *RetryLayerFileInfoStore) GetByPath(path string) (*model.FileInfo, error) {
  3214  
  3215  	tries := 0
  3216  	for {
  3217  		result, err := s.FileInfoStore.GetByPath(path)
  3218  		if err == nil {
  3219  			return result, nil
  3220  		}
  3221  		if !isRepeatableError(err) {
  3222  			return result, err
  3223  		}
  3224  		tries++
  3225  		if tries >= 3 {
  3226  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3227  			return result, err
  3228  		}
  3229  	}
  3230  
  3231  }
  3232  
  3233  func (s *RetryLayerFileInfoStore) GetForPost(postId string, readFromMaster bool, includeDeleted bool, allowFromCache bool) ([]*model.FileInfo, error) {
  3234  
  3235  	tries := 0
  3236  	for {
  3237  		result, err := s.FileInfoStore.GetForPost(postId, readFromMaster, includeDeleted, allowFromCache)
  3238  		if err == nil {
  3239  			return result, nil
  3240  		}
  3241  		if !isRepeatableError(err) {
  3242  			return result, err
  3243  		}
  3244  		tries++
  3245  		if tries >= 3 {
  3246  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3247  			return result, err
  3248  		}
  3249  	}
  3250  
  3251  }
  3252  
  3253  func (s *RetryLayerFileInfoStore) GetForUser(userId string) ([]*model.FileInfo, error) {
  3254  
  3255  	tries := 0
  3256  	for {
  3257  		result, err := s.FileInfoStore.GetForUser(userId)
  3258  		if err == nil {
  3259  			return result, nil
  3260  		}
  3261  		if !isRepeatableError(err) {
  3262  			return result, err
  3263  		}
  3264  		tries++
  3265  		if tries >= 3 {
  3266  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3267  			return result, err
  3268  		}
  3269  	}
  3270  
  3271  }
  3272  
  3273  func (s *RetryLayerFileInfoStore) GetWithOptions(page int, perPage int, opt *model.GetFileInfosOptions) ([]*model.FileInfo, error) {
  3274  
  3275  	tries := 0
  3276  	for {
  3277  		result, err := s.FileInfoStore.GetWithOptions(page, perPage, opt)
  3278  		if err == nil {
  3279  			return result, nil
  3280  		}
  3281  		if !isRepeatableError(err) {
  3282  			return result, err
  3283  		}
  3284  		tries++
  3285  		if tries >= 3 {
  3286  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3287  			return result, err
  3288  		}
  3289  	}
  3290  
  3291  }
  3292  
  3293  func (s *RetryLayerFileInfoStore) InvalidateFileInfosForPostCache(postId string, deleted bool) {
  3294  
  3295  	s.FileInfoStore.InvalidateFileInfosForPostCache(postId, deleted)
  3296  
  3297  }
  3298  
  3299  func (s *RetryLayerFileInfoStore) PermanentDelete(fileId string) error {
  3300  
  3301  	tries := 0
  3302  	for {
  3303  		err := s.FileInfoStore.PermanentDelete(fileId)
  3304  		if err == nil {
  3305  			return nil
  3306  		}
  3307  		if !isRepeatableError(err) {
  3308  			return err
  3309  		}
  3310  		tries++
  3311  		if tries >= 3 {
  3312  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3313  			return err
  3314  		}
  3315  	}
  3316  
  3317  }
  3318  
  3319  func (s *RetryLayerFileInfoStore) PermanentDeleteBatch(endTime int64, limit int64) (int64, error) {
  3320  
  3321  	tries := 0
  3322  	for {
  3323  		result, err := s.FileInfoStore.PermanentDeleteBatch(endTime, limit)
  3324  		if err == nil {
  3325  			return result, nil
  3326  		}
  3327  		if !isRepeatableError(err) {
  3328  			return result, err
  3329  		}
  3330  		tries++
  3331  		if tries >= 3 {
  3332  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3333  			return result, err
  3334  		}
  3335  	}
  3336  
  3337  }
  3338  
  3339  func (s *RetryLayerFileInfoStore) PermanentDeleteByUser(userId string) (int64, error) {
  3340  
  3341  	tries := 0
  3342  	for {
  3343  		result, err := s.FileInfoStore.PermanentDeleteByUser(userId)
  3344  		if err == nil {
  3345  			return result, nil
  3346  		}
  3347  		if !isRepeatableError(err) {
  3348  			return result, err
  3349  		}
  3350  		tries++
  3351  		if tries >= 3 {
  3352  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3353  			return result, err
  3354  		}
  3355  	}
  3356  
  3357  }
  3358  
  3359  func (s *RetryLayerFileInfoStore) Save(info *model.FileInfo) (*model.FileInfo, error) {
  3360  
  3361  	tries := 0
  3362  	for {
  3363  		result, err := s.FileInfoStore.Save(info)
  3364  		if err == nil {
  3365  			return result, nil
  3366  		}
  3367  		if !isRepeatableError(err) {
  3368  			return result, err
  3369  		}
  3370  		tries++
  3371  		if tries >= 3 {
  3372  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3373  			return result, err
  3374  		}
  3375  	}
  3376  
  3377  }
  3378  
  3379  func (s *RetryLayerFileInfoStore) Search(paramsList []*model.SearchParams, userId string, teamId string, page int, perPage int) (*model.FileInfoList, error) {
  3380  
  3381  	tries := 0
  3382  	for {
  3383  		result, err := s.FileInfoStore.Search(paramsList, userId, teamId, page, perPage)
  3384  		if err == nil {
  3385  			return result, nil
  3386  		}
  3387  		if !isRepeatableError(err) {
  3388  			return result, err
  3389  		}
  3390  		tries++
  3391  		if tries >= 3 {
  3392  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3393  			return result, err
  3394  		}
  3395  	}
  3396  
  3397  }
  3398  
  3399  func (s *RetryLayerFileInfoStore) SetContent(fileId string, content string) error {
  3400  
  3401  	tries := 0
  3402  	for {
  3403  		err := s.FileInfoStore.SetContent(fileId, content)
  3404  		if err == nil {
  3405  			return nil
  3406  		}
  3407  		if !isRepeatableError(err) {
  3408  			return err
  3409  		}
  3410  		tries++
  3411  		if tries >= 3 {
  3412  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3413  			return err
  3414  		}
  3415  	}
  3416  
  3417  }
  3418  
  3419  func (s *RetryLayerFileInfoStore) Upsert(info *model.FileInfo) (*model.FileInfo, error) {
  3420  
  3421  	tries := 0
  3422  	for {
  3423  		result, err := s.FileInfoStore.Upsert(info)
  3424  		if err == nil {
  3425  			return result, nil
  3426  		}
  3427  		if !isRepeatableError(err) {
  3428  			return result, err
  3429  		}
  3430  		tries++
  3431  		if tries >= 3 {
  3432  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3433  			return result, err
  3434  		}
  3435  	}
  3436  
  3437  }
  3438  
  3439  func (s *RetryLayerGroupStore) AdminRoleGroupsForSyncableMember(userID string, syncableID string, syncableType model.GroupSyncableType) ([]string, error) {
  3440  
  3441  	tries := 0
  3442  	for {
  3443  		result, err := s.GroupStore.AdminRoleGroupsForSyncableMember(userID, syncableID, syncableType)
  3444  		if err == nil {
  3445  			return result, nil
  3446  		}
  3447  		if !isRepeatableError(err) {
  3448  			return result, err
  3449  		}
  3450  		tries++
  3451  		if tries >= 3 {
  3452  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3453  			return result, err
  3454  		}
  3455  	}
  3456  
  3457  }
  3458  
  3459  func (s *RetryLayerGroupStore) ChannelMembersMinusGroupMembers(channelID string, groupIDs []string, page int, perPage int) ([]*model.UserWithGroups, error) {
  3460  
  3461  	tries := 0
  3462  	for {
  3463  		result, err := s.GroupStore.ChannelMembersMinusGroupMembers(channelID, groupIDs, page, perPage)
  3464  		if err == nil {
  3465  			return result, nil
  3466  		}
  3467  		if !isRepeatableError(err) {
  3468  			return result, err
  3469  		}
  3470  		tries++
  3471  		if tries >= 3 {
  3472  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3473  			return result, err
  3474  		}
  3475  	}
  3476  
  3477  }
  3478  
  3479  func (s *RetryLayerGroupStore) ChannelMembersToAdd(since int64, channelID *string) ([]*model.UserChannelIDPair, error) {
  3480  
  3481  	tries := 0
  3482  	for {
  3483  		result, err := s.GroupStore.ChannelMembersToAdd(since, channelID)
  3484  		if err == nil {
  3485  			return result, nil
  3486  		}
  3487  		if !isRepeatableError(err) {
  3488  			return result, err
  3489  		}
  3490  		tries++
  3491  		if tries >= 3 {
  3492  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3493  			return result, err
  3494  		}
  3495  	}
  3496  
  3497  }
  3498  
  3499  func (s *RetryLayerGroupStore) ChannelMembersToRemove(channelID *string) ([]*model.ChannelMember, error) {
  3500  
  3501  	tries := 0
  3502  	for {
  3503  		result, err := s.GroupStore.ChannelMembersToRemove(channelID)
  3504  		if err == nil {
  3505  			return result, nil
  3506  		}
  3507  		if !isRepeatableError(err) {
  3508  			return result, err
  3509  		}
  3510  		tries++
  3511  		if tries >= 3 {
  3512  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3513  			return result, err
  3514  		}
  3515  	}
  3516  
  3517  }
  3518  
  3519  func (s *RetryLayerGroupStore) CountChannelMembersMinusGroupMembers(channelID string, groupIDs []string) (int64, error) {
  3520  
  3521  	tries := 0
  3522  	for {
  3523  		result, err := s.GroupStore.CountChannelMembersMinusGroupMembers(channelID, groupIDs)
  3524  		if err == nil {
  3525  			return result, nil
  3526  		}
  3527  		if !isRepeatableError(err) {
  3528  			return result, err
  3529  		}
  3530  		tries++
  3531  		if tries >= 3 {
  3532  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3533  			return result, err
  3534  		}
  3535  	}
  3536  
  3537  }
  3538  
  3539  func (s *RetryLayerGroupStore) CountGroupsByChannel(channelId string, opts model.GroupSearchOpts) (int64, error) {
  3540  
  3541  	tries := 0
  3542  	for {
  3543  		result, err := s.GroupStore.CountGroupsByChannel(channelId, opts)
  3544  		if err == nil {
  3545  			return result, nil
  3546  		}
  3547  		if !isRepeatableError(err) {
  3548  			return result, err
  3549  		}
  3550  		tries++
  3551  		if tries >= 3 {
  3552  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3553  			return result, err
  3554  		}
  3555  	}
  3556  
  3557  }
  3558  
  3559  func (s *RetryLayerGroupStore) CountGroupsByTeam(teamId string, opts model.GroupSearchOpts) (int64, error) {
  3560  
  3561  	tries := 0
  3562  	for {
  3563  		result, err := s.GroupStore.CountGroupsByTeam(teamId, opts)
  3564  		if err == nil {
  3565  			return result, nil
  3566  		}
  3567  		if !isRepeatableError(err) {
  3568  			return result, err
  3569  		}
  3570  		tries++
  3571  		if tries >= 3 {
  3572  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3573  			return result, err
  3574  		}
  3575  	}
  3576  
  3577  }
  3578  
  3579  func (s *RetryLayerGroupStore) CountTeamMembersMinusGroupMembers(teamID string, groupIDs []string) (int64, error) {
  3580  
  3581  	tries := 0
  3582  	for {
  3583  		result, err := s.GroupStore.CountTeamMembersMinusGroupMembers(teamID, groupIDs)
  3584  		if err == nil {
  3585  			return result, nil
  3586  		}
  3587  		if !isRepeatableError(err) {
  3588  			return result, err
  3589  		}
  3590  		tries++
  3591  		if tries >= 3 {
  3592  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3593  			return result, err
  3594  		}
  3595  	}
  3596  
  3597  }
  3598  
  3599  func (s *RetryLayerGroupStore) Create(group *model.Group) (*model.Group, error) {
  3600  
  3601  	tries := 0
  3602  	for {
  3603  		result, err := s.GroupStore.Create(group)
  3604  		if err == nil {
  3605  			return result, nil
  3606  		}
  3607  		if !isRepeatableError(err) {
  3608  			return result, err
  3609  		}
  3610  		tries++
  3611  		if tries >= 3 {
  3612  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3613  			return result, err
  3614  		}
  3615  	}
  3616  
  3617  }
  3618  
  3619  func (s *RetryLayerGroupStore) CreateGroupSyncable(groupSyncable *model.GroupSyncable) (*model.GroupSyncable, error) {
  3620  
  3621  	tries := 0
  3622  	for {
  3623  		result, err := s.GroupStore.CreateGroupSyncable(groupSyncable)
  3624  		if err == nil {
  3625  			return result, nil
  3626  		}
  3627  		if !isRepeatableError(err) {
  3628  			return result, err
  3629  		}
  3630  		tries++
  3631  		if tries >= 3 {
  3632  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3633  			return result, err
  3634  		}
  3635  	}
  3636  
  3637  }
  3638  
  3639  func (s *RetryLayerGroupStore) Delete(groupID string) (*model.Group, error) {
  3640  
  3641  	tries := 0
  3642  	for {
  3643  		result, err := s.GroupStore.Delete(groupID)
  3644  		if err == nil {
  3645  			return result, nil
  3646  		}
  3647  		if !isRepeatableError(err) {
  3648  			return result, err
  3649  		}
  3650  		tries++
  3651  		if tries >= 3 {
  3652  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3653  			return result, err
  3654  		}
  3655  	}
  3656  
  3657  }
  3658  
  3659  func (s *RetryLayerGroupStore) DeleteGroupSyncable(groupID string, syncableID string, syncableType model.GroupSyncableType) (*model.GroupSyncable, error) {
  3660  
  3661  	tries := 0
  3662  	for {
  3663  		result, err := s.GroupStore.DeleteGroupSyncable(groupID, syncableID, syncableType)
  3664  		if err == nil {
  3665  			return result, nil
  3666  		}
  3667  		if !isRepeatableError(err) {
  3668  			return result, err
  3669  		}
  3670  		tries++
  3671  		if tries >= 3 {
  3672  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3673  			return result, err
  3674  		}
  3675  	}
  3676  
  3677  }
  3678  
  3679  func (s *RetryLayerGroupStore) DeleteMember(groupID string, userID string) (*model.GroupMember, error) {
  3680  
  3681  	tries := 0
  3682  	for {
  3683  		result, err := s.GroupStore.DeleteMember(groupID, userID)
  3684  		if err == nil {
  3685  			return result, nil
  3686  		}
  3687  		if !isRepeatableError(err) {
  3688  			return result, err
  3689  		}
  3690  		tries++
  3691  		if tries >= 3 {
  3692  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3693  			return result, err
  3694  		}
  3695  	}
  3696  
  3697  }
  3698  
  3699  func (s *RetryLayerGroupStore) DistinctGroupMemberCount() (int64, error) {
  3700  
  3701  	tries := 0
  3702  	for {
  3703  		result, err := s.GroupStore.DistinctGroupMemberCount()
  3704  		if err == nil {
  3705  			return result, nil
  3706  		}
  3707  		if !isRepeatableError(err) {
  3708  			return result, err
  3709  		}
  3710  		tries++
  3711  		if tries >= 3 {
  3712  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3713  			return result, err
  3714  		}
  3715  	}
  3716  
  3717  }
  3718  
  3719  func (s *RetryLayerGroupStore) Get(groupID string) (*model.Group, error) {
  3720  
  3721  	tries := 0
  3722  	for {
  3723  		result, err := s.GroupStore.Get(groupID)
  3724  		if err == nil {
  3725  			return result, nil
  3726  		}
  3727  		if !isRepeatableError(err) {
  3728  			return result, err
  3729  		}
  3730  		tries++
  3731  		if tries >= 3 {
  3732  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3733  			return result, err
  3734  		}
  3735  	}
  3736  
  3737  }
  3738  
  3739  func (s *RetryLayerGroupStore) GetAllBySource(groupSource model.GroupSource) ([]*model.Group, error) {
  3740  
  3741  	tries := 0
  3742  	for {
  3743  		result, err := s.GroupStore.GetAllBySource(groupSource)
  3744  		if err == nil {
  3745  			return result, nil
  3746  		}
  3747  		if !isRepeatableError(err) {
  3748  			return result, err
  3749  		}
  3750  		tries++
  3751  		if tries >= 3 {
  3752  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3753  			return result, err
  3754  		}
  3755  	}
  3756  
  3757  }
  3758  
  3759  func (s *RetryLayerGroupStore) GetAllGroupSyncablesByGroupId(groupID string, syncableType model.GroupSyncableType) ([]*model.GroupSyncable, error) {
  3760  
  3761  	tries := 0
  3762  	for {
  3763  		result, err := s.GroupStore.GetAllGroupSyncablesByGroupId(groupID, syncableType)
  3764  		if err == nil {
  3765  			return result, nil
  3766  		}
  3767  		if !isRepeatableError(err) {
  3768  			return result, err
  3769  		}
  3770  		tries++
  3771  		if tries >= 3 {
  3772  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3773  			return result, err
  3774  		}
  3775  	}
  3776  
  3777  }
  3778  
  3779  func (s *RetryLayerGroupStore) GetByIDs(groupIDs []string) ([]*model.Group, error) {
  3780  
  3781  	tries := 0
  3782  	for {
  3783  		result, err := s.GroupStore.GetByIDs(groupIDs)
  3784  		if err == nil {
  3785  			return result, nil
  3786  		}
  3787  		if !isRepeatableError(err) {
  3788  			return result, err
  3789  		}
  3790  		tries++
  3791  		if tries >= 3 {
  3792  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3793  			return result, err
  3794  		}
  3795  	}
  3796  
  3797  }
  3798  
  3799  func (s *RetryLayerGroupStore) GetByName(name string, opts model.GroupSearchOpts) (*model.Group, error) {
  3800  
  3801  	tries := 0
  3802  	for {
  3803  		result, err := s.GroupStore.GetByName(name, opts)
  3804  		if err == nil {
  3805  			return result, nil
  3806  		}
  3807  		if !isRepeatableError(err) {
  3808  			return result, err
  3809  		}
  3810  		tries++
  3811  		if tries >= 3 {
  3812  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3813  			return result, err
  3814  		}
  3815  	}
  3816  
  3817  }
  3818  
  3819  func (s *RetryLayerGroupStore) GetByRemoteID(remoteID string, groupSource model.GroupSource) (*model.Group, error) {
  3820  
  3821  	tries := 0
  3822  	for {
  3823  		result, err := s.GroupStore.GetByRemoteID(remoteID, groupSource)
  3824  		if err == nil {
  3825  			return result, nil
  3826  		}
  3827  		if !isRepeatableError(err) {
  3828  			return result, err
  3829  		}
  3830  		tries++
  3831  		if tries >= 3 {
  3832  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3833  			return result, err
  3834  		}
  3835  	}
  3836  
  3837  }
  3838  
  3839  func (s *RetryLayerGroupStore) GetByUser(userId string) ([]*model.Group, error) {
  3840  
  3841  	tries := 0
  3842  	for {
  3843  		result, err := s.GroupStore.GetByUser(userId)
  3844  		if err == nil {
  3845  			return result, nil
  3846  		}
  3847  		if !isRepeatableError(err) {
  3848  			return result, err
  3849  		}
  3850  		tries++
  3851  		if tries >= 3 {
  3852  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3853  			return result, err
  3854  		}
  3855  	}
  3856  
  3857  }
  3858  
  3859  func (s *RetryLayerGroupStore) GetGroupSyncable(groupID string, syncableID string, syncableType model.GroupSyncableType) (*model.GroupSyncable, error) {
  3860  
  3861  	tries := 0
  3862  	for {
  3863  		result, err := s.GroupStore.GetGroupSyncable(groupID, syncableID, syncableType)
  3864  		if err == nil {
  3865  			return result, nil
  3866  		}
  3867  		if !isRepeatableError(err) {
  3868  			return result, err
  3869  		}
  3870  		tries++
  3871  		if tries >= 3 {
  3872  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3873  			return result, err
  3874  		}
  3875  	}
  3876  
  3877  }
  3878  
  3879  func (s *RetryLayerGroupStore) GetGroups(page int, perPage int, opts model.GroupSearchOpts) ([]*model.Group, error) {
  3880  
  3881  	tries := 0
  3882  	for {
  3883  		result, err := s.GroupStore.GetGroups(page, perPage, opts)
  3884  		if err == nil {
  3885  			return result, nil
  3886  		}
  3887  		if !isRepeatableError(err) {
  3888  			return result, err
  3889  		}
  3890  		tries++
  3891  		if tries >= 3 {
  3892  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3893  			return result, err
  3894  		}
  3895  	}
  3896  
  3897  }
  3898  
  3899  func (s *RetryLayerGroupStore) GetGroupsAssociatedToChannelsByTeam(teamId string, opts model.GroupSearchOpts) (map[string][]*model.GroupWithSchemeAdmin, error) {
  3900  
  3901  	tries := 0
  3902  	for {
  3903  		result, err := s.GroupStore.GetGroupsAssociatedToChannelsByTeam(teamId, opts)
  3904  		if err == nil {
  3905  			return result, nil
  3906  		}
  3907  		if !isRepeatableError(err) {
  3908  			return result, err
  3909  		}
  3910  		tries++
  3911  		if tries >= 3 {
  3912  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3913  			return result, err
  3914  		}
  3915  	}
  3916  
  3917  }
  3918  
  3919  func (s *RetryLayerGroupStore) GetGroupsByChannel(channelId string, opts model.GroupSearchOpts) ([]*model.GroupWithSchemeAdmin, error) {
  3920  
  3921  	tries := 0
  3922  	for {
  3923  		result, err := s.GroupStore.GetGroupsByChannel(channelId, opts)
  3924  		if err == nil {
  3925  			return result, nil
  3926  		}
  3927  		if !isRepeatableError(err) {
  3928  			return result, err
  3929  		}
  3930  		tries++
  3931  		if tries >= 3 {
  3932  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3933  			return result, err
  3934  		}
  3935  	}
  3936  
  3937  }
  3938  
  3939  func (s *RetryLayerGroupStore) GetGroupsByTeam(teamId string, opts model.GroupSearchOpts) ([]*model.GroupWithSchemeAdmin, error) {
  3940  
  3941  	tries := 0
  3942  	for {
  3943  		result, err := s.GroupStore.GetGroupsByTeam(teamId, opts)
  3944  		if err == nil {
  3945  			return result, nil
  3946  		}
  3947  		if !isRepeatableError(err) {
  3948  			return result, err
  3949  		}
  3950  		tries++
  3951  		if tries >= 3 {
  3952  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3953  			return result, err
  3954  		}
  3955  	}
  3956  
  3957  }
  3958  
  3959  func (s *RetryLayerGroupStore) GetMemberCount(groupID string) (int64, error) {
  3960  
  3961  	tries := 0
  3962  	for {
  3963  		result, err := s.GroupStore.GetMemberCount(groupID)
  3964  		if err == nil {
  3965  			return result, nil
  3966  		}
  3967  		if !isRepeatableError(err) {
  3968  			return result, err
  3969  		}
  3970  		tries++
  3971  		if tries >= 3 {
  3972  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3973  			return result, err
  3974  		}
  3975  	}
  3976  
  3977  }
  3978  
  3979  func (s *RetryLayerGroupStore) GetMemberUsers(groupID string) ([]*model.User, error) {
  3980  
  3981  	tries := 0
  3982  	for {
  3983  		result, err := s.GroupStore.GetMemberUsers(groupID)
  3984  		if err == nil {
  3985  			return result, nil
  3986  		}
  3987  		if !isRepeatableError(err) {
  3988  			return result, err
  3989  		}
  3990  		tries++
  3991  		if tries >= 3 {
  3992  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  3993  			return result, err
  3994  		}
  3995  	}
  3996  
  3997  }
  3998  
  3999  func (s *RetryLayerGroupStore) GetMemberUsersInTeam(groupID string, teamID string) ([]*model.User, error) {
  4000  
  4001  	tries := 0
  4002  	for {
  4003  		result, err := s.GroupStore.GetMemberUsersInTeam(groupID, teamID)
  4004  		if err == nil {
  4005  			return result, nil
  4006  		}
  4007  		if !isRepeatableError(err) {
  4008  			return result, err
  4009  		}
  4010  		tries++
  4011  		if tries >= 3 {
  4012  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4013  			return result, err
  4014  		}
  4015  	}
  4016  
  4017  }
  4018  
  4019  func (s *RetryLayerGroupStore) GetMemberUsersNotInChannel(groupID string, channelID string) ([]*model.User, error) {
  4020  
  4021  	tries := 0
  4022  	for {
  4023  		result, err := s.GroupStore.GetMemberUsersNotInChannel(groupID, channelID)
  4024  		if err == nil {
  4025  			return result, nil
  4026  		}
  4027  		if !isRepeatableError(err) {
  4028  			return result, err
  4029  		}
  4030  		tries++
  4031  		if tries >= 3 {
  4032  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4033  			return result, err
  4034  		}
  4035  	}
  4036  
  4037  }
  4038  
  4039  func (s *RetryLayerGroupStore) GetMemberUsersPage(groupID string, page int, perPage int) ([]*model.User, error) {
  4040  
  4041  	tries := 0
  4042  	for {
  4043  		result, err := s.GroupStore.GetMemberUsersPage(groupID, page, perPage)
  4044  		if err == nil {
  4045  			return result, nil
  4046  		}
  4047  		if !isRepeatableError(err) {
  4048  			return result, err
  4049  		}
  4050  		tries++
  4051  		if tries >= 3 {
  4052  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4053  			return result, err
  4054  		}
  4055  	}
  4056  
  4057  }
  4058  
  4059  func (s *RetryLayerGroupStore) GroupChannelCount() (int64, error) {
  4060  
  4061  	tries := 0
  4062  	for {
  4063  		result, err := s.GroupStore.GroupChannelCount()
  4064  		if err == nil {
  4065  			return result, nil
  4066  		}
  4067  		if !isRepeatableError(err) {
  4068  			return result, err
  4069  		}
  4070  		tries++
  4071  		if tries >= 3 {
  4072  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4073  			return result, err
  4074  		}
  4075  	}
  4076  
  4077  }
  4078  
  4079  func (s *RetryLayerGroupStore) GroupCount() (int64, error) {
  4080  
  4081  	tries := 0
  4082  	for {
  4083  		result, err := s.GroupStore.GroupCount()
  4084  		if err == nil {
  4085  			return result, nil
  4086  		}
  4087  		if !isRepeatableError(err) {
  4088  			return result, err
  4089  		}
  4090  		tries++
  4091  		if tries >= 3 {
  4092  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4093  			return result, err
  4094  		}
  4095  	}
  4096  
  4097  }
  4098  
  4099  func (s *RetryLayerGroupStore) GroupCountWithAllowReference() (int64, error) {
  4100  
  4101  	tries := 0
  4102  	for {
  4103  		result, err := s.GroupStore.GroupCountWithAllowReference()
  4104  		if err == nil {
  4105  			return result, nil
  4106  		}
  4107  		if !isRepeatableError(err) {
  4108  			return result, err
  4109  		}
  4110  		tries++
  4111  		if tries >= 3 {
  4112  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4113  			return result, err
  4114  		}
  4115  	}
  4116  
  4117  }
  4118  
  4119  func (s *RetryLayerGroupStore) GroupMemberCount() (int64, error) {
  4120  
  4121  	tries := 0
  4122  	for {
  4123  		result, err := s.GroupStore.GroupMemberCount()
  4124  		if err == nil {
  4125  			return result, nil
  4126  		}
  4127  		if !isRepeatableError(err) {
  4128  			return result, err
  4129  		}
  4130  		tries++
  4131  		if tries >= 3 {
  4132  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4133  			return result, err
  4134  		}
  4135  	}
  4136  
  4137  }
  4138  
  4139  func (s *RetryLayerGroupStore) GroupTeamCount() (int64, error) {
  4140  
  4141  	tries := 0
  4142  	for {
  4143  		result, err := s.GroupStore.GroupTeamCount()
  4144  		if err == nil {
  4145  			return result, nil
  4146  		}
  4147  		if !isRepeatableError(err) {
  4148  			return result, err
  4149  		}
  4150  		tries++
  4151  		if tries >= 3 {
  4152  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4153  			return result, err
  4154  		}
  4155  	}
  4156  
  4157  }
  4158  
  4159  func (s *RetryLayerGroupStore) PermanentDeleteMembersByUser(userId string) error {
  4160  
  4161  	tries := 0
  4162  	for {
  4163  		err := s.GroupStore.PermanentDeleteMembersByUser(userId)
  4164  		if err == nil {
  4165  			return nil
  4166  		}
  4167  		if !isRepeatableError(err) {
  4168  			return err
  4169  		}
  4170  		tries++
  4171  		if tries >= 3 {
  4172  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4173  			return err
  4174  		}
  4175  	}
  4176  
  4177  }
  4178  
  4179  func (s *RetryLayerGroupStore) PermittedSyncableAdmins(syncableID string, syncableType model.GroupSyncableType) ([]string, error) {
  4180  
  4181  	tries := 0
  4182  	for {
  4183  		result, err := s.GroupStore.PermittedSyncableAdmins(syncableID, syncableType)
  4184  		if err == nil {
  4185  			return result, nil
  4186  		}
  4187  		if !isRepeatableError(err) {
  4188  			return result, err
  4189  		}
  4190  		tries++
  4191  		if tries >= 3 {
  4192  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4193  			return result, err
  4194  		}
  4195  	}
  4196  
  4197  }
  4198  
  4199  func (s *RetryLayerGroupStore) TeamMembersMinusGroupMembers(teamID string, groupIDs []string, page int, perPage int) ([]*model.UserWithGroups, error) {
  4200  
  4201  	tries := 0
  4202  	for {
  4203  		result, err := s.GroupStore.TeamMembersMinusGroupMembers(teamID, groupIDs, page, perPage)
  4204  		if err == nil {
  4205  			return result, nil
  4206  		}
  4207  		if !isRepeatableError(err) {
  4208  			return result, err
  4209  		}
  4210  		tries++
  4211  		if tries >= 3 {
  4212  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4213  			return result, err
  4214  		}
  4215  	}
  4216  
  4217  }
  4218  
  4219  func (s *RetryLayerGroupStore) TeamMembersToAdd(since int64, teamID *string) ([]*model.UserTeamIDPair, error) {
  4220  
  4221  	tries := 0
  4222  	for {
  4223  		result, err := s.GroupStore.TeamMembersToAdd(since, teamID)
  4224  		if err == nil {
  4225  			return result, nil
  4226  		}
  4227  		if !isRepeatableError(err) {
  4228  			return result, err
  4229  		}
  4230  		tries++
  4231  		if tries >= 3 {
  4232  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4233  			return result, err
  4234  		}
  4235  	}
  4236  
  4237  }
  4238  
  4239  func (s *RetryLayerGroupStore) TeamMembersToRemove(teamID *string) ([]*model.TeamMember, error) {
  4240  
  4241  	tries := 0
  4242  	for {
  4243  		result, err := s.GroupStore.TeamMembersToRemove(teamID)
  4244  		if err == nil {
  4245  			return result, nil
  4246  		}
  4247  		if !isRepeatableError(err) {
  4248  			return result, err
  4249  		}
  4250  		tries++
  4251  		if tries >= 3 {
  4252  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4253  			return result, err
  4254  		}
  4255  	}
  4256  
  4257  }
  4258  
  4259  func (s *RetryLayerGroupStore) Update(group *model.Group) (*model.Group, error) {
  4260  
  4261  	tries := 0
  4262  	for {
  4263  		result, err := s.GroupStore.Update(group)
  4264  		if err == nil {
  4265  			return result, nil
  4266  		}
  4267  		if !isRepeatableError(err) {
  4268  			return result, err
  4269  		}
  4270  		tries++
  4271  		if tries >= 3 {
  4272  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4273  			return result, err
  4274  		}
  4275  	}
  4276  
  4277  }
  4278  
  4279  func (s *RetryLayerGroupStore) UpdateGroupSyncable(groupSyncable *model.GroupSyncable) (*model.GroupSyncable, error) {
  4280  
  4281  	tries := 0
  4282  	for {
  4283  		result, err := s.GroupStore.UpdateGroupSyncable(groupSyncable)
  4284  		if err == nil {
  4285  			return result, nil
  4286  		}
  4287  		if !isRepeatableError(err) {
  4288  			return result, err
  4289  		}
  4290  		tries++
  4291  		if tries >= 3 {
  4292  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4293  			return result, err
  4294  		}
  4295  	}
  4296  
  4297  }
  4298  
  4299  func (s *RetryLayerGroupStore) UpsertMember(groupID string, userID string) (*model.GroupMember, error) {
  4300  
  4301  	tries := 0
  4302  	for {
  4303  		result, err := s.GroupStore.UpsertMember(groupID, userID)
  4304  		if err == nil {
  4305  			return result, nil
  4306  		}
  4307  		if !isRepeatableError(err) {
  4308  			return result, err
  4309  		}
  4310  		tries++
  4311  		if tries >= 3 {
  4312  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4313  			return result, err
  4314  		}
  4315  	}
  4316  
  4317  }
  4318  
  4319  func (s *RetryLayerJobStore) Delete(id string) (string, error) {
  4320  
  4321  	tries := 0
  4322  	for {
  4323  		result, err := s.JobStore.Delete(id)
  4324  		if err == nil {
  4325  			return result, nil
  4326  		}
  4327  		if !isRepeatableError(err) {
  4328  			return result, err
  4329  		}
  4330  		tries++
  4331  		if tries >= 3 {
  4332  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4333  			return result, err
  4334  		}
  4335  	}
  4336  
  4337  }
  4338  
  4339  func (s *RetryLayerJobStore) Get(id string) (*model.Job, error) {
  4340  
  4341  	tries := 0
  4342  	for {
  4343  		result, err := s.JobStore.Get(id)
  4344  		if err == nil {
  4345  			return result, nil
  4346  		}
  4347  		if !isRepeatableError(err) {
  4348  			return result, err
  4349  		}
  4350  		tries++
  4351  		if tries >= 3 {
  4352  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4353  			return result, err
  4354  		}
  4355  	}
  4356  
  4357  }
  4358  
  4359  func (s *RetryLayerJobStore) GetAllByStatus(status string) ([]*model.Job, error) {
  4360  
  4361  	tries := 0
  4362  	for {
  4363  		result, err := s.JobStore.GetAllByStatus(status)
  4364  		if err == nil {
  4365  			return result, nil
  4366  		}
  4367  		if !isRepeatableError(err) {
  4368  			return result, err
  4369  		}
  4370  		tries++
  4371  		if tries >= 3 {
  4372  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4373  			return result, err
  4374  		}
  4375  	}
  4376  
  4377  }
  4378  
  4379  func (s *RetryLayerJobStore) GetAllByType(jobType string) ([]*model.Job, error) {
  4380  
  4381  	tries := 0
  4382  	for {
  4383  		result, err := s.JobStore.GetAllByType(jobType)
  4384  		if err == nil {
  4385  			return result, nil
  4386  		}
  4387  		if !isRepeatableError(err) {
  4388  			return result, err
  4389  		}
  4390  		tries++
  4391  		if tries >= 3 {
  4392  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4393  			return result, err
  4394  		}
  4395  	}
  4396  
  4397  }
  4398  
  4399  func (s *RetryLayerJobStore) GetAllByTypePage(jobType string, offset int, limit int) ([]*model.Job, error) {
  4400  
  4401  	tries := 0
  4402  	for {
  4403  		result, err := s.JobStore.GetAllByTypePage(jobType, offset, limit)
  4404  		if err == nil {
  4405  			return result, nil
  4406  		}
  4407  		if !isRepeatableError(err) {
  4408  			return result, err
  4409  		}
  4410  		tries++
  4411  		if tries >= 3 {
  4412  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4413  			return result, err
  4414  		}
  4415  	}
  4416  
  4417  }
  4418  
  4419  func (s *RetryLayerJobStore) GetAllPage(offset int, limit int) ([]*model.Job, error) {
  4420  
  4421  	tries := 0
  4422  	for {
  4423  		result, err := s.JobStore.GetAllPage(offset, limit)
  4424  		if err == nil {
  4425  			return result, nil
  4426  		}
  4427  		if !isRepeatableError(err) {
  4428  			return result, err
  4429  		}
  4430  		tries++
  4431  		if tries >= 3 {
  4432  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4433  			return result, err
  4434  		}
  4435  	}
  4436  
  4437  }
  4438  
  4439  func (s *RetryLayerJobStore) GetCountByStatusAndType(status string, jobType string) (int64, error) {
  4440  
  4441  	tries := 0
  4442  	for {
  4443  		result, err := s.JobStore.GetCountByStatusAndType(status, jobType)
  4444  		if err == nil {
  4445  			return result, nil
  4446  		}
  4447  		if !isRepeatableError(err) {
  4448  			return result, err
  4449  		}
  4450  		tries++
  4451  		if tries >= 3 {
  4452  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4453  			return result, err
  4454  		}
  4455  	}
  4456  
  4457  }
  4458  
  4459  func (s *RetryLayerJobStore) GetNewestJobByStatusAndType(status string, jobType string) (*model.Job, error) {
  4460  
  4461  	tries := 0
  4462  	for {
  4463  		result, err := s.JobStore.GetNewestJobByStatusAndType(status, jobType)
  4464  		if err == nil {
  4465  			return result, nil
  4466  		}
  4467  		if !isRepeatableError(err) {
  4468  			return result, err
  4469  		}
  4470  		tries++
  4471  		if tries >= 3 {
  4472  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4473  			return result, err
  4474  		}
  4475  	}
  4476  
  4477  }
  4478  
  4479  func (s *RetryLayerJobStore) GetNewestJobByStatusesAndType(statuses []string, jobType string) (*model.Job, error) {
  4480  
  4481  	tries := 0
  4482  	for {
  4483  		result, err := s.JobStore.GetNewestJobByStatusesAndType(statuses, jobType)
  4484  		if err == nil {
  4485  			return result, nil
  4486  		}
  4487  		if !isRepeatableError(err) {
  4488  			return result, err
  4489  		}
  4490  		tries++
  4491  		if tries >= 3 {
  4492  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4493  			return result, err
  4494  		}
  4495  	}
  4496  
  4497  }
  4498  
  4499  func (s *RetryLayerJobStore) Save(job *model.Job) (*model.Job, error) {
  4500  
  4501  	tries := 0
  4502  	for {
  4503  		result, err := s.JobStore.Save(job)
  4504  		if err == nil {
  4505  			return result, nil
  4506  		}
  4507  		if !isRepeatableError(err) {
  4508  			return result, err
  4509  		}
  4510  		tries++
  4511  		if tries >= 3 {
  4512  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4513  			return result, err
  4514  		}
  4515  	}
  4516  
  4517  }
  4518  
  4519  func (s *RetryLayerJobStore) UpdateOptimistically(job *model.Job, currentStatus string) (bool, error) {
  4520  
  4521  	tries := 0
  4522  	for {
  4523  		result, err := s.JobStore.UpdateOptimistically(job, currentStatus)
  4524  		if err == nil {
  4525  			return result, nil
  4526  		}
  4527  		if !isRepeatableError(err) {
  4528  			return result, err
  4529  		}
  4530  		tries++
  4531  		if tries >= 3 {
  4532  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4533  			return result, err
  4534  		}
  4535  	}
  4536  
  4537  }
  4538  
  4539  func (s *RetryLayerJobStore) UpdateStatus(id string, status string) (*model.Job, error) {
  4540  
  4541  	tries := 0
  4542  	for {
  4543  		result, err := s.JobStore.UpdateStatus(id, status)
  4544  		if err == nil {
  4545  			return result, nil
  4546  		}
  4547  		if !isRepeatableError(err) {
  4548  			return result, err
  4549  		}
  4550  		tries++
  4551  		if tries >= 3 {
  4552  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4553  			return result, err
  4554  		}
  4555  	}
  4556  
  4557  }
  4558  
  4559  func (s *RetryLayerJobStore) UpdateStatusOptimistically(id string, currentStatus string, newStatus string) (bool, error) {
  4560  
  4561  	tries := 0
  4562  	for {
  4563  		result, err := s.JobStore.UpdateStatusOptimistically(id, currentStatus, newStatus)
  4564  		if err == nil {
  4565  			return result, nil
  4566  		}
  4567  		if !isRepeatableError(err) {
  4568  			return result, err
  4569  		}
  4570  		tries++
  4571  		if tries >= 3 {
  4572  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4573  			return result, err
  4574  		}
  4575  	}
  4576  
  4577  }
  4578  
  4579  func (s *RetryLayerLicenseStore) Get(id string) (*model.LicenseRecord, error) {
  4580  
  4581  	tries := 0
  4582  	for {
  4583  		result, err := s.LicenseStore.Get(id)
  4584  		if err == nil {
  4585  			return result, nil
  4586  		}
  4587  		if !isRepeatableError(err) {
  4588  			return result, err
  4589  		}
  4590  		tries++
  4591  		if tries >= 3 {
  4592  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4593  			return result, err
  4594  		}
  4595  	}
  4596  
  4597  }
  4598  
  4599  func (s *RetryLayerLicenseStore) Save(license *model.LicenseRecord) (*model.LicenseRecord, error) {
  4600  
  4601  	tries := 0
  4602  	for {
  4603  		result, err := s.LicenseStore.Save(license)
  4604  		if err == nil {
  4605  			return result, nil
  4606  		}
  4607  		if !isRepeatableError(err) {
  4608  			return result, err
  4609  		}
  4610  		tries++
  4611  		if tries >= 3 {
  4612  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4613  			return result, err
  4614  		}
  4615  	}
  4616  
  4617  }
  4618  
  4619  func (s *RetryLayerLinkMetadataStore) Get(url string, timestamp int64) (*model.LinkMetadata, error) {
  4620  
  4621  	tries := 0
  4622  	for {
  4623  		result, err := s.LinkMetadataStore.Get(url, timestamp)
  4624  		if err == nil {
  4625  			return result, nil
  4626  		}
  4627  		if !isRepeatableError(err) {
  4628  			return result, err
  4629  		}
  4630  		tries++
  4631  		if tries >= 3 {
  4632  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4633  			return result, err
  4634  		}
  4635  	}
  4636  
  4637  }
  4638  
  4639  func (s *RetryLayerLinkMetadataStore) Save(linkMetadata *model.LinkMetadata) (*model.LinkMetadata, error) {
  4640  
  4641  	tries := 0
  4642  	for {
  4643  		result, err := s.LinkMetadataStore.Save(linkMetadata)
  4644  		if err == nil {
  4645  			return result, nil
  4646  		}
  4647  		if !isRepeatableError(err) {
  4648  			return result, err
  4649  		}
  4650  		tries++
  4651  		if tries >= 3 {
  4652  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4653  			return result, err
  4654  		}
  4655  	}
  4656  
  4657  }
  4658  
  4659  func (s *RetryLayerOAuthStore) DeleteApp(id string) error {
  4660  
  4661  	tries := 0
  4662  	for {
  4663  		err := s.OAuthStore.DeleteApp(id)
  4664  		if err == nil {
  4665  			return nil
  4666  		}
  4667  		if !isRepeatableError(err) {
  4668  			return err
  4669  		}
  4670  		tries++
  4671  		if tries >= 3 {
  4672  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4673  			return err
  4674  		}
  4675  	}
  4676  
  4677  }
  4678  
  4679  func (s *RetryLayerOAuthStore) GetAccessData(token string) (*model.AccessData, error) {
  4680  
  4681  	tries := 0
  4682  	for {
  4683  		result, err := s.OAuthStore.GetAccessData(token)
  4684  		if err == nil {
  4685  			return result, nil
  4686  		}
  4687  		if !isRepeatableError(err) {
  4688  			return result, err
  4689  		}
  4690  		tries++
  4691  		if tries >= 3 {
  4692  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4693  			return result, err
  4694  		}
  4695  	}
  4696  
  4697  }
  4698  
  4699  func (s *RetryLayerOAuthStore) GetAccessDataByRefreshToken(token string) (*model.AccessData, error) {
  4700  
  4701  	tries := 0
  4702  	for {
  4703  		result, err := s.OAuthStore.GetAccessDataByRefreshToken(token)
  4704  		if err == nil {
  4705  			return result, nil
  4706  		}
  4707  		if !isRepeatableError(err) {
  4708  			return result, err
  4709  		}
  4710  		tries++
  4711  		if tries >= 3 {
  4712  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4713  			return result, err
  4714  		}
  4715  	}
  4716  
  4717  }
  4718  
  4719  func (s *RetryLayerOAuthStore) GetAccessDataByUserForApp(userId string, clientId string) ([]*model.AccessData, error) {
  4720  
  4721  	tries := 0
  4722  	for {
  4723  		result, err := s.OAuthStore.GetAccessDataByUserForApp(userId, clientId)
  4724  		if err == nil {
  4725  			return result, nil
  4726  		}
  4727  		if !isRepeatableError(err) {
  4728  			return result, err
  4729  		}
  4730  		tries++
  4731  		if tries >= 3 {
  4732  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4733  			return result, err
  4734  		}
  4735  	}
  4736  
  4737  }
  4738  
  4739  func (s *RetryLayerOAuthStore) GetApp(id string) (*model.OAuthApp, error) {
  4740  
  4741  	tries := 0
  4742  	for {
  4743  		result, err := s.OAuthStore.GetApp(id)
  4744  		if err == nil {
  4745  			return result, nil
  4746  		}
  4747  		if !isRepeatableError(err) {
  4748  			return result, err
  4749  		}
  4750  		tries++
  4751  		if tries >= 3 {
  4752  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4753  			return result, err
  4754  		}
  4755  	}
  4756  
  4757  }
  4758  
  4759  func (s *RetryLayerOAuthStore) GetAppByUser(userId string, offset int, limit int) ([]*model.OAuthApp, error) {
  4760  
  4761  	tries := 0
  4762  	for {
  4763  		result, err := s.OAuthStore.GetAppByUser(userId, offset, limit)
  4764  		if err == nil {
  4765  			return result, nil
  4766  		}
  4767  		if !isRepeatableError(err) {
  4768  			return result, err
  4769  		}
  4770  		tries++
  4771  		if tries >= 3 {
  4772  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4773  			return result, err
  4774  		}
  4775  	}
  4776  
  4777  }
  4778  
  4779  func (s *RetryLayerOAuthStore) GetApps(offset int, limit int) ([]*model.OAuthApp, error) {
  4780  
  4781  	tries := 0
  4782  	for {
  4783  		result, err := s.OAuthStore.GetApps(offset, limit)
  4784  		if err == nil {
  4785  			return result, nil
  4786  		}
  4787  		if !isRepeatableError(err) {
  4788  			return result, err
  4789  		}
  4790  		tries++
  4791  		if tries >= 3 {
  4792  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4793  			return result, err
  4794  		}
  4795  	}
  4796  
  4797  }
  4798  
  4799  func (s *RetryLayerOAuthStore) GetAuthData(code string) (*model.AuthData, error) {
  4800  
  4801  	tries := 0
  4802  	for {
  4803  		result, err := s.OAuthStore.GetAuthData(code)
  4804  		if err == nil {
  4805  			return result, nil
  4806  		}
  4807  		if !isRepeatableError(err) {
  4808  			return result, err
  4809  		}
  4810  		tries++
  4811  		if tries >= 3 {
  4812  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4813  			return result, err
  4814  		}
  4815  	}
  4816  
  4817  }
  4818  
  4819  func (s *RetryLayerOAuthStore) GetAuthorizedApps(userId string, offset int, limit int) ([]*model.OAuthApp, error) {
  4820  
  4821  	tries := 0
  4822  	for {
  4823  		result, err := s.OAuthStore.GetAuthorizedApps(userId, offset, limit)
  4824  		if err == nil {
  4825  			return result, nil
  4826  		}
  4827  		if !isRepeatableError(err) {
  4828  			return result, err
  4829  		}
  4830  		tries++
  4831  		if tries >= 3 {
  4832  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4833  			return result, err
  4834  		}
  4835  	}
  4836  
  4837  }
  4838  
  4839  func (s *RetryLayerOAuthStore) GetPreviousAccessData(userId string, clientId string) (*model.AccessData, error) {
  4840  
  4841  	tries := 0
  4842  	for {
  4843  		result, err := s.OAuthStore.GetPreviousAccessData(userId, clientId)
  4844  		if err == nil {
  4845  			return result, nil
  4846  		}
  4847  		if !isRepeatableError(err) {
  4848  			return result, err
  4849  		}
  4850  		tries++
  4851  		if tries >= 3 {
  4852  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4853  			return result, err
  4854  		}
  4855  	}
  4856  
  4857  }
  4858  
  4859  func (s *RetryLayerOAuthStore) PermanentDeleteAuthDataByUser(userId string) error {
  4860  
  4861  	tries := 0
  4862  	for {
  4863  		err := s.OAuthStore.PermanentDeleteAuthDataByUser(userId)
  4864  		if err == nil {
  4865  			return nil
  4866  		}
  4867  		if !isRepeatableError(err) {
  4868  			return err
  4869  		}
  4870  		tries++
  4871  		if tries >= 3 {
  4872  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4873  			return err
  4874  		}
  4875  	}
  4876  
  4877  }
  4878  
  4879  func (s *RetryLayerOAuthStore) RemoveAccessData(token string) error {
  4880  
  4881  	tries := 0
  4882  	for {
  4883  		err := s.OAuthStore.RemoveAccessData(token)
  4884  		if err == nil {
  4885  			return nil
  4886  		}
  4887  		if !isRepeatableError(err) {
  4888  			return err
  4889  		}
  4890  		tries++
  4891  		if tries >= 3 {
  4892  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4893  			return err
  4894  		}
  4895  	}
  4896  
  4897  }
  4898  
  4899  func (s *RetryLayerOAuthStore) RemoveAllAccessData() error {
  4900  
  4901  	tries := 0
  4902  	for {
  4903  		err := s.OAuthStore.RemoveAllAccessData()
  4904  		if err == nil {
  4905  			return nil
  4906  		}
  4907  		if !isRepeatableError(err) {
  4908  			return err
  4909  		}
  4910  		tries++
  4911  		if tries >= 3 {
  4912  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4913  			return err
  4914  		}
  4915  	}
  4916  
  4917  }
  4918  
  4919  func (s *RetryLayerOAuthStore) RemoveAuthData(code string) error {
  4920  
  4921  	tries := 0
  4922  	for {
  4923  		err := s.OAuthStore.RemoveAuthData(code)
  4924  		if err == nil {
  4925  			return nil
  4926  		}
  4927  		if !isRepeatableError(err) {
  4928  			return err
  4929  		}
  4930  		tries++
  4931  		if tries >= 3 {
  4932  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4933  			return err
  4934  		}
  4935  	}
  4936  
  4937  }
  4938  
  4939  func (s *RetryLayerOAuthStore) SaveAccessData(accessData *model.AccessData) (*model.AccessData, error) {
  4940  
  4941  	tries := 0
  4942  	for {
  4943  		result, err := s.OAuthStore.SaveAccessData(accessData)
  4944  		if err == nil {
  4945  			return result, nil
  4946  		}
  4947  		if !isRepeatableError(err) {
  4948  			return result, err
  4949  		}
  4950  		tries++
  4951  		if tries >= 3 {
  4952  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4953  			return result, err
  4954  		}
  4955  	}
  4956  
  4957  }
  4958  
  4959  func (s *RetryLayerOAuthStore) SaveApp(app *model.OAuthApp) (*model.OAuthApp, error) {
  4960  
  4961  	tries := 0
  4962  	for {
  4963  		result, err := s.OAuthStore.SaveApp(app)
  4964  		if err == nil {
  4965  			return result, nil
  4966  		}
  4967  		if !isRepeatableError(err) {
  4968  			return result, err
  4969  		}
  4970  		tries++
  4971  		if tries >= 3 {
  4972  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4973  			return result, err
  4974  		}
  4975  	}
  4976  
  4977  }
  4978  
  4979  func (s *RetryLayerOAuthStore) SaveAuthData(authData *model.AuthData) (*model.AuthData, error) {
  4980  
  4981  	tries := 0
  4982  	for {
  4983  		result, err := s.OAuthStore.SaveAuthData(authData)
  4984  		if err == nil {
  4985  			return result, nil
  4986  		}
  4987  		if !isRepeatableError(err) {
  4988  			return result, err
  4989  		}
  4990  		tries++
  4991  		if tries >= 3 {
  4992  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  4993  			return result, err
  4994  		}
  4995  	}
  4996  
  4997  }
  4998  
  4999  func (s *RetryLayerOAuthStore) UpdateAccessData(accessData *model.AccessData) (*model.AccessData, error) {
  5000  
  5001  	tries := 0
  5002  	for {
  5003  		result, err := s.OAuthStore.UpdateAccessData(accessData)
  5004  		if err == nil {
  5005  			return result, nil
  5006  		}
  5007  		if !isRepeatableError(err) {
  5008  			return result, err
  5009  		}
  5010  		tries++
  5011  		if tries >= 3 {
  5012  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5013  			return result, err
  5014  		}
  5015  	}
  5016  
  5017  }
  5018  
  5019  func (s *RetryLayerOAuthStore) UpdateApp(app *model.OAuthApp) (*model.OAuthApp, error) {
  5020  
  5021  	tries := 0
  5022  	for {
  5023  		result, err := s.OAuthStore.UpdateApp(app)
  5024  		if err == nil {
  5025  			return result, nil
  5026  		}
  5027  		if !isRepeatableError(err) {
  5028  			return result, err
  5029  		}
  5030  		tries++
  5031  		if tries >= 3 {
  5032  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5033  			return result, err
  5034  		}
  5035  	}
  5036  
  5037  }
  5038  
  5039  func (s *RetryLayerPluginStore) CompareAndDelete(keyVal *model.PluginKeyValue, oldValue []byte) (bool, error) {
  5040  
  5041  	tries := 0
  5042  	for {
  5043  		result, err := s.PluginStore.CompareAndDelete(keyVal, oldValue)
  5044  		if err == nil {
  5045  			return result, nil
  5046  		}
  5047  		if !isRepeatableError(err) {
  5048  			return result, err
  5049  		}
  5050  		tries++
  5051  		if tries >= 3 {
  5052  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5053  			return result, err
  5054  		}
  5055  	}
  5056  
  5057  }
  5058  
  5059  func (s *RetryLayerPluginStore) CompareAndSet(keyVal *model.PluginKeyValue, oldValue []byte) (bool, error) {
  5060  
  5061  	tries := 0
  5062  	for {
  5063  		result, err := s.PluginStore.CompareAndSet(keyVal, oldValue)
  5064  		if err == nil {
  5065  			return result, nil
  5066  		}
  5067  		if !isRepeatableError(err) {
  5068  			return result, err
  5069  		}
  5070  		tries++
  5071  		if tries >= 3 {
  5072  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5073  			return result, err
  5074  		}
  5075  	}
  5076  
  5077  }
  5078  
  5079  func (s *RetryLayerPluginStore) Delete(pluginId string, key string) error {
  5080  
  5081  	tries := 0
  5082  	for {
  5083  		err := s.PluginStore.Delete(pluginId, key)
  5084  		if err == nil {
  5085  			return nil
  5086  		}
  5087  		if !isRepeatableError(err) {
  5088  			return err
  5089  		}
  5090  		tries++
  5091  		if tries >= 3 {
  5092  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5093  			return err
  5094  		}
  5095  	}
  5096  
  5097  }
  5098  
  5099  func (s *RetryLayerPluginStore) DeleteAllExpired() error {
  5100  
  5101  	tries := 0
  5102  	for {
  5103  		err := s.PluginStore.DeleteAllExpired()
  5104  		if err == nil {
  5105  			return nil
  5106  		}
  5107  		if !isRepeatableError(err) {
  5108  			return err
  5109  		}
  5110  		tries++
  5111  		if tries >= 3 {
  5112  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5113  			return err
  5114  		}
  5115  	}
  5116  
  5117  }
  5118  
  5119  func (s *RetryLayerPluginStore) DeleteAllForPlugin(PluginId string) error {
  5120  
  5121  	tries := 0
  5122  	for {
  5123  		err := s.PluginStore.DeleteAllForPlugin(PluginId)
  5124  		if err == nil {
  5125  			return nil
  5126  		}
  5127  		if !isRepeatableError(err) {
  5128  			return err
  5129  		}
  5130  		tries++
  5131  		if tries >= 3 {
  5132  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5133  			return err
  5134  		}
  5135  	}
  5136  
  5137  }
  5138  
  5139  func (s *RetryLayerPluginStore) Get(pluginId string, key string) (*model.PluginKeyValue, error) {
  5140  
  5141  	tries := 0
  5142  	for {
  5143  		result, err := s.PluginStore.Get(pluginId, key)
  5144  		if err == nil {
  5145  			return result, nil
  5146  		}
  5147  		if !isRepeatableError(err) {
  5148  			return result, err
  5149  		}
  5150  		tries++
  5151  		if tries >= 3 {
  5152  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5153  			return result, err
  5154  		}
  5155  	}
  5156  
  5157  }
  5158  
  5159  func (s *RetryLayerPluginStore) List(pluginId string, page int, perPage int) ([]string, error) {
  5160  
  5161  	tries := 0
  5162  	for {
  5163  		result, err := s.PluginStore.List(pluginId, page, perPage)
  5164  		if err == nil {
  5165  			return result, nil
  5166  		}
  5167  		if !isRepeatableError(err) {
  5168  			return result, err
  5169  		}
  5170  		tries++
  5171  		if tries >= 3 {
  5172  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5173  			return result, err
  5174  		}
  5175  	}
  5176  
  5177  }
  5178  
  5179  func (s *RetryLayerPluginStore) SaveOrUpdate(keyVal *model.PluginKeyValue) (*model.PluginKeyValue, error) {
  5180  
  5181  	tries := 0
  5182  	for {
  5183  		result, err := s.PluginStore.SaveOrUpdate(keyVal)
  5184  		if err == nil {
  5185  			return result, nil
  5186  		}
  5187  		if !isRepeatableError(err) {
  5188  			return result, err
  5189  		}
  5190  		tries++
  5191  		if tries >= 3 {
  5192  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5193  			return result, err
  5194  		}
  5195  	}
  5196  
  5197  }
  5198  
  5199  func (s *RetryLayerPluginStore) SetWithOptions(pluginId string, key string, value []byte, options model.PluginKVSetOptions) (bool, error) {
  5200  
  5201  	tries := 0
  5202  	for {
  5203  		result, err := s.PluginStore.SetWithOptions(pluginId, key, value, options)
  5204  		if err == nil {
  5205  			return result, nil
  5206  		}
  5207  		if !isRepeatableError(err) {
  5208  			return result, err
  5209  		}
  5210  		tries++
  5211  		if tries >= 3 {
  5212  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5213  			return result, err
  5214  		}
  5215  	}
  5216  
  5217  }
  5218  
  5219  func (s *RetryLayerPostStore) AnalyticsPostCount(teamId string, mustHaveFile bool, mustHaveHashtag bool) (int64, error) {
  5220  
  5221  	tries := 0
  5222  	for {
  5223  		result, err := s.PostStore.AnalyticsPostCount(teamId, mustHaveFile, mustHaveHashtag)
  5224  		if err == nil {
  5225  			return result, nil
  5226  		}
  5227  		if !isRepeatableError(err) {
  5228  			return result, err
  5229  		}
  5230  		tries++
  5231  		if tries >= 3 {
  5232  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5233  			return result, err
  5234  		}
  5235  	}
  5236  
  5237  }
  5238  
  5239  func (s *RetryLayerPostStore) AnalyticsPostCountsByDay(options *model.AnalyticsPostCountsOptions) (model.AnalyticsRows, error) {
  5240  
  5241  	tries := 0
  5242  	for {
  5243  		result, err := s.PostStore.AnalyticsPostCountsByDay(options)
  5244  		if err == nil {
  5245  			return result, nil
  5246  		}
  5247  		if !isRepeatableError(err) {
  5248  			return result, err
  5249  		}
  5250  		tries++
  5251  		if tries >= 3 {
  5252  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5253  			return result, err
  5254  		}
  5255  	}
  5256  
  5257  }
  5258  
  5259  func (s *RetryLayerPostStore) AnalyticsUserCountsWithPostsByDay(teamId string) (model.AnalyticsRows, error) {
  5260  
  5261  	tries := 0
  5262  	for {
  5263  		result, err := s.PostStore.AnalyticsUserCountsWithPostsByDay(teamId)
  5264  		if err == nil {
  5265  			return result, nil
  5266  		}
  5267  		if !isRepeatableError(err) {
  5268  			return result, err
  5269  		}
  5270  		tries++
  5271  		if tries >= 3 {
  5272  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5273  			return result, err
  5274  		}
  5275  	}
  5276  
  5277  }
  5278  
  5279  func (s *RetryLayerPostStore) ClearCaches() {
  5280  
  5281  	s.PostStore.ClearCaches()
  5282  
  5283  }
  5284  
  5285  func (s *RetryLayerPostStore) Delete(postId string, time int64, deleteByID string) error {
  5286  
  5287  	tries := 0
  5288  	for {
  5289  		err := s.PostStore.Delete(postId, time, deleteByID)
  5290  		if err == nil {
  5291  			return nil
  5292  		}
  5293  		if !isRepeatableError(err) {
  5294  			return err
  5295  		}
  5296  		tries++
  5297  		if tries >= 3 {
  5298  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5299  			return err
  5300  		}
  5301  	}
  5302  
  5303  }
  5304  
  5305  func (s *RetryLayerPostStore) Get(id string, skipFetchThreads bool, collapsedThreads bool, collapsedThreadsExtended bool) (*model.PostList, error) {
  5306  
  5307  	tries := 0
  5308  	for {
  5309  		result, err := s.PostStore.Get(id, skipFetchThreads, collapsedThreads, collapsedThreadsExtended)
  5310  		if err == nil {
  5311  			return result, nil
  5312  		}
  5313  		if !isRepeatableError(err) {
  5314  			return result, err
  5315  		}
  5316  		tries++
  5317  		if tries >= 3 {
  5318  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5319  			return result, err
  5320  		}
  5321  	}
  5322  
  5323  }
  5324  
  5325  func (s *RetryLayerPostStore) GetDirectPostParentsForExportAfter(limit int, afterId string) ([]*model.DirectPostForExport, error) {
  5326  
  5327  	tries := 0
  5328  	for {
  5329  		result, err := s.PostStore.GetDirectPostParentsForExportAfter(limit, afterId)
  5330  		if err == nil {
  5331  			return result, nil
  5332  		}
  5333  		if !isRepeatableError(err) {
  5334  			return result, err
  5335  		}
  5336  		tries++
  5337  		if tries >= 3 {
  5338  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5339  			return result, err
  5340  		}
  5341  	}
  5342  
  5343  }
  5344  
  5345  func (s *RetryLayerPostStore) GetEtag(channelId string, allowFromCache bool, collapsedThreads bool) string {
  5346  
  5347  	return s.PostStore.GetEtag(channelId, allowFromCache, collapsedThreads)
  5348  
  5349  }
  5350  
  5351  func (s *RetryLayerPostStore) GetFlaggedPosts(userId string, offset int, limit int) (*model.PostList, error) {
  5352  
  5353  	tries := 0
  5354  	for {
  5355  		result, err := s.PostStore.GetFlaggedPosts(userId, offset, limit)
  5356  		if err == nil {
  5357  			return result, nil
  5358  		}
  5359  		if !isRepeatableError(err) {
  5360  			return result, err
  5361  		}
  5362  		tries++
  5363  		if tries >= 3 {
  5364  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5365  			return result, err
  5366  		}
  5367  	}
  5368  
  5369  }
  5370  
  5371  func (s *RetryLayerPostStore) GetFlaggedPostsForChannel(userId string, channelId string, offset int, limit int) (*model.PostList, error) {
  5372  
  5373  	tries := 0
  5374  	for {
  5375  		result, err := s.PostStore.GetFlaggedPostsForChannel(userId, channelId, offset, limit)
  5376  		if err == nil {
  5377  			return result, nil
  5378  		}
  5379  		if !isRepeatableError(err) {
  5380  			return result, err
  5381  		}
  5382  		tries++
  5383  		if tries >= 3 {
  5384  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5385  			return result, err
  5386  		}
  5387  	}
  5388  
  5389  }
  5390  
  5391  func (s *RetryLayerPostStore) GetFlaggedPostsForTeam(userId string, teamId string, offset int, limit int) (*model.PostList, error) {
  5392  
  5393  	tries := 0
  5394  	for {
  5395  		result, err := s.PostStore.GetFlaggedPostsForTeam(userId, teamId, offset, limit)
  5396  		if err == nil {
  5397  			return result, nil
  5398  		}
  5399  		if !isRepeatableError(err) {
  5400  			return result, err
  5401  		}
  5402  		tries++
  5403  		if tries >= 3 {
  5404  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5405  			return result, err
  5406  		}
  5407  	}
  5408  
  5409  }
  5410  
  5411  func (s *RetryLayerPostStore) GetMaxPostSize() int {
  5412  
  5413  	return s.PostStore.GetMaxPostSize()
  5414  
  5415  }
  5416  
  5417  func (s *RetryLayerPostStore) GetOldest() (*model.Post, error) {
  5418  
  5419  	tries := 0
  5420  	for {
  5421  		result, err := s.PostStore.GetOldest()
  5422  		if err == nil {
  5423  			return result, nil
  5424  		}
  5425  		if !isRepeatableError(err) {
  5426  			return result, err
  5427  		}
  5428  		tries++
  5429  		if tries >= 3 {
  5430  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5431  			return result, err
  5432  		}
  5433  	}
  5434  
  5435  }
  5436  
  5437  func (s *RetryLayerPostStore) GetOldestEntityCreationTime() (int64, error) {
  5438  
  5439  	tries := 0
  5440  	for {
  5441  		result, err := s.PostStore.GetOldestEntityCreationTime()
  5442  		if err == nil {
  5443  			return result, nil
  5444  		}
  5445  		if !isRepeatableError(err) {
  5446  			return result, err
  5447  		}
  5448  		tries++
  5449  		if tries >= 3 {
  5450  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5451  			return result, err
  5452  		}
  5453  	}
  5454  
  5455  }
  5456  
  5457  func (s *RetryLayerPostStore) GetParentsForExportAfter(limit int, afterId string) ([]*model.PostForExport, error) {
  5458  
  5459  	tries := 0
  5460  	for {
  5461  		result, err := s.PostStore.GetParentsForExportAfter(limit, afterId)
  5462  		if err == nil {
  5463  			return result, nil
  5464  		}
  5465  		if !isRepeatableError(err) {
  5466  			return result, err
  5467  		}
  5468  		tries++
  5469  		if tries >= 3 {
  5470  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5471  			return result, err
  5472  		}
  5473  	}
  5474  
  5475  }
  5476  
  5477  func (s *RetryLayerPostStore) GetPostAfterTime(channelId string, time int64) (*model.Post, error) {
  5478  
  5479  	tries := 0
  5480  	for {
  5481  		result, err := s.PostStore.GetPostAfterTime(channelId, time)
  5482  		if err == nil {
  5483  			return result, nil
  5484  		}
  5485  		if !isRepeatableError(err) {
  5486  			return result, err
  5487  		}
  5488  		tries++
  5489  		if tries >= 3 {
  5490  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5491  			return result, err
  5492  		}
  5493  	}
  5494  
  5495  }
  5496  
  5497  func (s *RetryLayerPostStore) GetPostIdAfterTime(channelId string, time int64) (string, error) {
  5498  
  5499  	tries := 0
  5500  	for {
  5501  		result, err := s.PostStore.GetPostIdAfterTime(channelId, time)
  5502  		if err == nil {
  5503  			return result, nil
  5504  		}
  5505  		if !isRepeatableError(err) {
  5506  			return result, err
  5507  		}
  5508  		tries++
  5509  		if tries >= 3 {
  5510  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5511  			return result, err
  5512  		}
  5513  	}
  5514  
  5515  }
  5516  
  5517  func (s *RetryLayerPostStore) GetPostIdBeforeTime(channelId string, time int64) (string, error) {
  5518  
  5519  	tries := 0
  5520  	for {
  5521  		result, err := s.PostStore.GetPostIdBeforeTime(channelId, time)
  5522  		if err == nil {
  5523  			return result, nil
  5524  		}
  5525  		if !isRepeatableError(err) {
  5526  			return result, err
  5527  		}
  5528  		tries++
  5529  		if tries >= 3 {
  5530  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5531  			return result, err
  5532  		}
  5533  	}
  5534  
  5535  }
  5536  
  5537  func (s *RetryLayerPostStore) GetPosts(options model.GetPostsOptions, allowFromCache bool) (*model.PostList, error) {
  5538  
  5539  	tries := 0
  5540  	for {
  5541  		result, err := s.PostStore.GetPosts(options, allowFromCache)
  5542  		if err == nil {
  5543  			return result, nil
  5544  		}
  5545  		if !isRepeatableError(err) {
  5546  			return result, err
  5547  		}
  5548  		tries++
  5549  		if tries >= 3 {
  5550  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5551  			return result, err
  5552  		}
  5553  	}
  5554  
  5555  }
  5556  
  5557  func (s *RetryLayerPostStore) GetPostsAfter(options model.GetPostsOptions) (*model.PostList, error) {
  5558  
  5559  	tries := 0
  5560  	for {
  5561  		result, err := s.PostStore.GetPostsAfter(options)
  5562  		if err == nil {
  5563  			return result, nil
  5564  		}
  5565  		if !isRepeatableError(err) {
  5566  			return result, err
  5567  		}
  5568  		tries++
  5569  		if tries >= 3 {
  5570  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5571  			return result, err
  5572  		}
  5573  	}
  5574  
  5575  }
  5576  
  5577  func (s *RetryLayerPostStore) GetPostsBatchForIndexing(startTime int64, endTime int64, limit int) ([]*model.PostForIndexing, error) {
  5578  
  5579  	tries := 0
  5580  	for {
  5581  		result, err := s.PostStore.GetPostsBatchForIndexing(startTime, endTime, limit)
  5582  		if err == nil {
  5583  			return result, nil
  5584  		}
  5585  		if !isRepeatableError(err) {
  5586  			return result, err
  5587  		}
  5588  		tries++
  5589  		if tries >= 3 {
  5590  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5591  			return result, err
  5592  		}
  5593  	}
  5594  
  5595  }
  5596  
  5597  func (s *RetryLayerPostStore) GetPostsBefore(options model.GetPostsOptions) (*model.PostList, error) {
  5598  
  5599  	tries := 0
  5600  	for {
  5601  		result, err := s.PostStore.GetPostsBefore(options)
  5602  		if err == nil {
  5603  			return result, nil
  5604  		}
  5605  		if !isRepeatableError(err) {
  5606  			return result, err
  5607  		}
  5608  		tries++
  5609  		if tries >= 3 {
  5610  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5611  			return result, err
  5612  		}
  5613  	}
  5614  
  5615  }
  5616  
  5617  func (s *RetryLayerPostStore) GetPostsByIds(postIds []string) ([]*model.Post, error) {
  5618  
  5619  	tries := 0
  5620  	for {
  5621  		result, err := s.PostStore.GetPostsByIds(postIds)
  5622  		if err == nil {
  5623  			return result, nil
  5624  		}
  5625  		if !isRepeatableError(err) {
  5626  			return result, err
  5627  		}
  5628  		tries++
  5629  		if tries >= 3 {
  5630  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5631  			return result, err
  5632  		}
  5633  	}
  5634  
  5635  }
  5636  
  5637  func (s *RetryLayerPostStore) GetPostsCreatedAt(channelId string, time int64) ([]*model.Post, error) {
  5638  
  5639  	tries := 0
  5640  	for {
  5641  		result, err := s.PostStore.GetPostsCreatedAt(channelId, time)
  5642  		if err == nil {
  5643  			return result, nil
  5644  		}
  5645  		if !isRepeatableError(err) {
  5646  			return result, err
  5647  		}
  5648  		tries++
  5649  		if tries >= 3 {
  5650  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5651  			return result, err
  5652  		}
  5653  	}
  5654  
  5655  }
  5656  
  5657  func (s *RetryLayerPostStore) GetPostsSince(options model.GetPostsSinceOptions, allowFromCache bool) (*model.PostList, error) {
  5658  
  5659  	tries := 0
  5660  	for {
  5661  		result, err := s.PostStore.GetPostsSince(options, allowFromCache)
  5662  		if err == nil {
  5663  			return result, nil
  5664  		}
  5665  		if !isRepeatableError(err) {
  5666  			return result, err
  5667  		}
  5668  		tries++
  5669  		if tries >= 3 {
  5670  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5671  			return result, err
  5672  		}
  5673  	}
  5674  
  5675  }
  5676  
  5677  func (s *RetryLayerPostStore) GetRepliesForExport(parentId string) ([]*model.ReplyForExport, error) {
  5678  
  5679  	tries := 0
  5680  	for {
  5681  		result, err := s.PostStore.GetRepliesForExport(parentId)
  5682  		if err == nil {
  5683  			return result, nil
  5684  		}
  5685  		if !isRepeatableError(err) {
  5686  			return result, err
  5687  		}
  5688  		tries++
  5689  		if tries >= 3 {
  5690  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5691  			return result, err
  5692  		}
  5693  	}
  5694  
  5695  }
  5696  
  5697  func (s *RetryLayerPostStore) GetSingle(id string) (*model.Post, error) {
  5698  
  5699  	tries := 0
  5700  	for {
  5701  		result, err := s.PostStore.GetSingle(id)
  5702  		if err == nil {
  5703  			return result, nil
  5704  		}
  5705  		if !isRepeatableError(err) {
  5706  			return result, err
  5707  		}
  5708  		tries++
  5709  		if tries >= 3 {
  5710  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5711  			return result, err
  5712  		}
  5713  	}
  5714  
  5715  }
  5716  
  5717  func (s *RetryLayerPostStore) InvalidateLastPostTimeCache(channelId string) {
  5718  
  5719  	s.PostStore.InvalidateLastPostTimeCache(channelId)
  5720  
  5721  }
  5722  
  5723  func (s *RetryLayerPostStore) Overwrite(post *model.Post) (*model.Post, error) {
  5724  
  5725  	tries := 0
  5726  	for {
  5727  		result, err := s.PostStore.Overwrite(post)
  5728  		if err == nil {
  5729  			return result, nil
  5730  		}
  5731  		if !isRepeatableError(err) {
  5732  			return result, err
  5733  		}
  5734  		tries++
  5735  		if tries >= 3 {
  5736  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5737  			return result, err
  5738  		}
  5739  	}
  5740  
  5741  }
  5742  
  5743  func (s *RetryLayerPostStore) OverwriteMultiple(posts []*model.Post) ([]*model.Post, int, error) {
  5744  
  5745  	tries := 0
  5746  	for {
  5747  		result, resultVar1, err := s.PostStore.OverwriteMultiple(posts)
  5748  		if err == nil {
  5749  			return result, resultVar1, nil
  5750  		}
  5751  		if !isRepeatableError(err) {
  5752  			return result, resultVar1, err
  5753  		}
  5754  		tries++
  5755  		if tries >= 3 {
  5756  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5757  			return result, resultVar1, err
  5758  		}
  5759  	}
  5760  
  5761  }
  5762  
  5763  func (s *RetryLayerPostStore) PermanentDeleteBatch(endTime int64, limit int64) (int64, error) {
  5764  
  5765  	tries := 0
  5766  	for {
  5767  		result, err := s.PostStore.PermanentDeleteBatch(endTime, limit)
  5768  		if err == nil {
  5769  			return result, nil
  5770  		}
  5771  		if !isRepeatableError(err) {
  5772  			return result, err
  5773  		}
  5774  		tries++
  5775  		if tries >= 3 {
  5776  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5777  			return result, err
  5778  		}
  5779  	}
  5780  
  5781  }
  5782  
  5783  func (s *RetryLayerPostStore) PermanentDeleteByChannel(channelId string) error {
  5784  
  5785  	tries := 0
  5786  	for {
  5787  		err := s.PostStore.PermanentDeleteByChannel(channelId)
  5788  		if err == nil {
  5789  			return nil
  5790  		}
  5791  		if !isRepeatableError(err) {
  5792  			return err
  5793  		}
  5794  		tries++
  5795  		if tries >= 3 {
  5796  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5797  			return err
  5798  		}
  5799  	}
  5800  
  5801  }
  5802  
  5803  func (s *RetryLayerPostStore) PermanentDeleteByUser(userId string) error {
  5804  
  5805  	tries := 0
  5806  	for {
  5807  		err := s.PostStore.PermanentDeleteByUser(userId)
  5808  		if err == nil {
  5809  			return nil
  5810  		}
  5811  		if !isRepeatableError(err) {
  5812  			return err
  5813  		}
  5814  		tries++
  5815  		if tries >= 3 {
  5816  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5817  			return err
  5818  		}
  5819  	}
  5820  
  5821  }
  5822  
  5823  func (s *RetryLayerPostStore) Save(post *model.Post) (*model.Post, error) {
  5824  
  5825  	tries := 0
  5826  	for {
  5827  		result, err := s.PostStore.Save(post)
  5828  		if err == nil {
  5829  			return result, nil
  5830  		}
  5831  		if !isRepeatableError(err) {
  5832  			return result, err
  5833  		}
  5834  		tries++
  5835  		if tries >= 3 {
  5836  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5837  			return result, err
  5838  		}
  5839  	}
  5840  
  5841  }
  5842  
  5843  func (s *RetryLayerPostStore) SaveMultiple(posts []*model.Post) ([]*model.Post, int, error) {
  5844  
  5845  	tries := 0
  5846  	for {
  5847  		result, resultVar1, err := s.PostStore.SaveMultiple(posts)
  5848  		if err == nil {
  5849  			return result, resultVar1, nil
  5850  		}
  5851  		if !isRepeatableError(err) {
  5852  			return result, resultVar1, err
  5853  		}
  5854  		tries++
  5855  		if tries >= 3 {
  5856  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5857  			return result, resultVar1, err
  5858  		}
  5859  	}
  5860  
  5861  }
  5862  
  5863  func (s *RetryLayerPostStore) Search(teamId string, userId string, params *model.SearchParams) (*model.PostList, error) {
  5864  
  5865  	tries := 0
  5866  	for {
  5867  		result, err := s.PostStore.Search(teamId, userId, params)
  5868  		if err == nil {
  5869  			return result, nil
  5870  		}
  5871  		if !isRepeatableError(err) {
  5872  			return result, err
  5873  		}
  5874  		tries++
  5875  		if tries >= 3 {
  5876  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5877  			return result, err
  5878  		}
  5879  	}
  5880  
  5881  }
  5882  
  5883  func (s *RetryLayerPostStore) SearchPostsInTeamForUser(paramsList []*model.SearchParams, userId string, teamId string, page int, perPage int) (*model.PostSearchResults, error) {
  5884  
  5885  	tries := 0
  5886  	for {
  5887  		result, err := s.PostStore.SearchPostsInTeamForUser(paramsList, userId, teamId, page, perPage)
  5888  		if err == nil {
  5889  			return result, nil
  5890  		}
  5891  		if !isRepeatableError(err) {
  5892  			return result, err
  5893  		}
  5894  		tries++
  5895  		if tries >= 3 {
  5896  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5897  			return result, err
  5898  		}
  5899  	}
  5900  
  5901  }
  5902  
  5903  func (s *RetryLayerPostStore) Update(newPost *model.Post, oldPost *model.Post) (*model.Post, error) {
  5904  
  5905  	tries := 0
  5906  	for {
  5907  		result, err := s.PostStore.Update(newPost, oldPost)
  5908  		if err == nil {
  5909  			return result, nil
  5910  		}
  5911  		if !isRepeatableError(err) {
  5912  			return result, err
  5913  		}
  5914  		tries++
  5915  		if tries >= 3 {
  5916  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5917  			return result, err
  5918  		}
  5919  	}
  5920  
  5921  }
  5922  
  5923  func (s *RetryLayerPreferenceStore) CleanupFlagsBatch(limit int64) (int64, error) {
  5924  
  5925  	tries := 0
  5926  	for {
  5927  		result, err := s.PreferenceStore.CleanupFlagsBatch(limit)
  5928  		if err == nil {
  5929  			return result, nil
  5930  		}
  5931  		if !isRepeatableError(err) {
  5932  			return result, err
  5933  		}
  5934  		tries++
  5935  		if tries >= 3 {
  5936  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5937  			return result, err
  5938  		}
  5939  	}
  5940  
  5941  }
  5942  
  5943  func (s *RetryLayerPreferenceStore) Delete(userId string, category string, name string) error {
  5944  
  5945  	tries := 0
  5946  	for {
  5947  		err := s.PreferenceStore.Delete(userId, category, name)
  5948  		if err == nil {
  5949  			return nil
  5950  		}
  5951  		if !isRepeatableError(err) {
  5952  			return err
  5953  		}
  5954  		tries++
  5955  		if tries >= 3 {
  5956  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5957  			return err
  5958  		}
  5959  	}
  5960  
  5961  }
  5962  
  5963  func (s *RetryLayerPreferenceStore) DeleteCategory(userId string, category string) error {
  5964  
  5965  	tries := 0
  5966  	for {
  5967  		err := s.PreferenceStore.DeleteCategory(userId, category)
  5968  		if err == nil {
  5969  			return nil
  5970  		}
  5971  		if !isRepeatableError(err) {
  5972  			return err
  5973  		}
  5974  		tries++
  5975  		if tries >= 3 {
  5976  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5977  			return err
  5978  		}
  5979  	}
  5980  
  5981  }
  5982  
  5983  func (s *RetryLayerPreferenceStore) DeleteCategoryAndName(category string, name string) error {
  5984  
  5985  	tries := 0
  5986  	for {
  5987  		err := s.PreferenceStore.DeleteCategoryAndName(category, name)
  5988  		if err == nil {
  5989  			return nil
  5990  		}
  5991  		if !isRepeatableError(err) {
  5992  			return err
  5993  		}
  5994  		tries++
  5995  		if tries >= 3 {
  5996  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  5997  			return err
  5998  		}
  5999  	}
  6000  
  6001  }
  6002  
  6003  func (s *RetryLayerPreferenceStore) Get(userId string, category string, name string) (*model.Preference, error) {
  6004  
  6005  	tries := 0
  6006  	for {
  6007  		result, err := s.PreferenceStore.Get(userId, category, name)
  6008  		if err == nil {
  6009  			return result, nil
  6010  		}
  6011  		if !isRepeatableError(err) {
  6012  			return result, err
  6013  		}
  6014  		tries++
  6015  		if tries >= 3 {
  6016  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6017  			return result, err
  6018  		}
  6019  	}
  6020  
  6021  }
  6022  
  6023  func (s *RetryLayerPreferenceStore) GetAll(userId string) (model.Preferences, error) {
  6024  
  6025  	tries := 0
  6026  	for {
  6027  		result, err := s.PreferenceStore.GetAll(userId)
  6028  		if err == nil {
  6029  			return result, nil
  6030  		}
  6031  		if !isRepeatableError(err) {
  6032  			return result, err
  6033  		}
  6034  		tries++
  6035  		if tries >= 3 {
  6036  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6037  			return result, err
  6038  		}
  6039  	}
  6040  
  6041  }
  6042  
  6043  func (s *RetryLayerPreferenceStore) GetCategory(userId string, category string) (model.Preferences, error) {
  6044  
  6045  	tries := 0
  6046  	for {
  6047  		result, err := s.PreferenceStore.GetCategory(userId, category)
  6048  		if err == nil {
  6049  			return result, nil
  6050  		}
  6051  		if !isRepeatableError(err) {
  6052  			return result, err
  6053  		}
  6054  		tries++
  6055  		if tries >= 3 {
  6056  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6057  			return result, err
  6058  		}
  6059  	}
  6060  
  6061  }
  6062  
  6063  func (s *RetryLayerPreferenceStore) PermanentDeleteByUser(userId string) error {
  6064  
  6065  	tries := 0
  6066  	for {
  6067  		err := s.PreferenceStore.PermanentDeleteByUser(userId)
  6068  		if err == nil {
  6069  			return nil
  6070  		}
  6071  		if !isRepeatableError(err) {
  6072  			return err
  6073  		}
  6074  		tries++
  6075  		if tries >= 3 {
  6076  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6077  			return err
  6078  		}
  6079  	}
  6080  
  6081  }
  6082  
  6083  func (s *RetryLayerPreferenceStore) Save(preferences *model.Preferences) error {
  6084  
  6085  	tries := 0
  6086  	for {
  6087  		err := s.PreferenceStore.Save(preferences)
  6088  		if err == nil {
  6089  			return nil
  6090  		}
  6091  		if !isRepeatableError(err) {
  6092  			return err
  6093  		}
  6094  		tries++
  6095  		if tries >= 3 {
  6096  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6097  			return err
  6098  		}
  6099  	}
  6100  
  6101  }
  6102  
  6103  func (s *RetryLayerProductNoticesStore) Clear(notices []string) error {
  6104  
  6105  	tries := 0
  6106  	for {
  6107  		err := s.ProductNoticesStore.Clear(notices)
  6108  		if err == nil {
  6109  			return nil
  6110  		}
  6111  		if !isRepeatableError(err) {
  6112  			return err
  6113  		}
  6114  		tries++
  6115  		if tries >= 3 {
  6116  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6117  			return err
  6118  		}
  6119  	}
  6120  
  6121  }
  6122  
  6123  func (s *RetryLayerProductNoticesStore) ClearOldNotices(currentNotices *model.ProductNotices) error {
  6124  
  6125  	tries := 0
  6126  	for {
  6127  		err := s.ProductNoticesStore.ClearOldNotices(currentNotices)
  6128  		if err == nil {
  6129  			return nil
  6130  		}
  6131  		if !isRepeatableError(err) {
  6132  			return err
  6133  		}
  6134  		tries++
  6135  		if tries >= 3 {
  6136  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6137  			return err
  6138  		}
  6139  	}
  6140  
  6141  }
  6142  
  6143  func (s *RetryLayerProductNoticesStore) GetViews(userId string) ([]model.ProductNoticeViewState, error) {
  6144  
  6145  	tries := 0
  6146  	for {
  6147  		result, err := s.ProductNoticesStore.GetViews(userId)
  6148  		if err == nil {
  6149  			return result, nil
  6150  		}
  6151  		if !isRepeatableError(err) {
  6152  			return result, err
  6153  		}
  6154  		tries++
  6155  		if tries >= 3 {
  6156  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6157  			return result, err
  6158  		}
  6159  	}
  6160  
  6161  }
  6162  
  6163  func (s *RetryLayerProductNoticesStore) View(userId string, notices []string) error {
  6164  
  6165  	tries := 0
  6166  	for {
  6167  		err := s.ProductNoticesStore.View(userId, notices)
  6168  		if err == nil {
  6169  			return nil
  6170  		}
  6171  		if !isRepeatableError(err) {
  6172  			return err
  6173  		}
  6174  		tries++
  6175  		if tries >= 3 {
  6176  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6177  			return err
  6178  		}
  6179  	}
  6180  
  6181  }
  6182  
  6183  func (s *RetryLayerReactionStore) BulkGetForPosts(postIds []string) ([]*model.Reaction, error) {
  6184  
  6185  	tries := 0
  6186  	for {
  6187  		result, err := s.ReactionStore.BulkGetForPosts(postIds)
  6188  		if err == nil {
  6189  			return result, nil
  6190  		}
  6191  		if !isRepeatableError(err) {
  6192  			return result, err
  6193  		}
  6194  		tries++
  6195  		if tries >= 3 {
  6196  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6197  			return result, err
  6198  		}
  6199  	}
  6200  
  6201  }
  6202  
  6203  func (s *RetryLayerReactionStore) Delete(reaction *model.Reaction) (*model.Reaction, error) {
  6204  
  6205  	tries := 0
  6206  	for {
  6207  		result, err := s.ReactionStore.Delete(reaction)
  6208  		if err == nil {
  6209  			return result, nil
  6210  		}
  6211  		if !isRepeatableError(err) {
  6212  			return result, err
  6213  		}
  6214  		tries++
  6215  		if tries >= 3 {
  6216  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6217  			return result, err
  6218  		}
  6219  	}
  6220  
  6221  }
  6222  
  6223  func (s *RetryLayerReactionStore) DeleteAllWithEmojiName(emojiName string) error {
  6224  
  6225  	tries := 0
  6226  	for {
  6227  		err := s.ReactionStore.DeleteAllWithEmojiName(emojiName)
  6228  		if err == nil {
  6229  			return nil
  6230  		}
  6231  		if !isRepeatableError(err) {
  6232  			return err
  6233  		}
  6234  		tries++
  6235  		if tries >= 3 {
  6236  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6237  			return err
  6238  		}
  6239  	}
  6240  
  6241  }
  6242  
  6243  func (s *RetryLayerReactionStore) GetForPost(postId string, allowFromCache bool) ([]*model.Reaction, error) {
  6244  
  6245  	tries := 0
  6246  	for {
  6247  		result, err := s.ReactionStore.GetForPost(postId, allowFromCache)
  6248  		if err == nil {
  6249  			return result, nil
  6250  		}
  6251  		if !isRepeatableError(err) {
  6252  			return result, err
  6253  		}
  6254  		tries++
  6255  		if tries >= 3 {
  6256  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6257  			return result, err
  6258  		}
  6259  	}
  6260  
  6261  }
  6262  
  6263  func (s *RetryLayerReactionStore) PermanentDeleteBatch(endTime int64, limit int64) (int64, error) {
  6264  
  6265  	tries := 0
  6266  	for {
  6267  		result, err := s.ReactionStore.PermanentDeleteBatch(endTime, limit)
  6268  		if err == nil {
  6269  			return result, nil
  6270  		}
  6271  		if !isRepeatableError(err) {
  6272  			return result, err
  6273  		}
  6274  		tries++
  6275  		if tries >= 3 {
  6276  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6277  			return result, err
  6278  		}
  6279  	}
  6280  
  6281  }
  6282  
  6283  func (s *RetryLayerReactionStore) Save(reaction *model.Reaction) (*model.Reaction, error) {
  6284  
  6285  	tries := 0
  6286  	for {
  6287  		result, err := s.ReactionStore.Save(reaction)
  6288  		if err == nil {
  6289  			return result, nil
  6290  		}
  6291  		if !isRepeatableError(err) {
  6292  			return result, err
  6293  		}
  6294  		tries++
  6295  		if tries >= 3 {
  6296  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6297  			return result, err
  6298  		}
  6299  	}
  6300  
  6301  }
  6302  
  6303  func (s *RetryLayerRoleStore) AllChannelSchemeRoles() ([]*model.Role, error) {
  6304  
  6305  	tries := 0
  6306  	for {
  6307  		result, err := s.RoleStore.AllChannelSchemeRoles()
  6308  		if err == nil {
  6309  			return result, nil
  6310  		}
  6311  		if !isRepeatableError(err) {
  6312  			return result, err
  6313  		}
  6314  		tries++
  6315  		if tries >= 3 {
  6316  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6317  			return result, err
  6318  		}
  6319  	}
  6320  
  6321  }
  6322  
  6323  func (s *RetryLayerRoleStore) ChannelHigherScopedPermissions(roleNames []string) (map[string]*model.RolePermissions, error) {
  6324  
  6325  	tries := 0
  6326  	for {
  6327  		result, err := s.RoleStore.ChannelHigherScopedPermissions(roleNames)
  6328  		if err == nil {
  6329  			return result, nil
  6330  		}
  6331  		if !isRepeatableError(err) {
  6332  			return result, err
  6333  		}
  6334  		tries++
  6335  		if tries >= 3 {
  6336  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6337  			return result, err
  6338  		}
  6339  	}
  6340  
  6341  }
  6342  
  6343  func (s *RetryLayerRoleStore) ChannelRolesUnderTeamRole(roleName string) ([]*model.Role, error) {
  6344  
  6345  	tries := 0
  6346  	for {
  6347  		result, err := s.RoleStore.ChannelRolesUnderTeamRole(roleName)
  6348  		if err == nil {
  6349  			return result, nil
  6350  		}
  6351  		if !isRepeatableError(err) {
  6352  			return result, err
  6353  		}
  6354  		tries++
  6355  		if tries >= 3 {
  6356  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6357  			return result, err
  6358  		}
  6359  	}
  6360  
  6361  }
  6362  
  6363  func (s *RetryLayerRoleStore) Delete(roleId string) (*model.Role, error) {
  6364  
  6365  	tries := 0
  6366  	for {
  6367  		result, err := s.RoleStore.Delete(roleId)
  6368  		if err == nil {
  6369  			return result, nil
  6370  		}
  6371  		if !isRepeatableError(err) {
  6372  			return result, err
  6373  		}
  6374  		tries++
  6375  		if tries >= 3 {
  6376  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6377  			return result, err
  6378  		}
  6379  	}
  6380  
  6381  }
  6382  
  6383  func (s *RetryLayerRoleStore) Get(roleId string) (*model.Role, error) {
  6384  
  6385  	tries := 0
  6386  	for {
  6387  		result, err := s.RoleStore.Get(roleId)
  6388  		if err == nil {
  6389  			return result, nil
  6390  		}
  6391  		if !isRepeatableError(err) {
  6392  			return result, err
  6393  		}
  6394  		tries++
  6395  		if tries >= 3 {
  6396  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6397  			return result, err
  6398  		}
  6399  	}
  6400  
  6401  }
  6402  
  6403  func (s *RetryLayerRoleStore) GetAll() ([]*model.Role, error) {
  6404  
  6405  	tries := 0
  6406  	for {
  6407  		result, err := s.RoleStore.GetAll()
  6408  		if err == nil {
  6409  			return result, nil
  6410  		}
  6411  		if !isRepeatableError(err) {
  6412  			return result, err
  6413  		}
  6414  		tries++
  6415  		if tries >= 3 {
  6416  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6417  			return result, err
  6418  		}
  6419  	}
  6420  
  6421  }
  6422  
  6423  func (s *RetryLayerRoleStore) GetByName(name string) (*model.Role, error) {
  6424  
  6425  	tries := 0
  6426  	for {
  6427  		result, err := s.RoleStore.GetByName(name)
  6428  		if err == nil {
  6429  			return result, nil
  6430  		}
  6431  		if !isRepeatableError(err) {
  6432  			return result, err
  6433  		}
  6434  		tries++
  6435  		if tries >= 3 {
  6436  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6437  			return result, err
  6438  		}
  6439  	}
  6440  
  6441  }
  6442  
  6443  func (s *RetryLayerRoleStore) GetByNames(names []string) ([]*model.Role, error) {
  6444  
  6445  	tries := 0
  6446  	for {
  6447  		result, err := s.RoleStore.GetByNames(names)
  6448  		if err == nil {
  6449  			return result, nil
  6450  		}
  6451  		if !isRepeatableError(err) {
  6452  			return result, err
  6453  		}
  6454  		tries++
  6455  		if tries >= 3 {
  6456  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6457  			return result, err
  6458  		}
  6459  	}
  6460  
  6461  }
  6462  
  6463  func (s *RetryLayerRoleStore) PermanentDeleteAll() error {
  6464  
  6465  	tries := 0
  6466  	for {
  6467  		err := s.RoleStore.PermanentDeleteAll()
  6468  		if err == nil {
  6469  			return nil
  6470  		}
  6471  		if !isRepeatableError(err) {
  6472  			return err
  6473  		}
  6474  		tries++
  6475  		if tries >= 3 {
  6476  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6477  			return err
  6478  		}
  6479  	}
  6480  
  6481  }
  6482  
  6483  func (s *RetryLayerRoleStore) Save(role *model.Role) (*model.Role, error) {
  6484  
  6485  	tries := 0
  6486  	for {
  6487  		result, err := s.RoleStore.Save(role)
  6488  		if err == nil {
  6489  			return result, nil
  6490  		}
  6491  		if !isRepeatableError(err) {
  6492  			return result, err
  6493  		}
  6494  		tries++
  6495  		if tries >= 3 {
  6496  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6497  			return result, err
  6498  		}
  6499  	}
  6500  
  6501  }
  6502  
  6503  func (s *RetryLayerSchemeStore) CountByScope(scope string) (int64, error) {
  6504  
  6505  	tries := 0
  6506  	for {
  6507  		result, err := s.SchemeStore.CountByScope(scope)
  6508  		if err == nil {
  6509  			return result, nil
  6510  		}
  6511  		if !isRepeatableError(err) {
  6512  			return result, err
  6513  		}
  6514  		tries++
  6515  		if tries >= 3 {
  6516  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6517  			return result, err
  6518  		}
  6519  	}
  6520  
  6521  }
  6522  
  6523  func (s *RetryLayerSchemeStore) CountWithoutPermission(scope string, permissionID string, roleScope model.RoleScope, roleType model.RoleType) (int64, error) {
  6524  
  6525  	tries := 0
  6526  	for {
  6527  		result, err := s.SchemeStore.CountWithoutPermission(scope, permissionID, roleScope, roleType)
  6528  		if err == nil {
  6529  			return result, nil
  6530  		}
  6531  		if !isRepeatableError(err) {
  6532  			return result, err
  6533  		}
  6534  		tries++
  6535  		if tries >= 3 {
  6536  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6537  			return result, err
  6538  		}
  6539  	}
  6540  
  6541  }
  6542  
  6543  func (s *RetryLayerSchemeStore) Delete(schemeId string) (*model.Scheme, error) {
  6544  
  6545  	tries := 0
  6546  	for {
  6547  		result, err := s.SchemeStore.Delete(schemeId)
  6548  		if err == nil {
  6549  			return result, nil
  6550  		}
  6551  		if !isRepeatableError(err) {
  6552  			return result, err
  6553  		}
  6554  		tries++
  6555  		if tries >= 3 {
  6556  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6557  			return result, err
  6558  		}
  6559  	}
  6560  
  6561  }
  6562  
  6563  func (s *RetryLayerSchemeStore) Get(schemeId string) (*model.Scheme, error) {
  6564  
  6565  	tries := 0
  6566  	for {
  6567  		result, err := s.SchemeStore.Get(schemeId)
  6568  		if err == nil {
  6569  			return result, nil
  6570  		}
  6571  		if !isRepeatableError(err) {
  6572  			return result, err
  6573  		}
  6574  		tries++
  6575  		if tries >= 3 {
  6576  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6577  			return result, err
  6578  		}
  6579  	}
  6580  
  6581  }
  6582  
  6583  func (s *RetryLayerSchemeStore) GetAllPage(scope string, offset int, limit int) ([]*model.Scheme, error) {
  6584  
  6585  	tries := 0
  6586  	for {
  6587  		result, err := s.SchemeStore.GetAllPage(scope, offset, limit)
  6588  		if err == nil {
  6589  			return result, nil
  6590  		}
  6591  		if !isRepeatableError(err) {
  6592  			return result, err
  6593  		}
  6594  		tries++
  6595  		if tries >= 3 {
  6596  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6597  			return result, err
  6598  		}
  6599  	}
  6600  
  6601  }
  6602  
  6603  func (s *RetryLayerSchemeStore) GetByName(schemeName string) (*model.Scheme, error) {
  6604  
  6605  	tries := 0
  6606  	for {
  6607  		result, err := s.SchemeStore.GetByName(schemeName)
  6608  		if err == nil {
  6609  			return result, nil
  6610  		}
  6611  		if !isRepeatableError(err) {
  6612  			return result, err
  6613  		}
  6614  		tries++
  6615  		if tries >= 3 {
  6616  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6617  			return result, err
  6618  		}
  6619  	}
  6620  
  6621  }
  6622  
  6623  func (s *RetryLayerSchemeStore) PermanentDeleteAll() error {
  6624  
  6625  	tries := 0
  6626  	for {
  6627  		err := s.SchemeStore.PermanentDeleteAll()
  6628  		if err == nil {
  6629  			return nil
  6630  		}
  6631  		if !isRepeatableError(err) {
  6632  			return err
  6633  		}
  6634  		tries++
  6635  		if tries >= 3 {
  6636  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6637  			return err
  6638  		}
  6639  	}
  6640  
  6641  }
  6642  
  6643  func (s *RetryLayerSchemeStore) Save(scheme *model.Scheme) (*model.Scheme, error) {
  6644  
  6645  	tries := 0
  6646  	for {
  6647  		result, err := s.SchemeStore.Save(scheme)
  6648  		if err == nil {
  6649  			return result, nil
  6650  		}
  6651  		if !isRepeatableError(err) {
  6652  			return result, err
  6653  		}
  6654  		tries++
  6655  		if tries >= 3 {
  6656  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6657  			return result, err
  6658  		}
  6659  	}
  6660  
  6661  }
  6662  
  6663  func (s *RetryLayerSessionStore) AnalyticsSessionCount() (int64, error) {
  6664  
  6665  	tries := 0
  6666  	for {
  6667  		result, err := s.SessionStore.AnalyticsSessionCount()
  6668  		if err == nil {
  6669  			return result, nil
  6670  		}
  6671  		if !isRepeatableError(err) {
  6672  			return result, err
  6673  		}
  6674  		tries++
  6675  		if tries >= 3 {
  6676  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6677  			return result, err
  6678  		}
  6679  	}
  6680  
  6681  }
  6682  
  6683  func (s *RetryLayerSessionStore) Cleanup(expiryTime int64, batchSize int64) {
  6684  
  6685  	s.SessionStore.Cleanup(expiryTime, batchSize)
  6686  
  6687  }
  6688  
  6689  func (s *RetryLayerSessionStore) Get(sessionIdOrToken string) (*model.Session, error) {
  6690  
  6691  	tries := 0
  6692  	for {
  6693  		result, err := s.SessionStore.Get(sessionIdOrToken)
  6694  		if err == nil {
  6695  			return result, nil
  6696  		}
  6697  		if !isRepeatableError(err) {
  6698  			return result, err
  6699  		}
  6700  		tries++
  6701  		if tries >= 3 {
  6702  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6703  			return result, err
  6704  		}
  6705  	}
  6706  
  6707  }
  6708  
  6709  func (s *RetryLayerSessionStore) GetSessions(userId string) ([]*model.Session, error) {
  6710  
  6711  	tries := 0
  6712  	for {
  6713  		result, err := s.SessionStore.GetSessions(userId)
  6714  		if err == nil {
  6715  			return result, nil
  6716  		}
  6717  		if !isRepeatableError(err) {
  6718  			return result, err
  6719  		}
  6720  		tries++
  6721  		if tries >= 3 {
  6722  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6723  			return result, err
  6724  		}
  6725  	}
  6726  
  6727  }
  6728  
  6729  func (s *RetryLayerSessionStore) GetSessionsExpired(thresholdMillis int64, mobileOnly bool, unnotifiedOnly bool) ([]*model.Session, error) {
  6730  
  6731  	tries := 0
  6732  	for {
  6733  		result, err := s.SessionStore.GetSessionsExpired(thresholdMillis, mobileOnly, unnotifiedOnly)
  6734  		if err == nil {
  6735  			return result, nil
  6736  		}
  6737  		if !isRepeatableError(err) {
  6738  			return result, err
  6739  		}
  6740  		tries++
  6741  		if tries >= 3 {
  6742  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6743  			return result, err
  6744  		}
  6745  	}
  6746  
  6747  }
  6748  
  6749  func (s *RetryLayerSessionStore) GetSessionsWithActiveDeviceIds(userId string) ([]*model.Session, error) {
  6750  
  6751  	tries := 0
  6752  	for {
  6753  		result, err := s.SessionStore.GetSessionsWithActiveDeviceIds(userId)
  6754  		if err == nil {
  6755  			return result, nil
  6756  		}
  6757  		if !isRepeatableError(err) {
  6758  			return result, err
  6759  		}
  6760  		tries++
  6761  		if tries >= 3 {
  6762  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6763  			return result, err
  6764  		}
  6765  	}
  6766  
  6767  }
  6768  
  6769  func (s *RetryLayerSessionStore) PermanentDeleteSessionsByUser(teamId string) error {
  6770  
  6771  	tries := 0
  6772  	for {
  6773  		err := s.SessionStore.PermanentDeleteSessionsByUser(teamId)
  6774  		if err == nil {
  6775  			return nil
  6776  		}
  6777  		if !isRepeatableError(err) {
  6778  			return err
  6779  		}
  6780  		tries++
  6781  		if tries >= 3 {
  6782  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6783  			return err
  6784  		}
  6785  	}
  6786  
  6787  }
  6788  
  6789  func (s *RetryLayerSessionStore) Remove(sessionIdOrToken string) error {
  6790  
  6791  	tries := 0
  6792  	for {
  6793  		err := s.SessionStore.Remove(sessionIdOrToken)
  6794  		if err == nil {
  6795  			return nil
  6796  		}
  6797  		if !isRepeatableError(err) {
  6798  			return err
  6799  		}
  6800  		tries++
  6801  		if tries >= 3 {
  6802  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6803  			return err
  6804  		}
  6805  	}
  6806  
  6807  }
  6808  
  6809  func (s *RetryLayerSessionStore) RemoveAllSessions() error {
  6810  
  6811  	tries := 0
  6812  	for {
  6813  		err := s.SessionStore.RemoveAllSessions()
  6814  		if err == nil {
  6815  			return nil
  6816  		}
  6817  		if !isRepeatableError(err) {
  6818  			return err
  6819  		}
  6820  		tries++
  6821  		if tries >= 3 {
  6822  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6823  			return err
  6824  		}
  6825  	}
  6826  
  6827  }
  6828  
  6829  func (s *RetryLayerSessionStore) Save(session *model.Session) (*model.Session, error) {
  6830  
  6831  	tries := 0
  6832  	for {
  6833  		result, err := s.SessionStore.Save(session)
  6834  		if err == nil {
  6835  			return result, nil
  6836  		}
  6837  		if !isRepeatableError(err) {
  6838  			return result, err
  6839  		}
  6840  		tries++
  6841  		if tries >= 3 {
  6842  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6843  			return result, err
  6844  		}
  6845  	}
  6846  
  6847  }
  6848  
  6849  func (s *RetryLayerSessionStore) UpdateDeviceId(id string, deviceId string, expiresAt int64) (string, error) {
  6850  
  6851  	tries := 0
  6852  	for {
  6853  		result, err := s.SessionStore.UpdateDeviceId(id, deviceId, expiresAt)
  6854  		if err == nil {
  6855  			return result, nil
  6856  		}
  6857  		if !isRepeatableError(err) {
  6858  			return result, err
  6859  		}
  6860  		tries++
  6861  		if tries >= 3 {
  6862  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6863  			return result, err
  6864  		}
  6865  	}
  6866  
  6867  }
  6868  
  6869  func (s *RetryLayerSessionStore) UpdateExpiredNotify(sessionid string, notified bool) error {
  6870  
  6871  	tries := 0
  6872  	for {
  6873  		err := s.SessionStore.UpdateExpiredNotify(sessionid, notified)
  6874  		if err == nil {
  6875  			return nil
  6876  		}
  6877  		if !isRepeatableError(err) {
  6878  			return err
  6879  		}
  6880  		tries++
  6881  		if tries >= 3 {
  6882  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6883  			return err
  6884  		}
  6885  	}
  6886  
  6887  }
  6888  
  6889  func (s *RetryLayerSessionStore) UpdateExpiresAt(sessionId string, time int64) error {
  6890  
  6891  	tries := 0
  6892  	for {
  6893  		err := s.SessionStore.UpdateExpiresAt(sessionId, time)
  6894  		if err == nil {
  6895  			return nil
  6896  		}
  6897  		if !isRepeatableError(err) {
  6898  			return err
  6899  		}
  6900  		tries++
  6901  		if tries >= 3 {
  6902  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6903  			return err
  6904  		}
  6905  	}
  6906  
  6907  }
  6908  
  6909  func (s *RetryLayerSessionStore) UpdateLastActivityAt(sessionId string, time int64) error {
  6910  
  6911  	tries := 0
  6912  	for {
  6913  		err := s.SessionStore.UpdateLastActivityAt(sessionId, time)
  6914  		if err == nil {
  6915  			return nil
  6916  		}
  6917  		if !isRepeatableError(err) {
  6918  			return err
  6919  		}
  6920  		tries++
  6921  		if tries >= 3 {
  6922  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6923  			return err
  6924  		}
  6925  	}
  6926  
  6927  }
  6928  
  6929  func (s *RetryLayerSessionStore) UpdateProps(session *model.Session) error {
  6930  
  6931  	tries := 0
  6932  	for {
  6933  		err := s.SessionStore.UpdateProps(session)
  6934  		if err == nil {
  6935  			return nil
  6936  		}
  6937  		if !isRepeatableError(err) {
  6938  			return err
  6939  		}
  6940  		tries++
  6941  		if tries >= 3 {
  6942  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6943  			return err
  6944  		}
  6945  	}
  6946  
  6947  }
  6948  
  6949  func (s *RetryLayerSessionStore) UpdateRoles(userId string, roles string) (string, error) {
  6950  
  6951  	tries := 0
  6952  	for {
  6953  		result, err := s.SessionStore.UpdateRoles(userId, roles)
  6954  		if err == nil {
  6955  			return result, nil
  6956  		}
  6957  		if !isRepeatableError(err) {
  6958  			return result, err
  6959  		}
  6960  		tries++
  6961  		if tries >= 3 {
  6962  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6963  			return result, err
  6964  		}
  6965  	}
  6966  
  6967  }
  6968  
  6969  func (s *RetryLayerStatusStore) Get(userId string) (*model.Status, error) {
  6970  
  6971  	tries := 0
  6972  	for {
  6973  		result, err := s.StatusStore.Get(userId)
  6974  		if err == nil {
  6975  			return result, nil
  6976  		}
  6977  		if !isRepeatableError(err) {
  6978  			return result, err
  6979  		}
  6980  		tries++
  6981  		if tries >= 3 {
  6982  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  6983  			return result, err
  6984  		}
  6985  	}
  6986  
  6987  }
  6988  
  6989  func (s *RetryLayerStatusStore) GetByIds(userIds []string) ([]*model.Status, error) {
  6990  
  6991  	tries := 0
  6992  	for {
  6993  		result, err := s.StatusStore.GetByIds(userIds)
  6994  		if err == nil {
  6995  			return result, nil
  6996  		}
  6997  		if !isRepeatableError(err) {
  6998  			return result, err
  6999  		}
  7000  		tries++
  7001  		if tries >= 3 {
  7002  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7003  			return result, err
  7004  		}
  7005  	}
  7006  
  7007  }
  7008  
  7009  func (s *RetryLayerStatusStore) GetTotalActiveUsersCount() (int64, error) {
  7010  
  7011  	tries := 0
  7012  	for {
  7013  		result, err := s.StatusStore.GetTotalActiveUsersCount()
  7014  		if err == nil {
  7015  			return result, nil
  7016  		}
  7017  		if !isRepeatableError(err) {
  7018  			return result, err
  7019  		}
  7020  		tries++
  7021  		if tries >= 3 {
  7022  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7023  			return result, err
  7024  		}
  7025  	}
  7026  
  7027  }
  7028  
  7029  func (s *RetryLayerStatusStore) ResetAll() error {
  7030  
  7031  	tries := 0
  7032  	for {
  7033  		err := s.StatusStore.ResetAll()
  7034  		if err == nil {
  7035  			return nil
  7036  		}
  7037  		if !isRepeatableError(err) {
  7038  			return err
  7039  		}
  7040  		tries++
  7041  		if tries >= 3 {
  7042  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7043  			return err
  7044  		}
  7045  	}
  7046  
  7047  }
  7048  
  7049  func (s *RetryLayerStatusStore) SaveOrUpdate(status *model.Status) error {
  7050  
  7051  	tries := 0
  7052  	for {
  7053  		err := s.StatusStore.SaveOrUpdate(status)
  7054  		if err == nil {
  7055  			return nil
  7056  		}
  7057  		if !isRepeatableError(err) {
  7058  			return err
  7059  		}
  7060  		tries++
  7061  		if tries >= 3 {
  7062  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7063  			return err
  7064  		}
  7065  	}
  7066  
  7067  }
  7068  
  7069  func (s *RetryLayerStatusStore) UpdateLastActivityAt(userId string, lastActivityAt int64) error {
  7070  
  7071  	tries := 0
  7072  	for {
  7073  		err := s.StatusStore.UpdateLastActivityAt(userId, lastActivityAt)
  7074  		if err == nil {
  7075  			return nil
  7076  		}
  7077  		if !isRepeatableError(err) {
  7078  			return err
  7079  		}
  7080  		tries++
  7081  		if tries >= 3 {
  7082  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7083  			return err
  7084  		}
  7085  	}
  7086  
  7087  }
  7088  
  7089  func (s *RetryLayerSystemStore) Get() (model.StringMap, error) {
  7090  
  7091  	tries := 0
  7092  	for {
  7093  		result, err := s.SystemStore.Get()
  7094  		if err == nil {
  7095  			return result, nil
  7096  		}
  7097  		if !isRepeatableError(err) {
  7098  			return result, err
  7099  		}
  7100  		tries++
  7101  		if tries >= 3 {
  7102  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7103  			return result, err
  7104  		}
  7105  	}
  7106  
  7107  }
  7108  
  7109  func (s *RetryLayerSystemStore) GetByName(name string) (*model.System, error) {
  7110  
  7111  	tries := 0
  7112  	for {
  7113  		result, err := s.SystemStore.GetByName(name)
  7114  		if err == nil {
  7115  			return result, nil
  7116  		}
  7117  		if !isRepeatableError(err) {
  7118  			return result, err
  7119  		}
  7120  		tries++
  7121  		if tries >= 3 {
  7122  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7123  			return result, err
  7124  		}
  7125  	}
  7126  
  7127  }
  7128  
  7129  func (s *RetryLayerSystemStore) InsertIfExists(system *model.System) (*model.System, error) {
  7130  
  7131  	tries := 0
  7132  	for {
  7133  		result, err := s.SystemStore.InsertIfExists(system)
  7134  		if err == nil {
  7135  			return result, nil
  7136  		}
  7137  		if !isRepeatableError(err) {
  7138  			return result, err
  7139  		}
  7140  		tries++
  7141  		if tries >= 3 {
  7142  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7143  			return result, err
  7144  		}
  7145  	}
  7146  
  7147  }
  7148  
  7149  func (s *RetryLayerSystemStore) PermanentDeleteByName(name string) (*model.System, error) {
  7150  
  7151  	tries := 0
  7152  	for {
  7153  		result, err := s.SystemStore.PermanentDeleteByName(name)
  7154  		if err == nil {
  7155  			return result, nil
  7156  		}
  7157  		if !isRepeatableError(err) {
  7158  			return result, err
  7159  		}
  7160  		tries++
  7161  		if tries >= 3 {
  7162  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7163  			return result, err
  7164  		}
  7165  	}
  7166  
  7167  }
  7168  
  7169  func (s *RetryLayerSystemStore) Save(system *model.System) error {
  7170  
  7171  	tries := 0
  7172  	for {
  7173  		err := s.SystemStore.Save(system)
  7174  		if err == nil {
  7175  			return nil
  7176  		}
  7177  		if !isRepeatableError(err) {
  7178  			return err
  7179  		}
  7180  		tries++
  7181  		if tries >= 3 {
  7182  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7183  			return err
  7184  		}
  7185  	}
  7186  
  7187  }
  7188  
  7189  func (s *RetryLayerSystemStore) SaveOrUpdate(system *model.System) error {
  7190  
  7191  	tries := 0
  7192  	for {
  7193  		err := s.SystemStore.SaveOrUpdate(system)
  7194  		if err == nil {
  7195  			return nil
  7196  		}
  7197  		if !isRepeatableError(err) {
  7198  			return err
  7199  		}
  7200  		tries++
  7201  		if tries >= 3 {
  7202  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7203  			return err
  7204  		}
  7205  	}
  7206  
  7207  }
  7208  
  7209  func (s *RetryLayerSystemStore) SaveOrUpdateWithWarnMetricHandling(system *model.System) error {
  7210  
  7211  	tries := 0
  7212  	for {
  7213  		err := s.SystemStore.SaveOrUpdateWithWarnMetricHandling(system)
  7214  		if err == nil {
  7215  			return nil
  7216  		}
  7217  		if !isRepeatableError(err) {
  7218  			return err
  7219  		}
  7220  		tries++
  7221  		if tries >= 3 {
  7222  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7223  			return err
  7224  		}
  7225  	}
  7226  
  7227  }
  7228  
  7229  func (s *RetryLayerSystemStore) Update(system *model.System) error {
  7230  
  7231  	tries := 0
  7232  	for {
  7233  		err := s.SystemStore.Update(system)
  7234  		if err == nil {
  7235  			return nil
  7236  		}
  7237  		if !isRepeatableError(err) {
  7238  			return err
  7239  		}
  7240  		tries++
  7241  		if tries >= 3 {
  7242  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7243  			return err
  7244  		}
  7245  	}
  7246  
  7247  }
  7248  
  7249  func (s *RetryLayerTeamStore) AnalyticsGetTeamCountForScheme(schemeId string) (int64, error) {
  7250  
  7251  	tries := 0
  7252  	for {
  7253  		result, err := s.TeamStore.AnalyticsGetTeamCountForScheme(schemeId)
  7254  		if err == nil {
  7255  			return result, nil
  7256  		}
  7257  		if !isRepeatableError(err) {
  7258  			return result, err
  7259  		}
  7260  		tries++
  7261  		if tries >= 3 {
  7262  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7263  			return result, err
  7264  		}
  7265  	}
  7266  
  7267  }
  7268  
  7269  func (s *RetryLayerTeamStore) AnalyticsPrivateTeamCount() (int64, error) {
  7270  
  7271  	tries := 0
  7272  	for {
  7273  		result, err := s.TeamStore.AnalyticsPrivateTeamCount()
  7274  		if err == nil {
  7275  			return result, nil
  7276  		}
  7277  		if !isRepeatableError(err) {
  7278  			return result, err
  7279  		}
  7280  		tries++
  7281  		if tries >= 3 {
  7282  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7283  			return result, err
  7284  		}
  7285  	}
  7286  
  7287  }
  7288  
  7289  func (s *RetryLayerTeamStore) AnalyticsPublicTeamCount() (int64, error) {
  7290  
  7291  	tries := 0
  7292  	for {
  7293  		result, err := s.TeamStore.AnalyticsPublicTeamCount()
  7294  		if err == nil {
  7295  			return result, nil
  7296  		}
  7297  		if !isRepeatableError(err) {
  7298  			return result, err
  7299  		}
  7300  		tries++
  7301  		if tries >= 3 {
  7302  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7303  			return result, err
  7304  		}
  7305  	}
  7306  
  7307  }
  7308  
  7309  func (s *RetryLayerTeamStore) AnalyticsTeamCount(includeDeleted bool) (int64, error) {
  7310  
  7311  	tries := 0
  7312  	for {
  7313  		result, err := s.TeamStore.AnalyticsTeamCount(includeDeleted)
  7314  		if err == nil {
  7315  			return result, nil
  7316  		}
  7317  		if !isRepeatableError(err) {
  7318  			return result, err
  7319  		}
  7320  		tries++
  7321  		if tries >= 3 {
  7322  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7323  			return result, err
  7324  		}
  7325  	}
  7326  
  7327  }
  7328  
  7329  func (s *RetryLayerTeamStore) ClearAllCustomRoleAssignments() error {
  7330  
  7331  	tries := 0
  7332  	for {
  7333  		err := s.TeamStore.ClearAllCustomRoleAssignments()
  7334  		if err == nil {
  7335  			return nil
  7336  		}
  7337  		if !isRepeatableError(err) {
  7338  			return err
  7339  		}
  7340  		tries++
  7341  		if tries >= 3 {
  7342  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7343  			return err
  7344  		}
  7345  	}
  7346  
  7347  }
  7348  
  7349  func (s *RetryLayerTeamStore) ClearCaches() {
  7350  
  7351  	s.TeamStore.ClearCaches()
  7352  
  7353  }
  7354  
  7355  func (s *RetryLayerTeamStore) Get(id string) (*model.Team, error) {
  7356  
  7357  	tries := 0
  7358  	for {
  7359  		result, err := s.TeamStore.Get(id)
  7360  		if err == nil {
  7361  			return result, nil
  7362  		}
  7363  		if !isRepeatableError(err) {
  7364  			return result, err
  7365  		}
  7366  		tries++
  7367  		if tries >= 3 {
  7368  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7369  			return result, err
  7370  		}
  7371  	}
  7372  
  7373  }
  7374  
  7375  func (s *RetryLayerTeamStore) GetActiveMemberCount(teamId string, restrictions *model.ViewUsersRestrictions) (int64, error) {
  7376  
  7377  	tries := 0
  7378  	for {
  7379  		result, err := s.TeamStore.GetActiveMemberCount(teamId, restrictions)
  7380  		if err == nil {
  7381  			return result, nil
  7382  		}
  7383  		if !isRepeatableError(err) {
  7384  			return result, err
  7385  		}
  7386  		tries++
  7387  		if tries >= 3 {
  7388  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7389  			return result, err
  7390  		}
  7391  	}
  7392  
  7393  }
  7394  
  7395  func (s *RetryLayerTeamStore) GetAll() ([]*model.Team, error) {
  7396  
  7397  	tries := 0
  7398  	for {
  7399  		result, err := s.TeamStore.GetAll()
  7400  		if err == nil {
  7401  			return result, nil
  7402  		}
  7403  		if !isRepeatableError(err) {
  7404  			return result, err
  7405  		}
  7406  		tries++
  7407  		if tries >= 3 {
  7408  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7409  			return result, err
  7410  		}
  7411  	}
  7412  
  7413  }
  7414  
  7415  func (s *RetryLayerTeamStore) GetAllForExportAfter(limit int, afterId string) ([]*model.TeamForExport, error) {
  7416  
  7417  	tries := 0
  7418  	for {
  7419  		result, err := s.TeamStore.GetAllForExportAfter(limit, afterId)
  7420  		if err == nil {
  7421  			return result, nil
  7422  		}
  7423  		if !isRepeatableError(err) {
  7424  			return result, err
  7425  		}
  7426  		tries++
  7427  		if tries >= 3 {
  7428  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7429  			return result, err
  7430  		}
  7431  	}
  7432  
  7433  }
  7434  
  7435  func (s *RetryLayerTeamStore) GetAllPage(offset int, limit int) ([]*model.Team, error) {
  7436  
  7437  	tries := 0
  7438  	for {
  7439  		result, err := s.TeamStore.GetAllPage(offset, limit)
  7440  		if err == nil {
  7441  			return result, nil
  7442  		}
  7443  		if !isRepeatableError(err) {
  7444  			return result, err
  7445  		}
  7446  		tries++
  7447  		if tries >= 3 {
  7448  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7449  			return result, err
  7450  		}
  7451  	}
  7452  
  7453  }
  7454  
  7455  func (s *RetryLayerTeamStore) GetAllPrivateTeamListing() ([]*model.Team, error) {
  7456  
  7457  	tries := 0
  7458  	for {
  7459  		result, err := s.TeamStore.GetAllPrivateTeamListing()
  7460  		if err == nil {
  7461  			return result, nil
  7462  		}
  7463  		if !isRepeatableError(err) {
  7464  			return result, err
  7465  		}
  7466  		tries++
  7467  		if tries >= 3 {
  7468  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7469  			return result, err
  7470  		}
  7471  	}
  7472  
  7473  }
  7474  
  7475  func (s *RetryLayerTeamStore) GetAllPrivateTeamPageListing(offset int, limit int) ([]*model.Team, error) {
  7476  
  7477  	tries := 0
  7478  	for {
  7479  		result, err := s.TeamStore.GetAllPrivateTeamPageListing(offset, limit)
  7480  		if err == nil {
  7481  			return result, nil
  7482  		}
  7483  		if !isRepeatableError(err) {
  7484  			return result, err
  7485  		}
  7486  		tries++
  7487  		if tries >= 3 {
  7488  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7489  			return result, err
  7490  		}
  7491  	}
  7492  
  7493  }
  7494  
  7495  func (s *RetryLayerTeamStore) GetAllPublicTeamPageListing(offset int, limit int) ([]*model.Team, error) {
  7496  
  7497  	tries := 0
  7498  	for {
  7499  		result, err := s.TeamStore.GetAllPublicTeamPageListing(offset, limit)
  7500  		if err == nil {
  7501  			return result, nil
  7502  		}
  7503  		if !isRepeatableError(err) {
  7504  			return result, err
  7505  		}
  7506  		tries++
  7507  		if tries >= 3 {
  7508  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7509  			return result, err
  7510  		}
  7511  	}
  7512  
  7513  }
  7514  
  7515  func (s *RetryLayerTeamStore) GetAllTeamListing() ([]*model.Team, error) {
  7516  
  7517  	tries := 0
  7518  	for {
  7519  		result, err := s.TeamStore.GetAllTeamListing()
  7520  		if err == nil {
  7521  			return result, nil
  7522  		}
  7523  		if !isRepeatableError(err) {
  7524  			return result, err
  7525  		}
  7526  		tries++
  7527  		if tries >= 3 {
  7528  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7529  			return result, err
  7530  		}
  7531  	}
  7532  
  7533  }
  7534  
  7535  func (s *RetryLayerTeamStore) GetAllTeamPageListing(offset int, limit int) ([]*model.Team, error) {
  7536  
  7537  	tries := 0
  7538  	for {
  7539  		result, err := s.TeamStore.GetAllTeamPageListing(offset, limit)
  7540  		if err == nil {
  7541  			return result, nil
  7542  		}
  7543  		if !isRepeatableError(err) {
  7544  			return result, err
  7545  		}
  7546  		tries++
  7547  		if tries >= 3 {
  7548  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7549  			return result, err
  7550  		}
  7551  	}
  7552  
  7553  }
  7554  
  7555  func (s *RetryLayerTeamStore) GetByInviteId(inviteId string) (*model.Team, error) {
  7556  
  7557  	tries := 0
  7558  	for {
  7559  		result, err := s.TeamStore.GetByInviteId(inviteId)
  7560  		if err == nil {
  7561  			return result, nil
  7562  		}
  7563  		if !isRepeatableError(err) {
  7564  			return result, err
  7565  		}
  7566  		tries++
  7567  		if tries >= 3 {
  7568  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7569  			return result, err
  7570  		}
  7571  	}
  7572  
  7573  }
  7574  
  7575  func (s *RetryLayerTeamStore) GetByName(name string) (*model.Team, error) {
  7576  
  7577  	tries := 0
  7578  	for {
  7579  		result, err := s.TeamStore.GetByName(name)
  7580  		if err == nil {
  7581  			return result, nil
  7582  		}
  7583  		if !isRepeatableError(err) {
  7584  			return result, err
  7585  		}
  7586  		tries++
  7587  		if tries >= 3 {
  7588  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7589  			return result, err
  7590  		}
  7591  	}
  7592  
  7593  }
  7594  
  7595  func (s *RetryLayerTeamStore) GetByNames(name []string) ([]*model.Team, error) {
  7596  
  7597  	tries := 0
  7598  	for {
  7599  		result, err := s.TeamStore.GetByNames(name)
  7600  		if err == nil {
  7601  			return result, nil
  7602  		}
  7603  		if !isRepeatableError(err) {
  7604  			return result, err
  7605  		}
  7606  		tries++
  7607  		if tries >= 3 {
  7608  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7609  			return result, err
  7610  		}
  7611  	}
  7612  
  7613  }
  7614  
  7615  func (s *RetryLayerTeamStore) GetChannelUnreadsForAllTeams(excludeTeamId string, userId string) ([]*model.ChannelUnread, error) {
  7616  
  7617  	tries := 0
  7618  	for {
  7619  		result, err := s.TeamStore.GetChannelUnreadsForAllTeams(excludeTeamId, userId)
  7620  		if err == nil {
  7621  			return result, nil
  7622  		}
  7623  		if !isRepeatableError(err) {
  7624  			return result, err
  7625  		}
  7626  		tries++
  7627  		if tries >= 3 {
  7628  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7629  			return result, err
  7630  		}
  7631  	}
  7632  
  7633  }
  7634  
  7635  func (s *RetryLayerTeamStore) GetChannelUnreadsForTeam(teamId string, userId string) ([]*model.ChannelUnread, error) {
  7636  
  7637  	tries := 0
  7638  	for {
  7639  		result, err := s.TeamStore.GetChannelUnreadsForTeam(teamId, userId)
  7640  		if err == nil {
  7641  			return result, nil
  7642  		}
  7643  		if !isRepeatableError(err) {
  7644  			return result, err
  7645  		}
  7646  		tries++
  7647  		if tries >= 3 {
  7648  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7649  			return result, err
  7650  		}
  7651  	}
  7652  
  7653  }
  7654  
  7655  func (s *RetryLayerTeamStore) GetMember(teamId string, userId string) (*model.TeamMember, error) {
  7656  
  7657  	tries := 0
  7658  	for {
  7659  		result, err := s.TeamStore.GetMember(teamId, userId)
  7660  		if err == nil {
  7661  			return result, nil
  7662  		}
  7663  		if !isRepeatableError(err) {
  7664  			return result, err
  7665  		}
  7666  		tries++
  7667  		if tries >= 3 {
  7668  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7669  			return result, err
  7670  		}
  7671  	}
  7672  
  7673  }
  7674  
  7675  func (s *RetryLayerTeamStore) GetMembers(teamId string, offset int, limit int, teamMembersGetOptions *model.TeamMembersGetOptions) ([]*model.TeamMember, error) {
  7676  
  7677  	tries := 0
  7678  	for {
  7679  		result, err := s.TeamStore.GetMembers(teamId, offset, limit, teamMembersGetOptions)
  7680  		if err == nil {
  7681  			return result, nil
  7682  		}
  7683  		if !isRepeatableError(err) {
  7684  			return result, err
  7685  		}
  7686  		tries++
  7687  		if tries >= 3 {
  7688  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7689  			return result, err
  7690  		}
  7691  	}
  7692  
  7693  }
  7694  
  7695  func (s *RetryLayerTeamStore) GetMembersByIds(teamId string, userIds []string, restrictions *model.ViewUsersRestrictions) ([]*model.TeamMember, error) {
  7696  
  7697  	tries := 0
  7698  	for {
  7699  		result, err := s.TeamStore.GetMembersByIds(teamId, userIds, restrictions)
  7700  		if err == nil {
  7701  			return result, nil
  7702  		}
  7703  		if !isRepeatableError(err) {
  7704  			return result, err
  7705  		}
  7706  		tries++
  7707  		if tries >= 3 {
  7708  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7709  			return result, err
  7710  		}
  7711  	}
  7712  
  7713  }
  7714  
  7715  func (s *RetryLayerTeamStore) GetTeamMembersForExport(userId string) ([]*model.TeamMemberForExport, error) {
  7716  
  7717  	tries := 0
  7718  	for {
  7719  		result, err := s.TeamStore.GetTeamMembersForExport(userId)
  7720  		if err == nil {
  7721  			return result, nil
  7722  		}
  7723  		if !isRepeatableError(err) {
  7724  			return result, err
  7725  		}
  7726  		tries++
  7727  		if tries >= 3 {
  7728  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7729  			return result, err
  7730  		}
  7731  	}
  7732  
  7733  }
  7734  
  7735  func (s *RetryLayerTeamStore) GetTeamsByScheme(schemeId string, offset int, limit int) ([]*model.Team, error) {
  7736  
  7737  	tries := 0
  7738  	for {
  7739  		result, err := s.TeamStore.GetTeamsByScheme(schemeId, offset, limit)
  7740  		if err == nil {
  7741  			return result, nil
  7742  		}
  7743  		if !isRepeatableError(err) {
  7744  			return result, err
  7745  		}
  7746  		tries++
  7747  		if tries >= 3 {
  7748  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7749  			return result, err
  7750  		}
  7751  	}
  7752  
  7753  }
  7754  
  7755  func (s *RetryLayerTeamStore) GetTeamsByUserId(userId string) ([]*model.Team, error) {
  7756  
  7757  	tries := 0
  7758  	for {
  7759  		result, err := s.TeamStore.GetTeamsByUserId(userId)
  7760  		if err == nil {
  7761  			return result, nil
  7762  		}
  7763  		if !isRepeatableError(err) {
  7764  			return result, err
  7765  		}
  7766  		tries++
  7767  		if tries >= 3 {
  7768  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7769  			return result, err
  7770  		}
  7771  	}
  7772  
  7773  }
  7774  
  7775  func (s *RetryLayerTeamStore) GetTeamsForUser(ctx context.Context, userId string) ([]*model.TeamMember, error) {
  7776  
  7777  	tries := 0
  7778  	for {
  7779  		result, err := s.TeamStore.GetTeamsForUser(ctx, userId)
  7780  		if err == nil {
  7781  			return result, nil
  7782  		}
  7783  		if !isRepeatableError(err) {
  7784  			return result, err
  7785  		}
  7786  		tries++
  7787  		if tries >= 3 {
  7788  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7789  			return result, err
  7790  		}
  7791  	}
  7792  
  7793  }
  7794  
  7795  func (s *RetryLayerTeamStore) GetTeamsForUserWithPagination(userId string, page int, perPage int) ([]*model.TeamMember, error) {
  7796  
  7797  	tries := 0
  7798  	for {
  7799  		result, err := s.TeamStore.GetTeamsForUserWithPagination(userId, page, perPage)
  7800  		if err == nil {
  7801  			return result, nil
  7802  		}
  7803  		if !isRepeatableError(err) {
  7804  			return result, err
  7805  		}
  7806  		tries++
  7807  		if tries >= 3 {
  7808  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7809  			return result, err
  7810  		}
  7811  	}
  7812  
  7813  }
  7814  
  7815  func (s *RetryLayerTeamStore) GetTotalMemberCount(teamId string, restrictions *model.ViewUsersRestrictions) (int64, error) {
  7816  
  7817  	tries := 0
  7818  	for {
  7819  		result, err := s.TeamStore.GetTotalMemberCount(teamId, restrictions)
  7820  		if err == nil {
  7821  			return result, nil
  7822  		}
  7823  		if !isRepeatableError(err) {
  7824  			return result, err
  7825  		}
  7826  		tries++
  7827  		if tries >= 3 {
  7828  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7829  			return result, err
  7830  		}
  7831  	}
  7832  
  7833  }
  7834  
  7835  func (s *RetryLayerTeamStore) GetUserTeamIds(userId string, allowFromCache bool) ([]string, error) {
  7836  
  7837  	tries := 0
  7838  	for {
  7839  		result, err := s.TeamStore.GetUserTeamIds(userId, allowFromCache)
  7840  		if err == nil {
  7841  			return result, nil
  7842  		}
  7843  		if !isRepeatableError(err) {
  7844  			return result, err
  7845  		}
  7846  		tries++
  7847  		if tries >= 3 {
  7848  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7849  			return result, err
  7850  		}
  7851  	}
  7852  
  7853  }
  7854  
  7855  func (s *RetryLayerTeamStore) GroupSyncedTeamCount() (int64, error) {
  7856  
  7857  	tries := 0
  7858  	for {
  7859  		result, err := s.TeamStore.GroupSyncedTeamCount()
  7860  		if err == nil {
  7861  			return result, nil
  7862  		}
  7863  		if !isRepeatableError(err) {
  7864  			return result, err
  7865  		}
  7866  		tries++
  7867  		if tries >= 3 {
  7868  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7869  			return result, err
  7870  		}
  7871  	}
  7872  
  7873  }
  7874  
  7875  func (s *RetryLayerTeamStore) InvalidateAllTeamIdsForUser(userId string) {
  7876  
  7877  	s.TeamStore.InvalidateAllTeamIdsForUser(userId)
  7878  
  7879  }
  7880  
  7881  func (s *RetryLayerTeamStore) MigrateTeamMembers(fromTeamId string, fromUserId string) (map[string]string, error) {
  7882  
  7883  	tries := 0
  7884  	for {
  7885  		result, err := s.TeamStore.MigrateTeamMembers(fromTeamId, fromUserId)
  7886  		if err == nil {
  7887  			return result, nil
  7888  		}
  7889  		if !isRepeatableError(err) {
  7890  			return result, err
  7891  		}
  7892  		tries++
  7893  		if tries >= 3 {
  7894  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7895  			return result, err
  7896  		}
  7897  	}
  7898  
  7899  }
  7900  
  7901  func (s *RetryLayerTeamStore) PermanentDelete(teamId string) error {
  7902  
  7903  	tries := 0
  7904  	for {
  7905  		err := s.TeamStore.PermanentDelete(teamId)
  7906  		if err == nil {
  7907  			return nil
  7908  		}
  7909  		if !isRepeatableError(err) {
  7910  			return err
  7911  		}
  7912  		tries++
  7913  		if tries >= 3 {
  7914  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7915  			return err
  7916  		}
  7917  	}
  7918  
  7919  }
  7920  
  7921  func (s *RetryLayerTeamStore) RemoveAllMembersByTeam(teamId string) error {
  7922  
  7923  	tries := 0
  7924  	for {
  7925  		err := s.TeamStore.RemoveAllMembersByTeam(teamId)
  7926  		if err == nil {
  7927  			return nil
  7928  		}
  7929  		if !isRepeatableError(err) {
  7930  			return err
  7931  		}
  7932  		tries++
  7933  		if tries >= 3 {
  7934  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7935  			return err
  7936  		}
  7937  	}
  7938  
  7939  }
  7940  
  7941  func (s *RetryLayerTeamStore) RemoveAllMembersByUser(userId string) error {
  7942  
  7943  	tries := 0
  7944  	for {
  7945  		err := s.TeamStore.RemoveAllMembersByUser(userId)
  7946  		if err == nil {
  7947  			return nil
  7948  		}
  7949  		if !isRepeatableError(err) {
  7950  			return err
  7951  		}
  7952  		tries++
  7953  		if tries >= 3 {
  7954  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7955  			return err
  7956  		}
  7957  	}
  7958  
  7959  }
  7960  
  7961  func (s *RetryLayerTeamStore) RemoveMember(teamId string, userId string) error {
  7962  
  7963  	tries := 0
  7964  	for {
  7965  		err := s.TeamStore.RemoveMember(teamId, userId)
  7966  		if err == nil {
  7967  			return nil
  7968  		}
  7969  		if !isRepeatableError(err) {
  7970  			return err
  7971  		}
  7972  		tries++
  7973  		if tries >= 3 {
  7974  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7975  			return err
  7976  		}
  7977  	}
  7978  
  7979  }
  7980  
  7981  func (s *RetryLayerTeamStore) RemoveMembers(teamId string, userIds []string) error {
  7982  
  7983  	tries := 0
  7984  	for {
  7985  		err := s.TeamStore.RemoveMembers(teamId, userIds)
  7986  		if err == nil {
  7987  			return nil
  7988  		}
  7989  		if !isRepeatableError(err) {
  7990  			return err
  7991  		}
  7992  		tries++
  7993  		if tries >= 3 {
  7994  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  7995  			return err
  7996  		}
  7997  	}
  7998  
  7999  }
  8000  
  8001  func (s *RetryLayerTeamStore) ResetAllTeamSchemes() error {
  8002  
  8003  	tries := 0
  8004  	for {
  8005  		err := s.TeamStore.ResetAllTeamSchemes()
  8006  		if err == nil {
  8007  			return nil
  8008  		}
  8009  		if !isRepeatableError(err) {
  8010  			return err
  8011  		}
  8012  		tries++
  8013  		if tries >= 3 {
  8014  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8015  			return err
  8016  		}
  8017  	}
  8018  
  8019  }
  8020  
  8021  func (s *RetryLayerTeamStore) Save(team *model.Team) (*model.Team, error) {
  8022  
  8023  	tries := 0
  8024  	for {
  8025  		result, err := s.TeamStore.Save(team)
  8026  		if err == nil {
  8027  			return result, nil
  8028  		}
  8029  		if !isRepeatableError(err) {
  8030  			return result, err
  8031  		}
  8032  		tries++
  8033  		if tries >= 3 {
  8034  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8035  			return result, err
  8036  		}
  8037  	}
  8038  
  8039  }
  8040  
  8041  func (s *RetryLayerTeamStore) SaveMember(member *model.TeamMember, maxUsersPerTeam int) (*model.TeamMember, error) {
  8042  
  8043  	tries := 0
  8044  	for {
  8045  		result, err := s.TeamStore.SaveMember(member, maxUsersPerTeam)
  8046  		if err == nil {
  8047  			return result, nil
  8048  		}
  8049  		if !isRepeatableError(err) {
  8050  			return result, err
  8051  		}
  8052  		tries++
  8053  		if tries >= 3 {
  8054  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8055  			return result, err
  8056  		}
  8057  	}
  8058  
  8059  }
  8060  
  8061  func (s *RetryLayerTeamStore) SaveMultipleMembers(members []*model.TeamMember, maxUsersPerTeam int) ([]*model.TeamMember, error) {
  8062  
  8063  	tries := 0
  8064  	for {
  8065  		result, err := s.TeamStore.SaveMultipleMembers(members, maxUsersPerTeam)
  8066  		if err == nil {
  8067  			return result, nil
  8068  		}
  8069  		if !isRepeatableError(err) {
  8070  			return result, err
  8071  		}
  8072  		tries++
  8073  		if tries >= 3 {
  8074  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8075  			return result, err
  8076  		}
  8077  	}
  8078  
  8079  }
  8080  
  8081  func (s *RetryLayerTeamStore) SearchAll(term string, opts *model.TeamSearch) ([]*model.Team, error) {
  8082  
  8083  	tries := 0
  8084  	for {
  8085  		result, err := s.TeamStore.SearchAll(term, opts)
  8086  		if err == nil {
  8087  			return result, nil
  8088  		}
  8089  		if !isRepeatableError(err) {
  8090  			return result, err
  8091  		}
  8092  		tries++
  8093  		if tries >= 3 {
  8094  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8095  			return result, err
  8096  		}
  8097  	}
  8098  
  8099  }
  8100  
  8101  func (s *RetryLayerTeamStore) SearchAllPaged(term string, opts *model.TeamSearch) ([]*model.Team, int64, error) {
  8102  
  8103  	tries := 0
  8104  	for {
  8105  		result, resultVar1, err := s.TeamStore.SearchAllPaged(term, opts)
  8106  		if err == nil {
  8107  			return result, resultVar1, nil
  8108  		}
  8109  		if !isRepeatableError(err) {
  8110  			return result, resultVar1, err
  8111  		}
  8112  		tries++
  8113  		if tries >= 3 {
  8114  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8115  			return result, resultVar1, err
  8116  		}
  8117  	}
  8118  
  8119  }
  8120  
  8121  func (s *RetryLayerTeamStore) SearchOpen(term string) ([]*model.Team, error) {
  8122  
  8123  	tries := 0
  8124  	for {
  8125  		result, err := s.TeamStore.SearchOpen(term)
  8126  		if err == nil {
  8127  			return result, nil
  8128  		}
  8129  		if !isRepeatableError(err) {
  8130  			return result, err
  8131  		}
  8132  		tries++
  8133  		if tries >= 3 {
  8134  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8135  			return result, err
  8136  		}
  8137  	}
  8138  
  8139  }
  8140  
  8141  func (s *RetryLayerTeamStore) SearchPrivate(term string) ([]*model.Team, error) {
  8142  
  8143  	tries := 0
  8144  	for {
  8145  		result, err := s.TeamStore.SearchPrivate(term)
  8146  		if err == nil {
  8147  			return result, nil
  8148  		}
  8149  		if !isRepeatableError(err) {
  8150  			return result, err
  8151  		}
  8152  		tries++
  8153  		if tries >= 3 {
  8154  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8155  			return result, err
  8156  		}
  8157  	}
  8158  
  8159  }
  8160  
  8161  func (s *RetryLayerTeamStore) Update(team *model.Team) (*model.Team, error) {
  8162  
  8163  	tries := 0
  8164  	for {
  8165  		result, err := s.TeamStore.Update(team)
  8166  		if err == nil {
  8167  			return result, nil
  8168  		}
  8169  		if !isRepeatableError(err) {
  8170  			return result, err
  8171  		}
  8172  		tries++
  8173  		if tries >= 3 {
  8174  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8175  			return result, err
  8176  		}
  8177  	}
  8178  
  8179  }
  8180  
  8181  func (s *RetryLayerTeamStore) UpdateLastTeamIconUpdate(teamId string, curTime int64) error {
  8182  
  8183  	tries := 0
  8184  	for {
  8185  		err := s.TeamStore.UpdateLastTeamIconUpdate(teamId, curTime)
  8186  		if err == nil {
  8187  			return nil
  8188  		}
  8189  		if !isRepeatableError(err) {
  8190  			return err
  8191  		}
  8192  		tries++
  8193  		if tries >= 3 {
  8194  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8195  			return err
  8196  		}
  8197  	}
  8198  
  8199  }
  8200  
  8201  func (s *RetryLayerTeamStore) UpdateMember(member *model.TeamMember) (*model.TeamMember, error) {
  8202  
  8203  	tries := 0
  8204  	for {
  8205  		result, err := s.TeamStore.UpdateMember(member)
  8206  		if err == nil {
  8207  			return result, nil
  8208  		}
  8209  		if !isRepeatableError(err) {
  8210  			return result, err
  8211  		}
  8212  		tries++
  8213  		if tries >= 3 {
  8214  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8215  			return result, err
  8216  		}
  8217  	}
  8218  
  8219  }
  8220  
  8221  func (s *RetryLayerTeamStore) UpdateMembersRole(teamID string, userIDs []string) error {
  8222  
  8223  	tries := 0
  8224  	for {
  8225  		err := s.TeamStore.UpdateMembersRole(teamID, userIDs)
  8226  		if err == nil {
  8227  			return nil
  8228  		}
  8229  		if !isRepeatableError(err) {
  8230  			return err
  8231  		}
  8232  		tries++
  8233  		if tries >= 3 {
  8234  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8235  			return err
  8236  		}
  8237  	}
  8238  
  8239  }
  8240  
  8241  func (s *RetryLayerTeamStore) UpdateMultipleMembers(members []*model.TeamMember) ([]*model.TeamMember, error) {
  8242  
  8243  	tries := 0
  8244  	for {
  8245  		result, err := s.TeamStore.UpdateMultipleMembers(members)
  8246  		if err == nil {
  8247  			return result, nil
  8248  		}
  8249  		if !isRepeatableError(err) {
  8250  			return result, err
  8251  		}
  8252  		tries++
  8253  		if tries >= 3 {
  8254  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8255  			return result, err
  8256  		}
  8257  	}
  8258  
  8259  }
  8260  
  8261  func (s *RetryLayerTeamStore) UserBelongsToTeams(userId string, teamIds []string) (bool, error) {
  8262  
  8263  	tries := 0
  8264  	for {
  8265  		result, err := s.TeamStore.UserBelongsToTeams(userId, teamIds)
  8266  		if err == nil {
  8267  			return result, nil
  8268  		}
  8269  		if !isRepeatableError(err) {
  8270  			return result, err
  8271  		}
  8272  		tries++
  8273  		if tries >= 3 {
  8274  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8275  			return result, err
  8276  		}
  8277  	}
  8278  
  8279  }
  8280  
  8281  func (s *RetryLayerTermsOfServiceStore) Get(id string, allowFromCache bool) (*model.TermsOfService, error) {
  8282  
  8283  	tries := 0
  8284  	for {
  8285  		result, err := s.TermsOfServiceStore.Get(id, allowFromCache)
  8286  		if err == nil {
  8287  			return result, nil
  8288  		}
  8289  		if !isRepeatableError(err) {
  8290  			return result, err
  8291  		}
  8292  		tries++
  8293  		if tries >= 3 {
  8294  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8295  			return result, err
  8296  		}
  8297  	}
  8298  
  8299  }
  8300  
  8301  func (s *RetryLayerTermsOfServiceStore) GetLatest(allowFromCache bool) (*model.TermsOfService, error) {
  8302  
  8303  	tries := 0
  8304  	for {
  8305  		result, err := s.TermsOfServiceStore.GetLatest(allowFromCache)
  8306  		if err == nil {
  8307  			return result, nil
  8308  		}
  8309  		if !isRepeatableError(err) {
  8310  			return result, err
  8311  		}
  8312  		tries++
  8313  		if tries >= 3 {
  8314  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8315  			return result, err
  8316  		}
  8317  	}
  8318  
  8319  }
  8320  
  8321  func (s *RetryLayerTermsOfServiceStore) Save(termsOfService *model.TermsOfService) (*model.TermsOfService, error) {
  8322  
  8323  	tries := 0
  8324  	for {
  8325  		result, err := s.TermsOfServiceStore.Save(termsOfService)
  8326  		if err == nil {
  8327  			return result, nil
  8328  		}
  8329  		if !isRepeatableError(err) {
  8330  			return result, err
  8331  		}
  8332  		tries++
  8333  		if tries >= 3 {
  8334  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8335  			return result, err
  8336  		}
  8337  	}
  8338  
  8339  }
  8340  
  8341  func (s *RetryLayerThreadStore) CollectThreadsWithNewerReplies(userId string, channelIds []string, timestamp int64) ([]string, error) {
  8342  
  8343  	tries := 0
  8344  	for {
  8345  		result, err := s.ThreadStore.CollectThreadsWithNewerReplies(userId, channelIds, timestamp)
  8346  		if err == nil {
  8347  			return result, nil
  8348  		}
  8349  		if !isRepeatableError(err) {
  8350  			return result, err
  8351  		}
  8352  		tries++
  8353  		if tries >= 3 {
  8354  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8355  			return result, err
  8356  		}
  8357  	}
  8358  
  8359  }
  8360  
  8361  func (s *RetryLayerThreadStore) CreateMembershipIfNeeded(userId string, postId string, following bool, incrementMentions bool, updateFollowing bool) error {
  8362  
  8363  	tries := 0
  8364  	for {
  8365  		err := s.ThreadStore.CreateMembershipIfNeeded(userId, postId, following, incrementMentions, updateFollowing)
  8366  		if err == nil {
  8367  			return nil
  8368  		}
  8369  		if !isRepeatableError(err) {
  8370  			return err
  8371  		}
  8372  		tries++
  8373  		if tries >= 3 {
  8374  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8375  			return err
  8376  		}
  8377  	}
  8378  
  8379  }
  8380  
  8381  func (s *RetryLayerThreadStore) Delete(postId string) error {
  8382  
  8383  	tries := 0
  8384  	for {
  8385  		err := s.ThreadStore.Delete(postId)
  8386  		if err == nil {
  8387  			return nil
  8388  		}
  8389  		if !isRepeatableError(err) {
  8390  			return err
  8391  		}
  8392  		tries++
  8393  		if tries >= 3 {
  8394  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8395  			return err
  8396  		}
  8397  	}
  8398  
  8399  }
  8400  
  8401  func (s *RetryLayerThreadStore) DeleteMembershipForUser(userId string, postId string) error {
  8402  
  8403  	tries := 0
  8404  	for {
  8405  		err := s.ThreadStore.DeleteMembershipForUser(userId, postId)
  8406  		if err == nil {
  8407  			return nil
  8408  		}
  8409  		if !isRepeatableError(err) {
  8410  			return err
  8411  		}
  8412  		tries++
  8413  		if tries >= 3 {
  8414  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8415  			return err
  8416  		}
  8417  	}
  8418  
  8419  }
  8420  
  8421  func (s *RetryLayerThreadStore) Get(id string) (*model.Thread, error) {
  8422  
  8423  	tries := 0
  8424  	for {
  8425  		result, err := s.ThreadStore.Get(id)
  8426  		if err == nil {
  8427  			return result, nil
  8428  		}
  8429  		if !isRepeatableError(err) {
  8430  			return result, err
  8431  		}
  8432  		tries++
  8433  		if tries >= 3 {
  8434  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8435  			return result, err
  8436  		}
  8437  	}
  8438  
  8439  }
  8440  
  8441  func (s *RetryLayerThreadStore) GetMembershipForUser(userId string, postId string) (*model.ThreadMembership, error) {
  8442  
  8443  	tries := 0
  8444  	for {
  8445  		result, err := s.ThreadStore.GetMembershipForUser(userId, postId)
  8446  		if err == nil {
  8447  			return result, nil
  8448  		}
  8449  		if !isRepeatableError(err) {
  8450  			return result, err
  8451  		}
  8452  		tries++
  8453  		if tries >= 3 {
  8454  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8455  			return result, err
  8456  		}
  8457  	}
  8458  
  8459  }
  8460  
  8461  func (s *RetryLayerThreadStore) GetMembershipsForUser(userId string, teamId string) ([]*model.ThreadMembership, error) {
  8462  
  8463  	tries := 0
  8464  	for {
  8465  		result, err := s.ThreadStore.GetMembershipsForUser(userId, teamId)
  8466  		if err == nil {
  8467  			return result, nil
  8468  		}
  8469  		if !isRepeatableError(err) {
  8470  			return result, err
  8471  		}
  8472  		tries++
  8473  		if tries >= 3 {
  8474  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8475  			return result, err
  8476  		}
  8477  	}
  8478  
  8479  }
  8480  
  8481  func (s *RetryLayerThreadStore) GetPosts(threadId string, since int64) ([]*model.Post, error) {
  8482  
  8483  	tries := 0
  8484  	for {
  8485  		result, err := s.ThreadStore.GetPosts(threadId, since)
  8486  		if err == nil {
  8487  			return result, nil
  8488  		}
  8489  		if !isRepeatableError(err) {
  8490  			return result, err
  8491  		}
  8492  		tries++
  8493  		if tries >= 3 {
  8494  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8495  			return result, err
  8496  		}
  8497  	}
  8498  
  8499  }
  8500  
  8501  func (s *RetryLayerThreadStore) GetThreadForUser(userId string, teamId string, threadId string, extended bool) (*model.ThreadResponse, error) {
  8502  
  8503  	tries := 0
  8504  	for {
  8505  		result, err := s.ThreadStore.GetThreadForUser(userId, teamId, threadId, extended)
  8506  		if err == nil {
  8507  			return result, nil
  8508  		}
  8509  		if !isRepeatableError(err) {
  8510  			return result, err
  8511  		}
  8512  		tries++
  8513  		if tries >= 3 {
  8514  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8515  			return result, err
  8516  		}
  8517  	}
  8518  
  8519  }
  8520  
  8521  func (s *RetryLayerThreadStore) GetThreadMentionsForUserPerChannel(userId string, teamId string) (map[string]int64, error) {
  8522  
  8523  	tries := 0
  8524  	for {
  8525  		result, err := s.ThreadStore.GetThreadMentionsForUserPerChannel(userId, teamId)
  8526  		if err == nil {
  8527  			return result, nil
  8528  		}
  8529  		if !isRepeatableError(err) {
  8530  			return result, err
  8531  		}
  8532  		tries++
  8533  		if tries >= 3 {
  8534  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8535  			return result, err
  8536  		}
  8537  	}
  8538  
  8539  }
  8540  
  8541  func (s *RetryLayerThreadStore) GetThreadsForUser(userId string, teamId string, opts model.GetUserThreadsOpts) (*model.Threads, error) {
  8542  
  8543  	tries := 0
  8544  	for {
  8545  		result, err := s.ThreadStore.GetThreadsForUser(userId, teamId, opts)
  8546  		if err == nil {
  8547  			return result, nil
  8548  		}
  8549  		if !isRepeatableError(err) {
  8550  			return result, err
  8551  		}
  8552  		tries++
  8553  		if tries >= 3 {
  8554  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8555  			return result, err
  8556  		}
  8557  	}
  8558  
  8559  }
  8560  
  8561  func (s *RetryLayerThreadStore) MarkAllAsRead(userId string, teamId string) error {
  8562  
  8563  	tries := 0
  8564  	for {
  8565  		err := s.ThreadStore.MarkAllAsRead(userId, teamId)
  8566  		if err == nil {
  8567  			return nil
  8568  		}
  8569  		if !isRepeatableError(err) {
  8570  			return err
  8571  		}
  8572  		tries++
  8573  		if tries >= 3 {
  8574  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8575  			return err
  8576  		}
  8577  	}
  8578  
  8579  }
  8580  
  8581  func (s *RetryLayerThreadStore) MarkAsRead(userId string, threadId string, timestamp int64) error {
  8582  
  8583  	tries := 0
  8584  	for {
  8585  		err := s.ThreadStore.MarkAsRead(userId, threadId, timestamp)
  8586  		if err == nil {
  8587  			return nil
  8588  		}
  8589  		if !isRepeatableError(err) {
  8590  			return err
  8591  		}
  8592  		tries++
  8593  		if tries >= 3 {
  8594  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8595  			return err
  8596  		}
  8597  	}
  8598  
  8599  }
  8600  
  8601  func (s *RetryLayerThreadStore) Save(thread *model.Thread) (*model.Thread, error) {
  8602  
  8603  	tries := 0
  8604  	for {
  8605  		result, err := s.ThreadStore.Save(thread)
  8606  		if err == nil {
  8607  			return result, nil
  8608  		}
  8609  		if !isRepeatableError(err) {
  8610  			return result, err
  8611  		}
  8612  		tries++
  8613  		if tries >= 3 {
  8614  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8615  			return result, err
  8616  		}
  8617  	}
  8618  
  8619  }
  8620  
  8621  func (s *RetryLayerThreadStore) SaveMembership(membership *model.ThreadMembership) (*model.ThreadMembership, error) {
  8622  
  8623  	tries := 0
  8624  	for {
  8625  		result, err := s.ThreadStore.SaveMembership(membership)
  8626  		if err == nil {
  8627  			return result, nil
  8628  		}
  8629  		if !isRepeatableError(err) {
  8630  			return result, err
  8631  		}
  8632  		tries++
  8633  		if tries >= 3 {
  8634  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8635  			return result, err
  8636  		}
  8637  	}
  8638  
  8639  }
  8640  
  8641  func (s *RetryLayerThreadStore) SaveMultiple(thread []*model.Thread) ([]*model.Thread, int, error) {
  8642  
  8643  	tries := 0
  8644  	for {
  8645  		result, resultVar1, err := s.ThreadStore.SaveMultiple(thread)
  8646  		if err == nil {
  8647  			return result, resultVar1, nil
  8648  		}
  8649  		if !isRepeatableError(err) {
  8650  			return result, resultVar1, err
  8651  		}
  8652  		tries++
  8653  		if tries >= 3 {
  8654  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8655  			return result, resultVar1, err
  8656  		}
  8657  	}
  8658  
  8659  }
  8660  
  8661  func (s *RetryLayerThreadStore) Update(thread *model.Thread) (*model.Thread, error) {
  8662  
  8663  	tries := 0
  8664  	for {
  8665  		result, err := s.ThreadStore.Update(thread)
  8666  		if err == nil {
  8667  			return result, nil
  8668  		}
  8669  		if !isRepeatableError(err) {
  8670  			return result, err
  8671  		}
  8672  		tries++
  8673  		if tries >= 3 {
  8674  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8675  			return result, err
  8676  		}
  8677  	}
  8678  
  8679  }
  8680  
  8681  func (s *RetryLayerThreadStore) UpdateMembership(membership *model.ThreadMembership) (*model.ThreadMembership, error) {
  8682  
  8683  	tries := 0
  8684  	for {
  8685  		result, err := s.ThreadStore.UpdateMembership(membership)
  8686  		if err == nil {
  8687  			return result, nil
  8688  		}
  8689  		if !isRepeatableError(err) {
  8690  			return result, err
  8691  		}
  8692  		tries++
  8693  		if tries >= 3 {
  8694  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8695  			return result, err
  8696  		}
  8697  	}
  8698  
  8699  }
  8700  
  8701  func (s *RetryLayerThreadStore) UpdateUnreadsByChannel(userId string, changedThreads []string, timestamp int64, updateViewedTimestamp bool) error {
  8702  
  8703  	tries := 0
  8704  	for {
  8705  		err := s.ThreadStore.UpdateUnreadsByChannel(userId, changedThreads, timestamp, updateViewedTimestamp)
  8706  		if err == nil {
  8707  			return nil
  8708  		}
  8709  		if !isRepeatableError(err) {
  8710  			return err
  8711  		}
  8712  		tries++
  8713  		if tries >= 3 {
  8714  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8715  			return err
  8716  		}
  8717  	}
  8718  
  8719  }
  8720  
  8721  func (s *RetryLayerTokenStore) Cleanup() {
  8722  
  8723  	s.TokenStore.Cleanup()
  8724  
  8725  }
  8726  
  8727  func (s *RetryLayerTokenStore) Delete(token string) error {
  8728  
  8729  	tries := 0
  8730  	for {
  8731  		err := s.TokenStore.Delete(token)
  8732  		if err == nil {
  8733  			return nil
  8734  		}
  8735  		if !isRepeatableError(err) {
  8736  			return err
  8737  		}
  8738  		tries++
  8739  		if tries >= 3 {
  8740  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8741  			return err
  8742  		}
  8743  	}
  8744  
  8745  }
  8746  
  8747  func (s *RetryLayerTokenStore) GetByToken(token string) (*model.Token, error) {
  8748  
  8749  	tries := 0
  8750  	for {
  8751  		result, err := s.TokenStore.GetByToken(token)
  8752  		if err == nil {
  8753  			return result, nil
  8754  		}
  8755  		if !isRepeatableError(err) {
  8756  			return result, err
  8757  		}
  8758  		tries++
  8759  		if tries >= 3 {
  8760  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8761  			return result, err
  8762  		}
  8763  	}
  8764  
  8765  }
  8766  
  8767  func (s *RetryLayerTokenStore) RemoveAllTokensByType(tokenType string) error {
  8768  
  8769  	tries := 0
  8770  	for {
  8771  		err := s.TokenStore.RemoveAllTokensByType(tokenType)
  8772  		if err == nil {
  8773  			return nil
  8774  		}
  8775  		if !isRepeatableError(err) {
  8776  			return err
  8777  		}
  8778  		tries++
  8779  		if tries >= 3 {
  8780  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8781  			return err
  8782  		}
  8783  	}
  8784  
  8785  }
  8786  
  8787  func (s *RetryLayerTokenStore) Save(recovery *model.Token) error {
  8788  
  8789  	tries := 0
  8790  	for {
  8791  		err := s.TokenStore.Save(recovery)
  8792  		if err == nil {
  8793  			return nil
  8794  		}
  8795  		if !isRepeatableError(err) {
  8796  			return err
  8797  		}
  8798  		tries++
  8799  		if tries >= 3 {
  8800  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8801  			return err
  8802  		}
  8803  	}
  8804  
  8805  }
  8806  
  8807  func (s *RetryLayerUploadSessionStore) Delete(id string) error {
  8808  
  8809  	tries := 0
  8810  	for {
  8811  		err := s.UploadSessionStore.Delete(id)
  8812  		if err == nil {
  8813  			return nil
  8814  		}
  8815  		if !isRepeatableError(err) {
  8816  			return err
  8817  		}
  8818  		tries++
  8819  		if tries >= 3 {
  8820  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8821  			return err
  8822  		}
  8823  	}
  8824  
  8825  }
  8826  
  8827  func (s *RetryLayerUploadSessionStore) Get(id string) (*model.UploadSession, error) {
  8828  
  8829  	tries := 0
  8830  	for {
  8831  		result, err := s.UploadSessionStore.Get(id)
  8832  		if err == nil {
  8833  			return result, nil
  8834  		}
  8835  		if !isRepeatableError(err) {
  8836  			return result, err
  8837  		}
  8838  		tries++
  8839  		if tries >= 3 {
  8840  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8841  			return result, err
  8842  		}
  8843  	}
  8844  
  8845  }
  8846  
  8847  func (s *RetryLayerUploadSessionStore) GetForUser(userId string) ([]*model.UploadSession, error) {
  8848  
  8849  	tries := 0
  8850  	for {
  8851  		result, err := s.UploadSessionStore.GetForUser(userId)
  8852  		if err == nil {
  8853  			return result, nil
  8854  		}
  8855  		if !isRepeatableError(err) {
  8856  			return result, err
  8857  		}
  8858  		tries++
  8859  		if tries >= 3 {
  8860  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8861  			return result, err
  8862  		}
  8863  	}
  8864  
  8865  }
  8866  
  8867  func (s *RetryLayerUploadSessionStore) Save(session *model.UploadSession) (*model.UploadSession, error) {
  8868  
  8869  	tries := 0
  8870  	for {
  8871  		result, err := s.UploadSessionStore.Save(session)
  8872  		if err == nil {
  8873  			return result, nil
  8874  		}
  8875  		if !isRepeatableError(err) {
  8876  			return result, err
  8877  		}
  8878  		tries++
  8879  		if tries >= 3 {
  8880  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8881  			return result, err
  8882  		}
  8883  	}
  8884  
  8885  }
  8886  
  8887  func (s *RetryLayerUploadSessionStore) Update(session *model.UploadSession) error {
  8888  
  8889  	tries := 0
  8890  	for {
  8891  		err := s.UploadSessionStore.Update(session)
  8892  		if err == nil {
  8893  			return nil
  8894  		}
  8895  		if !isRepeatableError(err) {
  8896  			return err
  8897  		}
  8898  		tries++
  8899  		if tries >= 3 {
  8900  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8901  			return err
  8902  		}
  8903  	}
  8904  
  8905  }
  8906  
  8907  func (s *RetryLayerUserStore) AnalyticsActiveCount(time int64, options model.UserCountOptions) (int64, error) {
  8908  
  8909  	tries := 0
  8910  	for {
  8911  		result, err := s.UserStore.AnalyticsActiveCount(time, options)
  8912  		if err == nil {
  8913  			return result, nil
  8914  		}
  8915  		if !isRepeatableError(err) {
  8916  			return result, err
  8917  		}
  8918  		tries++
  8919  		if tries >= 3 {
  8920  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8921  			return result, err
  8922  		}
  8923  	}
  8924  
  8925  }
  8926  
  8927  func (s *RetryLayerUserStore) AnalyticsActiveCountForPeriod(startTime int64, endTime int64, options model.UserCountOptions) (int64, error) {
  8928  
  8929  	tries := 0
  8930  	for {
  8931  		result, err := s.UserStore.AnalyticsActiveCountForPeriod(startTime, endTime, options)
  8932  		if err == nil {
  8933  			return result, nil
  8934  		}
  8935  		if !isRepeatableError(err) {
  8936  			return result, err
  8937  		}
  8938  		tries++
  8939  		if tries >= 3 {
  8940  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8941  			return result, err
  8942  		}
  8943  	}
  8944  
  8945  }
  8946  
  8947  func (s *RetryLayerUserStore) AnalyticsGetExternalUsers(hostDomain string) (bool, error) {
  8948  
  8949  	tries := 0
  8950  	for {
  8951  		result, err := s.UserStore.AnalyticsGetExternalUsers(hostDomain)
  8952  		if err == nil {
  8953  			return result, nil
  8954  		}
  8955  		if !isRepeatableError(err) {
  8956  			return result, err
  8957  		}
  8958  		tries++
  8959  		if tries >= 3 {
  8960  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8961  			return result, err
  8962  		}
  8963  	}
  8964  
  8965  }
  8966  
  8967  func (s *RetryLayerUserStore) AnalyticsGetGuestCount() (int64, error) {
  8968  
  8969  	tries := 0
  8970  	for {
  8971  		result, err := s.UserStore.AnalyticsGetGuestCount()
  8972  		if err == nil {
  8973  			return result, nil
  8974  		}
  8975  		if !isRepeatableError(err) {
  8976  			return result, err
  8977  		}
  8978  		tries++
  8979  		if tries >= 3 {
  8980  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  8981  			return result, err
  8982  		}
  8983  	}
  8984  
  8985  }
  8986  
  8987  func (s *RetryLayerUserStore) AnalyticsGetInactiveUsersCount() (int64, error) {
  8988  
  8989  	tries := 0
  8990  	for {
  8991  		result, err := s.UserStore.AnalyticsGetInactiveUsersCount()
  8992  		if err == nil {
  8993  			return result, nil
  8994  		}
  8995  		if !isRepeatableError(err) {
  8996  			return result, err
  8997  		}
  8998  		tries++
  8999  		if tries >= 3 {
  9000  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9001  			return result, err
  9002  		}
  9003  	}
  9004  
  9005  }
  9006  
  9007  func (s *RetryLayerUserStore) AnalyticsGetSystemAdminCount() (int64, error) {
  9008  
  9009  	tries := 0
  9010  	for {
  9011  		result, err := s.UserStore.AnalyticsGetSystemAdminCount()
  9012  		if err == nil {
  9013  			return result, nil
  9014  		}
  9015  		if !isRepeatableError(err) {
  9016  			return result, err
  9017  		}
  9018  		tries++
  9019  		if tries >= 3 {
  9020  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9021  			return result, err
  9022  		}
  9023  	}
  9024  
  9025  }
  9026  
  9027  func (s *RetryLayerUserStore) AutocompleteUsersInChannel(teamId string, channelId string, term string, options *model.UserSearchOptions) (*model.UserAutocompleteInChannel, error) {
  9028  
  9029  	tries := 0
  9030  	for {
  9031  		result, err := s.UserStore.AutocompleteUsersInChannel(teamId, channelId, term, options)
  9032  		if err == nil {
  9033  			return result, nil
  9034  		}
  9035  		if !isRepeatableError(err) {
  9036  			return result, err
  9037  		}
  9038  		tries++
  9039  		if tries >= 3 {
  9040  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9041  			return result, err
  9042  		}
  9043  	}
  9044  
  9045  }
  9046  
  9047  func (s *RetryLayerUserStore) ClearAllCustomRoleAssignments() error {
  9048  
  9049  	tries := 0
  9050  	for {
  9051  		err := s.UserStore.ClearAllCustomRoleAssignments()
  9052  		if err == nil {
  9053  			return nil
  9054  		}
  9055  		if !isRepeatableError(err) {
  9056  			return err
  9057  		}
  9058  		tries++
  9059  		if tries >= 3 {
  9060  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9061  			return err
  9062  		}
  9063  	}
  9064  
  9065  }
  9066  
  9067  func (s *RetryLayerUserStore) ClearCaches() {
  9068  
  9069  	s.UserStore.ClearCaches()
  9070  
  9071  }
  9072  
  9073  func (s *RetryLayerUserStore) Count(options model.UserCountOptions) (int64, error) {
  9074  
  9075  	tries := 0
  9076  	for {
  9077  		result, err := s.UserStore.Count(options)
  9078  		if err == nil {
  9079  			return result, nil
  9080  		}
  9081  		if !isRepeatableError(err) {
  9082  			return result, err
  9083  		}
  9084  		tries++
  9085  		if tries >= 3 {
  9086  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9087  			return result, err
  9088  		}
  9089  	}
  9090  
  9091  }
  9092  
  9093  func (s *RetryLayerUserStore) DeactivateGuests() ([]string, error) {
  9094  
  9095  	tries := 0
  9096  	for {
  9097  		result, err := s.UserStore.DeactivateGuests()
  9098  		if err == nil {
  9099  			return result, nil
  9100  		}
  9101  		if !isRepeatableError(err) {
  9102  			return result, err
  9103  		}
  9104  		tries++
  9105  		if tries >= 3 {
  9106  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9107  			return result, err
  9108  		}
  9109  	}
  9110  
  9111  }
  9112  
  9113  func (s *RetryLayerUserStore) DemoteUserToGuest(userID string) (*model.User, error) {
  9114  
  9115  	tries := 0
  9116  	for {
  9117  		result, err := s.UserStore.DemoteUserToGuest(userID)
  9118  		if err == nil {
  9119  			return result, nil
  9120  		}
  9121  		if !isRepeatableError(err) {
  9122  			return result, err
  9123  		}
  9124  		tries++
  9125  		if tries >= 3 {
  9126  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9127  			return result, err
  9128  		}
  9129  	}
  9130  
  9131  }
  9132  
  9133  func (s *RetryLayerUserStore) Get(ctx context.Context, id string) (*model.User, error) {
  9134  
  9135  	tries := 0
  9136  	for {
  9137  		result, err := s.UserStore.Get(ctx, id)
  9138  		if err == nil {
  9139  			return result, nil
  9140  		}
  9141  		if !isRepeatableError(err) {
  9142  			return result, err
  9143  		}
  9144  		tries++
  9145  		if tries >= 3 {
  9146  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9147  			return result, err
  9148  		}
  9149  	}
  9150  
  9151  }
  9152  
  9153  func (s *RetryLayerUserStore) GetAll() ([]*model.User, error) {
  9154  
  9155  	tries := 0
  9156  	for {
  9157  		result, err := s.UserStore.GetAll()
  9158  		if err == nil {
  9159  			return result, nil
  9160  		}
  9161  		if !isRepeatableError(err) {
  9162  			return result, err
  9163  		}
  9164  		tries++
  9165  		if tries >= 3 {
  9166  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9167  			return result, err
  9168  		}
  9169  	}
  9170  
  9171  }
  9172  
  9173  func (s *RetryLayerUserStore) GetAllAfter(limit int, afterId string) ([]*model.User, error) {
  9174  
  9175  	tries := 0
  9176  	for {
  9177  		result, err := s.UserStore.GetAllAfter(limit, afterId)
  9178  		if err == nil {
  9179  			return result, nil
  9180  		}
  9181  		if !isRepeatableError(err) {
  9182  			return result, err
  9183  		}
  9184  		tries++
  9185  		if tries >= 3 {
  9186  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9187  			return result, err
  9188  		}
  9189  	}
  9190  
  9191  }
  9192  
  9193  func (s *RetryLayerUserStore) GetAllNotInAuthService(authServices []string) ([]*model.User, error) {
  9194  
  9195  	tries := 0
  9196  	for {
  9197  		result, err := s.UserStore.GetAllNotInAuthService(authServices)
  9198  		if err == nil {
  9199  			return result, nil
  9200  		}
  9201  		if !isRepeatableError(err) {
  9202  			return result, err
  9203  		}
  9204  		tries++
  9205  		if tries >= 3 {
  9206  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9207  			return result, err
  9208  		}
  9209  	}
  9210  
  9211  }
  9212  
  9213  func (s *RetryLayerUserStore) GetAllProfiles(options *model.UserGetOptions) ([]*model.User, error) {
  9214  
  9215  	tries := 0
  9216  	for {
  9217  		result, err := s.UserStore.GetAllProfiles(options)
  9218  		if err == nil {
  9219  			return result, nil
  9220  		}
  9221  		if !isRepeatableError(err) {
  9222  			return result, err
  9223  		}
  9224  		tries++
  9225  		if tries >= 3 {
  9226  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9227  			return result, err
  9228  		}
  9229  	}
  9230  
  9231  }
  9232  
  9233  func (s *RetryLayerUserStore) GetAllProfilesInChannel(ctx context.Context, channelId string, allowFromCache bool) (map[string]*model.User, error) {
  9234  
  9235  	tries := 0
  9236  	for {
  9237  		result, err := s.UserStore.GetAllProfilesInChannel(ctx, channelId, allowFromCache)
  9238  		if err == nil {
  9239  			return result, nil
  9240  		}
  9241  		if !isRepeatableError(err) {
  9242  			return result, err
  9243  		}
  9244  		tries++
  9245  		if tries >= 3 {
  9246  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9247  			return result, err
  9248  		}
  9249  	}
  9250  
  9251  }
  9252  
  9253  func (s *RetryLayerUserStore) GetAllUsingAuthService(authService string) ([]*model.User, error) {
  9254  
  9255  	tries := 0
  9256  	for {
  9257  		result, err := s.UserStore.GetAllUsingAuthService(authService)
  9258  		if err == nil {
  9259  			return result, nil
  9260  		}
  9261  		if !isRepeatableError(err) {
  9262  			return result, err
  9263  		}
  9264  		tries++
  9265  		if tries >= 3 {
  9266  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9267  			return result, err
  9268  		}
  9269  	}
  9270  
  9271  }
  9272  
  9273  func (s *RetryLayerUserStore) GetAnyUnreadPostCountForChannel(userId string, channelId string) (int64, error) {
  9274  
  9275  	tries := 0
  9276  	for {
  9277  		result, err := s.UserStore.GetAnyUnreadPostCountForChannel(userId, channelId)
  9278  		if err == nil {
  9279  			return result, nil
  9280  		}
  9281  		if !isRepeatableError(err) {
  9282  			return result, err
  9283  		}
  9284  		tries++
  9285  		if tries >= 3 {
  9286  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9287  			return result, err
  9288  		}
  9289  	}
  9290  
  9291  }
  9292  
  9293  func (s *RetryLayerUserStore) GetByAuth(authData *string, authService string) (*model.User, error) {
  9294  
  9295  	tries := 0
  9296  	for {
  9297  		result, err := s.UserStore.GetByAuth(authData, authService)
  9298  		if err == nil {
  9299  			return result, nil
  9300  		}
  9301  		if !isRepeatableError(err) {
  9302  			return result, err
  9303  		}
  9304  		tries++
  9305  		if tries >= 3 {
  9306  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9307  			return result, err
  9308  		}
  9309  	}
  9310  
  9311  }
  9312  
  9313  func (s *RetryLayerUserStore) GetByEmail(email string) (*model.User, error) {
  9314  
  9315  	tries := 0
  9316  	for {
  9317  		result, err := s.UserStore.GetByEmail(email)
  9318  		if err == nil {
  9319  			return result, nil
  9320  		}
  9321  		if !isRepeatableError(err) {
  9322  			return result, err
  9323  		}
  9324  		tries++
  9325  		if tries >= 3 {
  9326  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9327  			return result, err
  9328  		}
  9329  	}
  9330  
  9331  }
  9332  
  9333  func (s *RetryLayerUserStore) GetByUsername(username string) (*model.User, error) {
  9334  
  9335  	tries := 0
  9336  	for {
  9337  		result, err := s.UserStore.GetByUsername(username)
  9338  		if err == nil {
  9339  			return result, nil
  9340  		}
  9341  		if !isRepeatableError(err) {
  9342  			return result, err
  9343  		}
  9344  		tries++
  9345  		if tries >= 3 {
  9346  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9347  			return result, err
  9348  		}
  9349  	}
  9350  
  9351  }
  9352  
  9353  func (s *RetryLayerUserStore) GetChannelGroupUsers(channelID string) ([]*model.User, error) {
  9354  
  9355  	tries := 0
  9356  	for {
  9357  		result, err := s.UserStore.GetChannelGroupUsers(channelID)
  9358  		if err == nil {
  9359  			return result, nil
  9360  		}
  9361  		if !isRepeatableError(err) {
  9362  			return result, err
  9363  		}
  9364  		tries++
  9365  		if tries >= 3 {
  9366  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9367  			return result, err
  9368  		}
  9369  	}
  9370  
  9371  }
  9372  
  9373  func (s *RetryLayerUserStore) GetEtagForAllProfiles() string {
  9374  
  9375  	return s.UserStore.GetEtagForAllProfiles()
  9376  
  9377  }
  9378  
  9379  func (s *RetryLayerUserStore) GetEtagForProfiles(teamId string) string {
  9380  
  9381  	return s.UserStore.GetEtagForProfiles(teamId)
  9382  
  9383  }
  9384  
  9385  func (s *RetryLayerUserStore) GetEtagForProfilesNotInTeam(teamId string) string {
  9386  
  9387  	return s.UserStore.GetEtagForProfilesNotInTeam(teamId)
  9388  
  9389  }
  9390  
  9391  func (s *RetryLayerUserStore) GetForLogin(loginId string, allowSignInWithUsername bool, allowSignInWithEmail bool) (*model.User, error) {
  9392  
  9393  	tries := 0
  9394  	for {
  9395  		result, err := s.UserStore.GetForLogin(loginId, allowSignInWithUsername, allowSignInWithEmail)
  9396  		if err == nil {
  9397  			return result, nil
  9398  		}
  9399  		if !isRepeatableError(err) {
  9400  			return result, err
  9401  		}
  9402  		tries++
  9403  		if tries >= 3 {
  9404  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9405  			return result, err
  9406  		}
  9407  	}
  9408  
  9409  }
  9410  
  9411  func (s *RetryLayerUserStore) GetKnownUsers(userID string) ([]string, error) {
  9412  
  9413  	tries := 0
  9414  	for {
  9415  		result, err := s.UserStore.GetKnownUsers(userID)
  9416  		if err == nil {
  9417  			return result, nil
  9418  		}
  9419  		if !isRepeatableError(err) {
  9420  			return result, err
  9421  		}
  9422  		tries++
  9423  		if tries >= 3 {
  9424  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9425  			return result, err
  9426  		}
  9427  	}
  9428  
  9429  }
  9430  
  9431  func (s *RetryLayerUserStore) GetMany(ctx context.Context, ids []string) ([]*model.User, error) {
  9432  
  9433  	tries := 0
  9434  	for {
  9435  		result, err := s.UserStore.GetMany(ctx, ids)
  9436  		if err == nil {
  9437  			return result, nil
  9438  		}
  9439  		if !isRepeatableError(err) {
  9440  			return result, err
  9441  		}
  9442  		tries++
  9443  		if tries >= 3 {
  9444  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9445  			return result, err
  9446  		}
  9447  	}
  9448  
  9449  }
  9450  
  9451  func (s *RetryLayerUserStore) GetNewUsersForTeam(teamId string, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, error) {
  9452  
  9453  	tries := 0
  9454  	for {
  9455  		result, err := s.UserStore.GetNewUsersForTeam(teamId, offset, limit, viewRestrictions)
  9456  		if err == nil {
  9457  			return result, nil
  9458  		}
  9459  		if !isRepeatableError(err) {
  9460  			return result, err
  9461  		}
  9462  		tries++
  9463  		if tries >= 3 {
  9464  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9465  			return result, err
  9466  		}
  9467  	}
  9468  
  9469  }
  9470  
  9471  func (s *RetryLayerUserStore) GetProfileByGroupChannelIdsForUser(userId string, channelIds []string) (map[string][]*model.User, error) {
  9472  
  9473  	tries := 0
  9474  	for {
  9475  		result, err := s.UserStore.GetProfileByGroupChannelIdsForUser(userId, channelIds)
  9476  		if err == nil {
  9477  			return result, nil
  9478  		}
  9479  		if !isRepeatableError(err) {
  9480  			return result, err
  9481  		}
  9482  		tries++
  9483  		if tries >= 3 {
  9484  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9485  			return result, err
  9486  		}
  9487  	}
  9488  
  9489  }
  9490  
  9491  func (s *RetryLayerUserStore) GetProfileByIds(ctx context.Context, userIds []string, options *store.UserGetByIdsOpts, allowFromCache bool) ([]*model.User, error) {
  9492  
  9493  	tries := 0
  9494  	for {
  9495  		result, err := s.UserStore.GetProfileByIds(ctx, userIds, options, allowFromCache)
  9496  		if err == nil {
  9497  			return result, nil
  9498  		}
  9499  		if !isRepeatableError(err) {
  9500  			return result, err
  9501  		}
  9502  		tries++
  9503  		if tries >= 3 {
  9504  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9505  			return result, err
  9506  		}
  9507  	}
  9508  
  9509  }
  9510  
  9511  func (s *RetryLayerUserStore) GetProfiles(options *model.UserGetOptions) ([]*model.User, error) {
  9512  
  9513  	tries := 0
  9514  	for {
  9515  		result, err := s.UserStore.GetProfiles(options)
  9516  		if err == nil {
  9517  			return result, nil
  9518  		}
  9519  		if !isRepeatableError(err) {
  9520  			return result, err
  9521  		}
  9522  		tries++
  9523  		if tries >= 3 {
  9524  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9525  			return result, err
  9526  		}
  9527  	}
  9528  
  9529  }
  9530  
  9531  func (s *RetryLayerUserStore) GetProfilesByUsernames(usernames []string, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, error) {
  9532  
  9533  	tries := 0
  9534  	for {
  9535  		result, err := s.UserStore.GetProfilesByUsernames(usernames, viewRestrictions)
  9536  		if err == nil {
  9537  			return result, nil
  9538  		}
  9539  		if !isRepeatableError(err) {
  9540  			return result, err
  9541  		}
  9542  		tries++
  9543  		if tries >= 3 {
  9544  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9545  			return result, err
  9546  		}
  9547  	}
  9548  
  9549  }
  9550  
  9551  func (s *RetryLayerUserStore) GetProfilesInChannel(options *model.UserGetOptions) ([]*model.User, error) {
  9552  
  9553  	tries := 0
  9554  	for {
  9555  		result, err := s.UserStore.GetProfilesInChannel(options)
  9556  		if err == nil {
  9557  			return result, nil
  9558  		}
  9559  		if !isRepeatableError(err) {
  9560  			return result, err
  9561  		}
  9562  		tries++
  9563  		if tries >= 3 {
  9564  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9565  			return result, err
  9566  		}
  9567  	}
  9568  
  9569  }
  9570  
  9571  func (s *RetryLayerUserStore) GetProfilesInChannelByStatus(options *model.UserGetOptions) ([]*model.User, error) {
  9572  
  9573  	tries := 0
  9574  	for {
  9575  		result, err := s.UserStore.GetProfilesInChannelByStatus(options)
  9576  		if err == nil {
  9577  			return result, nil
  9578  		}
  9579  		if !isRepeatableError(err) {
  9580  			return result, err
  9581  		}
  9582  		tries++
  9583  		if tries >= 3 {
  9584  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9585  			return result, err
  9586  		}
  9587  	}
  9588  
  9589  }
  9590  
  9591  func (s *RetryLayerUserStore) GetProfilesNotInChannel(teamId string, channelId string, groupConstrained bool, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, error) {
  9592  
  9593  	tries := 0
  9594  	for {
  9595  		result, err := s.UserStore.GetProfilesNotInChannel(teamId, channelId, groupConstrained, offset, limit, viewRestrictions)
  9596  		if err == nil {
  9597  			return result, nil
  9598  		}
  9599  		if !isRepeatableError(err) {
  9600  			return result, err
  9601  		}
  9602  		tries++
  9603  		if tries >= 3 {
  9604  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9605  			return result, err
  9606  		}
  9607  	}
  9608  
  9609  }
  9610  
  9611  func (s *RetryLayerUserStore) GetProfilesNotInTeam(teamId string, groupConstrained bool, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, error) {
  9612  
  9613  	tries := 0
  9614  	for {
  9615  		result, err := s.UserStore.GetProfilesNotInTeam(teamId, groupConstrained, offset, limit, viewRestrictions)
  9616  		if err == nil {
  9617  			return result, nil
  9618  		}
  9619  		if !isRepeatableError(err) {
  9620  			return result, err
  9621  		}
  9622  		tries++
  9623  		if tries >= 3 {
  9624  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9625  			return result, err
  9626  		}
  9627  	}
  9628  
  9629  }
  9630  
  9631  func (s *RetryLayerUserStore) GetProfilesWithoutTeam(options *model.UserGetOptions) ([]*model.User, error) {
  9632  
  9633  	tries := 0
  9634  	for {
  9635  		result, err := s.UserStore.GetProfilesWithoutTeam(options)
  9636  		if err == nil {
  9637  			return result, nil
  9638  		}
  9639  		if !isRepeatableError(err) {
  9640  			return result, err
  9641  		}
  9642  		tries++
  9643  		if tries >= 3 {
  9644  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9645  			return result, err
  9646  		}
  9647  	}
  9648  
  9649  }
  9650  
  9651  func (s *RetryLayerUserStore) GetRecentlyActiveUsersForTeam(teamId string, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, error) {
  9652  
  9653  	tries := 0
  9654  	for {
  9655  		result, err := s.UserStore.GetRecentlyActiveUsersForTeam(teamId, offset, limit, viewRestrictions)
  9656  		if err == nil {
  9657  			return result, nil
  9658  		}
  9659  		if !isRepeatableError(err) {
  9660  			return result, err
  9661  		}
  9662  		tries++
  9663  		if tries >= 3 {
  9664  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9665  			return result, err
  9666  		}
  9667  	}
  9668  
  9669  }
  9670  
  9671  func (s *RetryLayerUserStore) GetSystemAdminProfiles() (map[string]*model.User, error) {
  9672  
  9673  	tries := 0
  9674  	for {
  9675  		result, err := s.UserStore.GetSystemAdminProfiles()
  9676  		if err == nil {
  9677  			return result, nil
  9678  		}
  9679  		if !isRepeatableError(err) {
  9680  			return result, err
  9681  		}
  9682  		tries++
  9683  		if tries >= 3 {
  9684  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9685  			return result, err
  9686  		}
  9687  	}
  9688  
  9689  }
  9690  
  9691  func (s *RetryLayerUserStore) GetTeamGroupUsers(teamID string) ([]*model.User, error) {
  9692  
  9693  	tries := 0
  9694  	for {
  9695  		result, err := s.UserStore.GetTeamGroupUsers(teamID)
  9696  		if err == nil {
  9697  			return result, nil
  9698  		}
  9699  		if !isRepeatableError(err) {
  9700  			return result, err
  9701  		}
  9702  		tries++
  9703  		if tries >= 3 {
  9704  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9705  			return result, err
  9706  		}
  9707  	}
  9708  
  9709  }
  9710  
  9711  func (s *RetryLayerUserStore) GetUnreadCount(userId string) (int64, error) {
  9712  
  9713  	tries := 0
  9714  	for {
  9715  		result, err := s.UserStore.GetUnreadCount(userId)
  9716  		if err == nil {
  9717  			return result, nil
  9718  		}
  9719  		if !isRepeatableError(err) {
  9720  			return result, err
  9721  		}
  9722  		tries++
  9723  		if tries >= 3 {
  9724  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9725  			return result, err
  9726  		}
  9727  	}
  9728  
  9729  }
  9730  
  9731  func (s *RetryLayerUserStore) GetUnreadCountForChannel(userId string, channelId string) (int64, error) {
  9732  
  9733  	tries := 0
  9734  	for {
  9735  		result, err := s.UserStore.GetUnreadCountForChannel(userId, channelId)
  9736  		if err == nil {
  9737  			return result, nil
  9738  		}
  9739  		if !isRepeatableError(err) {
  9740  			return result, err
  9741  		}
  9742  		tries++
  9743  		if tries >= 3 {
  9744  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9745  			return result, err
  9746  		}
  9747  	}
  9748  
  9749  }
  9750  
  9751  func (s *RetryLayerUserStore) GetUsersBatchForIndexing(startTime int64, endTime int64, limit int) ([]*model.UserForIndexing, error) {
  9752  
  9753  	tries := 0
  9754  	for {
  9755  		result, err := s.UserStore.GetUsersBatchForIndexing(startTime, endTime, limit)
  9756  		if err == nil {
  9757  			return result, nil
  9758  		}
  9759  		if !isRepeatableError(err) {
  9760  			return result, err
  9761  		}
  9762  		tries++
  9763  		if tries >= 3 {
  9764  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9765  			return result, err
  9766  		}
  9767  	}
  9768  
  9769  }
  9770  
  9771  func (s *RetryLayerUserStore) InferSystemInstallDate() (int64, error) {
  9772  
  9773  	tries := 0
  9774  	for {
  9775  		result, err := s.UserStore.InferSystemInstallDate()
  9776  		if err == nil {
  9777  			return result, nil
  9778  		}
  9779  		if !isRepeatableError(err) {
  9780  			return result, err
  9781  		}
  9782  		tries++
  9783  		if tries >= 3 {
  9784  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9785  			return result, err
  9786  		}
  9787  	}
  9788  
  9789  }
  9790  
  9791  func (s *RetryLayerUserStore) InvalidateProfileCacheForUser(userId string) {
  9792  
  9793  	s.UserStore.InvalidateProfileCacheForUser(userId)
  9794  
  9795  }
  9796  
  9797  func (s *RetryLayerUserStore) InvalidateProfilesInChannelCache(channelId string) {
  9798  
  9799  	s.UserStore.InvalidateProfilesInChannelCache(channelId)
  9800  
  9801  }
  9802  
  9803  func (s *RetryLayerUserStore) InvalidateProfilesInChannelCacheByUser(userId string) {
  9804  
  9805  	s.UserStore.InvalidateProfilesInChannelCacheByUser(userId)
  9806  
  9807  }
  9808  
  9809  func (s *RetryLayerUserStore) PermanentDelete(userId string) error {
  9810  
  9811  	tries := 0
  9812  	for {
  9813  		err := s.UserStore.PermanentDelete(userId)
  9814  		if err == nil {
  9815  			return nil
  9816  		}
  9817  		if !isRepeatableError(err) {
  9818  			return err
  9819  		}
  9820  		tries++
  9821  		if tries >= 3 {
  9822  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9823  			return err
  9824  		}
  9825  	}
  9826  
  9827  }
  9828  
  9829  func (s *RetryLayerUserStore) PromoteGuestToUser(userID string) error {
  9830  
  9831  	tries := 0
  9832  	for {
  9833  		err := s.UserStore.PromoteGuestToUser(userID)
  9834  		if err == nil {
  9835  			return nil
  9836  		}
  9837  		if !isRepeatableError(err) {
  9838  			return err
  9839  		}
  9840  		tries++
  9841  		if tries >= 3 {
  9842  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9843  			return err
  9844  		}
  9845  	}
  9846  
  9847  }
  9848  
  9849  func (s *RetryLayerUserStore) ResetLastPictureUpdate(userId string) error {
  9850  
  9851  	tries := 0
  9852  	for {
  9853  		err := s.UserStore.ResetLastPictureUpdate(userId)
  9854  		if err == nil {
  9855  			return nil
  9856  		}
  9857  		if !isRepeatableError(err) {
  9858  			return err
  9859  		}
  9860  		tries++
  9861  		if tries >= 3 {
  9862  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9863  			return err
  9864  		}
  9865  	}
  9866  
  9867  }
  9868  
  9869  func (s *RetryLayerUserStore) Save(user *model.User) (*model.User, error) {
  9870  
  9871  	tries := 0
  9872  	for {
  9873  		result, err := s.UserStore.Save(user)
  9874  		if err == nil {
  9875  			return result, nil
  9876  		}
  9877  		if !isRepeatableError(err) {
  9878  			return result, err
  9879  		}
  9880  		tries++
  9881  		if tries >= 3 {
  9882  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9883  			return result, err
  9884  		}
  9885  	}
  9886  
  9887  }
  9888  
  9889  func (s *RetryLayerUserStore) Search(teamId string, term string, options *model.UserSearchOptions) ([]*model.User, error) {
  9890  
  9891  	tries := 0
  9892  	for {
  9893  		result, err := s.UserStore.Search(teamId, term, options)
  9894  		if err == nil {
  9895  			return result, nil
  9896  		}
  9897  		if !isRepeatableError(err) {
  9898  			return result, err
  9899  		}
  9900  		tries++
  9901  		if tries >= 3 {
  9902  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9903  			return result, err
  9904  		}
  9905  	}
  9906  
  9907  }
  9908  
  9909  func (s *RetryLayerUserStore) SearchInChannel(channelId string, term string, options *model.UserSearchOptions) ([]*model.User, error) {
  9910  
  9911  	tries := 0
  9912  	for {
  9913  		result, err := s.UserStore.SearchInChannel(channelId, term, options)
  9914  		if err == nil {
  9915  			return result, nil
  9916  		}
  9917  		if !isRepeatableError(err) {
  9918  			return result, err
  9919  		}
  9920  		tries++
  9921  		if tries >= 3 {
  9922  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9923  			return result, err
  9924  		}
  9925  	}
  9926  
  9927  }
  9928  
  9929  func (s *RetryLayerUserStore) SearchInGroup(groupID string, term string, options *model.UserSearchOptions) ([]*model.User, error) {
  9930  
  9931  	tries := 0
  9932  	for {
  9933  		result, err := s.UserStore.SearchInGroup(groupID, term, options)
  9934  		if err == nil {
  9935  			return result, nil
  9936  		}
  9937  		if !isRepeatableError(err) {
  9938  			return result, err
  9939  		}
  9940  		tries++
  9941  		if tries >= 3 {
  9942  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9943  			return result, err
  9944  		}
  9945  	}
  9946  
  9947  }
  9948  
  9949  func (s *RetryLayerUserStore) SearchNotInChannel(teamId string, channelId string, term string, options *model.UserSearchOptions) ([]*model.User, error) {
  9950  
  9951  	tries := 0
  9952  	for {
  9953  		result, err := s.UserStore.SearchNotInChannel(teamId, channelId, term, options)
  9954  		if err == nil {
  9955  			return result, nil
  9956  		}
  9957  		if !isRepeatableError(err) {
  9958  			return result, err
  9959  		}
  9960  		tries++
  9961  		if tries >= 3 {
  9962  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9963  			return result, err
  9964  		}
  9965  	}
  9966  
  9967  }
  9968  
  9969  func (s *RetryLayerUserStore) SearchNotInTeam(notInTeamId string, term string, options *model.UserSearchOptions) ([]*model.User, error) {
  9970  
  9971  	tries := 0
  9972  	for {
  9973  		result, err := s.UserStore.SearchNotInTeam(notInTeamId, term, options)
  9974  		if err == nil {
  9975  			return result, nil
  9976  		}
  9977  		if !isRepeatableError(err) {
  9978  			return result, err
  9979  		}
  9980  		tries++
  9981  		if tries >= 3 {
  9982  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
  9983  			return result, err
  9984  		}
  9985  	}
  9986  
  9987  }
  9988  
  9989  func (s *RetryLayerUserStore) SearchWithoutTeam(term string, options *model.UserSearchOptions) ([]*model.User, error) {
  9990  
  9991  	tries := 0
  9992  	for {
  9993  		result, err := s.UserStore.SearchWithoutTeam(term, options)
  9994  		if err == nil {
  9995  			return result, nil
  9996  		}
  9997  		if !isRepeatableError(err) {
  9998  			return result, err
  9999  		}
 10000  		tries++
 10001  		if tries >= 3 {
 10002  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10003  			return result, err
 10004  		}
 10005  	}
 10006  
 10007  }
 10008  
 10009  func (s *RetryLayerUserStore) Update(user *model.User, allowRoleUpdate bool) (*model.UserUpdate, error) {
 10010  
 10011  	tries := 0
 10012  	for {
 10013  		result, err := s.UserStore.Update(user, allowRoleUpdate)
 10014  		if err == nil {
 10015  			return result, nil
 10016  		}
 10017  		if !isRepeatableError(err) {
 10018  			return result, err
 10019  		}
 10020  		tries++
 10021  		if tries >= 3 {
 10022  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10023  			return result, err
 10024  		}
 10025  	}
 10026  
 10027  }
 10028  
 10029  func (s *RetryLayerUserStore) UpdateAuthData(userId string, service string, authData *string, email string, resetMfa bool) (string, error) {
 10030  
 10031  	tries := 0
 10032  	for {
 10033  		result, err := s.UserStore.UpdateAuthData(userId, service, authData, email, resetMfa)
 10034  		if err == nil {
 10035  			return result, nil
 10036  		}
 10037  		if !isRepeatableError(err) {
 10038  			return result, err
 10039  		}
 10040  		tries++
 10041  		if tries >= 3 {
 10042  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10043  			return result, err
 10044  		}
 10045  	}
 10046  
 10047  }
 10048  
 10049  func (s *RetryLayerUserStore) UpdateFailedPasswordAttempts(userId string, attempts int) error {
 10050  
 10051  	tries := 0
 10052  	for {
 10053  		err := s.UserStore.UpdateFailedPasswordAttempts(userId, attempts)
 10054  		if err == nil {
 10055  			return nil
 10056  		}
 10057  		if !isRepeatableError(err) {
 10058  			return err
 10059  		}
 10060  		tries++
 10061  		if tries >= 3 {
 10062  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10063  			return err
 10064  		}
 10065  	}
 10066  
 10067  }
 10068  
 10069  func (s *RetryLayerUserStore) UpdateLastPictureUpdate(userId string) error {
 10070  
 10071  	tries := 0
 10072  	for {
 10073  		err := s.UserStore.UpdateLastPictureUpdate(userId)
 10074  		if err == nil {
 10075  			return nil
 10076  		}
 10077  		if !isRepeatableError(err) {
 10078  			return err
 10079  		}
 10080  		tries++
 10081  		if tries >= 3 {
 10082  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10083  			return err
 10084  		}
 10085  	}
 10086  
 10087  }
 10088  
 10089  func (s *RetryLayerUserStore) UpdateMfaActive(userId string, active bool) error {
 10090  
 10091  	tries := 0
 10092  	for {
 10093  		err := s.UserStore.UpdateMfaActive(userId, active)
 10094  		if err == nil {
 10095  			return nil
 10096  		}
 10097  		if !isRepeatableError(err) {
 10098  			return err
 10099  		}
 10100  		tries++
 10101  		if tries >= 3 {
 10102  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10103  			return err
 10104  		}
 10105  	}
 10106  
 10107  }
 10108  
 10109  func (s *RetryLayerUserStore) UpdateMfaSecret(userId string, secret string) error {
 10110  
 10111  	tries := 0
 10112  	for {
 10113  		err := s.UserStore.UpdateMfaSecret(userId, secret)
 10114  		if err == nil {
 10115  			return nil
 10116  		}
 10117  		if !isRepeatableError(err) {
 10118  			return err
 10119  		}
 10120  		tries++
 10121  		if tries >= 3 {
 10122  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10123  			return err
 10124  		}
 10125  	}
 10126  
 10127  }
 10128  
 10129  func (s *RetryLayerUserStore) UpdatePassword(userId string, newPassword string) error {
 10130  
 10131  	tries := 0
 10132  	for {
 10133  		err := s.UserStore.UpdatePassword(userId, newPassword)
 10134  		if err == nil {
 10135  			return nil
 10136  		}
 10137  		if !isRepeatableError(err) {
 10138  			return err
 10139  		}
 10140  		tries++
 10141  		if tries >= 3 {
 10142  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10143  			return err
 10144  		}
 10145  	}
 10146  
 10147  }
 10148  
 10149  func (s *RetryLayerUserStore) UpdateUpdateAt(userId string) (int64, error) {
 10150  
 10151  	tries := 0
 10152  	for {
 10153  		result, err := s.UserStore.UpdateUpdateAt(userId)
 10154  		if err == nil {
 10155  			return result, nil
 10156  		}
 10157  		if !isRepeatableError(err) {
 10158  			return result, err
 10159  		}
 10160  		tries++
 10161  		if tries >= 3 {
 10162  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10163  			return result, err
 10164  		}
 10165  	}
 10166  
 10167  }
 10168  
 10169  func (s *RetryLayerUserStore) VerifyEmail(userId string, email string) (string, error) {
 10170  
 10171  	tries := 0
 10172  	for {
 10173  		result, err := s.UserStore.VerifyEmail(userId, email)
 10174  		if err == nil {
 10175  			return result, nil
 10176  		}
 10177  		if !isRepeatableError(err) {
 10178  			return result, err
 10179  		}
 10180  		tries++
 10181  		if tries >= 3 {
 10182  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10183  			return result, err
 10184  		}
 10185  	}
 10186  
 10187  }
 10188  
 10189  func (s *RetryLayerUserAccessTokenStore) Delete(tokenId string) error {
 10190  
 10191  	tries := 0
 10192  	for {
 10193  		err := s.UserAccessTokenStore.Delete(tokenId)
 10194  		if err == nil {
 10195  			return nil
 10196  		}
 10197  		if !isRepeatableError(err) {
 10198  			return err
 10199  		}
 10200  		tries++
 10201  		if tries >= 3 {
 10202  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10203  			return err
 10204  		}
 10205  	}
 10206  
 10207  }
 10208  
 10209  func (s *RetryLayerUserAccessTokenStore) DeleteAllForUser(userId string) error {
 10210  
 10211  	tries := 0
 10212  	for {
 10213  		err := s.UserAccessTokenStore.DeleteAllForUser(userId)
 10214  		if err == nil {
 10215  			return nil
 10216  		}
 10217  		if !isRepeatableError(err) {
 10218  			return err
 10219  		}
 10220  		tries++
 10221  		if tries >= 3 {
 10222  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10223  			return err
 10224  		}
 10225  	}
 10226  
 10227  }
 10228  
 10229  func (s *RetryLayerUserAccessTokenStore) Get(tokenId string) (*model.UserAccessToken, error) {
 10230  
 10231  	tries := 0
 10232  	for {
 10233  		result, err := s.UserAccessTokenStore.Get(tokenId)
 10234  		if err == nil {
 10235  			return result, nil
 10236  		}
 10237  		if !isRepeatableError(err) {
 10238  			return result, err
 10239  		}
 10240  		tries++
 10241  		if tries >= 3 {
 10242  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10243  			return result, err
 10244  		}
 10245  	}
 10246  
 10247  }
 10248  
 10249  func (s *RetryLayerUserAccessTokenStore) GetAll(offset int, limit int) ([]*model.UserAccessToken, error) {
 10250  
 10251  	tries := 0
 10252  	for {
 10253  		result, err := s.UserAccessTokenStore.GetAll(offset, limit)
 10254  		if err == nil {
 10255  			return result, nil
 10256  		}
 10257  		if !isRepeatableError(err) {
 10258  			return result, err
 10259  		}
 10260  		tries++
 10261  		if tries >= 3 {
 10262  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10263  			return result, err
 10264  		}
 10265  	}
 10266  
 10267  }
 10268  
 10269  func (s *RetryLayerUserAccessTokenStore) GetByToken(tokenString string) (*model.UserAccessToken, error) {
 10270  
 10271  	tries := 0
 10272  	for {
 10273  		result, err := s.UserAccessTokenStore.GetByToken(tokenString)
 10274  		if err == nil {
 10275  			return result, nil
 10276  		}
 10277  		if !isRepeatableError(err) {
 10278  			return result, err
 10279  		}
 10280  		tries++
 10281  		if tries >= 3 {
 10282  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10283  			return result, err
 10284  		}
 10285  	}
 10286  
 10287  }
 10288  
 10289  func (s *RetryLayerUserAccessTokenStore) GetByUser(userId string, page int, perPage int) ([]*model.UserAccessToken, error) {
 10290  
 10291  	tries := 0
 10292  	for {
 10293  		result, err := s.UserAccessTokenStore.GetByUser(userId, page, perPage)
 10294  		if err == nil {
 10295  			return result, nil
 10296  		}
 10297  		if !isRepeatableError(err) {
 10298  			return result, err
 10299  		}
 10300  		tries++
 10301  		if tries >= 3 {
 10302  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10303  			return result, err
 10304  		}
 10305  	}
 10306  
 10307  }
 10308  
 10309  func (s *RetryLayerUserAccessTokenStore) Save(token *model.UserAccessToken) (*model.UserAccessToken, error) {
 10310  
 10311  	tries := 0
 10312  	for {
 10313  		result, err := s.UserAccessTokenStore.Save(token)
 10314  		if err == nil {
 10315  			return result, nil
 10316  		}
 10317  		if !isRepeatableError(err) {
 10318  			return result, err
 10319  		}
 10320  		tries++
 10321  		if tries >= 3 {
 10322  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10323  			return result, err
 10324  		}
 10325  	}
 10326  
 10327  }
 10328  
 10329  func (s *RetryLayerUserAccessTokenStore) Search(term string) ([]*model.UserAccessToken, error) {
 10330  
 10331  	tries := 0
 10332  	for {
 10333  		result, err := s.UserAccessTokenStore.Search(term)
 10334  		if err == nil {
 10335  			return result, nil
 10336  		}
 10337  		if !isRepeatableError(err) {
 10338  			return result, err
 10339  		}
 10340  		tries++
 10341  		if tries >= 3 {
 10342  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10343  			return result, err
 10344  		}
 10345  	}
 10346  
 10347  }
 10348  
 10349  func (s *RetryLayerUserAccessTokenStore) UpdateTokenDisable(tokenId string) error {
 10350  
 10351  	tries := 0
 10352  	for {
 10353  		err := s.UserAccessTokenStore.UpdateTokenDisable(tokenId)
 10354  		if err == nil {
 10355  			return nil
 10356  		}
 10357  		if !isRepeatableError(err) {
 10358  			return err
 10359  		}
 10360  		tries++
 10361  		if tries >= 3 {
 10362  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10363  			return err
 10364  		}
 10365  	}
 10366  
 10367  }
 10368  
 10369  func (s *RetryLayerUserAccessTokenStore) UpdateTokenEnable(tokenId string) error {
 10370  
 10371  	tries := 0
 10372  	for {
 10373  		err := s.UserAccessTokenStore.UpdateTokenEnable(tokenId)
 10374  		if err == nil {
 10375  			return nil
 10376  		}
 10377  		if !isRepeatableError(err) {
 10378  			return err
 10379  		}
 10380  		tries++
 10381  		if tries >= 3 {
 10382  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10383  			return err
 10384  		}
 10385  	}
 10386  
 10387  }
 10388  
 10389  func (s *RetryLayerUserTermsOfServiceStore) Delete(userId string, termsOfServiceId string) error {
 10390  
 10391  	tries := 0
 10392  	for {
 10393  		err := s.UserTermsOfServiceStore.Delete(userId, termsOfServiceId)
 10394  		if err == nil {
 10395  			return nil
 10396  		}
 10397  		if !isRepeatableError(err) {
 10398  			return err
 10399  		}
 10400  		tries++
 10401  		if tries >= 3 {
 10402  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10403  			return err
 10404  		}
 10405  	}
 10406  
 10407  }
 10408  
 10409  func (s *RetryLayerUserTermsOfServiceStore) GetByUser(userId string) (*model.UserTermsOfService, error) {
 10410  
 10411  	tries := 0
 10412  	for {
 10413  		result, err := s.UserTermsOfServiceStore.GetByUser(userId)
 10414  		if err == nil {
 10415  			return result, nil
 10416  		}
 10417  		if !isRepeatableError(err) {
 10418  			return result, err
 10419  		}
 10420  		tries++
 10421  		if tries >= 3 {
 10422  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10423  			return result, err
 10424  		}
 10425  	}
 10426  
 10427  }
 10428  
 10429  func (s *RetryLayerUserTermsOfServiceStore) Save(userTermsOfService *model.UserTermsOfService) (*model.UserTermsOfService, error) {
 10430  
 10431  	tries := 0
 10432  	for {
 10433  		result, err := s.UserTermsOfServiceStore.Save(userTermsOfService)
 10434  		if err == nil {
 10435  			return result, nil
 10436  		}
 10437  		if !isRepeatableError(err) {
 10438  			return result, err
 10439  		}
 10440  		tries++
 10441  		if tries >= 3 {
 10442  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10443  			return result, err
 10444  		}
 10445  	}
 10446  
 10447  }
 10448  
 10449  func (s *RetryLayerWebhookStore) AnalyticsIncomingCount(teamId string) (int64, error) {
 10450  
 10451  	tries := 0
 10452  	for {
 10453  		result, err := s.WebhookStore.AnalyticsIncomingCount(teamId)
 10454  		if err == nil {
 10455  			return result, nil
 10456  		}
 10457  		if !isRepeatableError(err) {
 10458  			return result, err
 10459  		}
 10460  		tries++
 10461  		if tries >= 3 {
 10462  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10463  			return result, err
 10464  		}
 10465  	}
 10466  
 10467  }
 10468  
 10469  func (s *RetryLayerWebhookStore) AnalyticsOutgoingCount(teamId string) (int64, error) {
 10470  
 10471  	tries := 0
 10472  	for {
 10473  		result, err := s.WebhookStore.AnalyticsOutgoingCount(teamId)
 10474  		if err == nil {
 10475  			return result, nil
 10476  		}
 10477  		if !isRepeatableError(err) {
 10478  			return result, err
 10479  		}
 10480  		tries++
 10481  		if tries >= 3 {
 10482  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10483  			return result, err
 10484  		}
 10485  	}
 10486  
 10487  }
 10488  
 10489  func (s *RetryLayerWebhookStore) ClearCaches() {
 10490  
 10491  	s.WebhookStore.ClearCaches()
 10492  
 10493  }
 10494  
 10495  func (s *RetryLayerWebhookStore) DeleteIncoming(webhookId string, time int64) error {
 10496  
 10497  	tries := 0
 10498  	for {
 10499  		err := s.WebhookStore.DeleteIncoming(webhookId, time)
 10500  		if err == nil {
 10501  			return nil
 10502  		}
 10503  		if !isRepeatableError(err) {
 10504  			return err
 10505  		}
 10506  		tries++
 10507  		if tries >= 3 {
 10508  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10509  			return err
 10510  		}
 10511  	}
 10512  
 10513  }
 10514  
 10515  func (s *RetryLayerWebhookStore) DeleteOutgoing(webhookId string, time int64) error {
 10516  
 10517  	tries := 0
 10518  	for {
 10519  		err := s.WebhookStore.DeleteOutgoing(webhookId, time)
 10520  		if err == nil {
 10521  			return nil
 10522  		}
 10523  		if !isRepeatableError(err) {
 10524  			return err
 10525  		}
 10526  		tries++
 10527  		if tries >= 3 {
 10528  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10529  			return err
 10530  		}
 10531  	}
 10532  
 10533  }
 10534  
 10535  func (s *RetryLayerWebhookStore) GetIncoming(id string, allowFromCache bool) (*model.IncomingWebhook, error) {
 10536  
 10537  	tries := 0
 10538  	for {
 10539  		result, err := s.WebhookStore.GetIncoming(id, allowFromCache)
 10540  		if err == nil {
 10541  			return result, nil
 10542  		}
 10543  		if !isRepeatableError(err) {
 10544  			return result, err
 10545  		}
 10546  		tries++
 10547  		if tries >= 3 {
 10548  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10549  			return result, err
 10550  		}
 10551  	}
 10552  
 10553  }
 10554  
 10555  func (s *RetryLayerWebhookStore) GetIncomingByChannel(channelId string) ([]*model.IncomingWebhook, error) {
 10556  
 10557  	tries := 0
 10558  	for {
 10559  		result, err := s.WebhookStore.GetIncomingByChannel(channelId)
 10560  		if err == nil {
 10561  			return result, nil
 10562  		}
 10563  		if !isRepeatableError(err) {
 10564  			return result, err
 10565  		}
 10566  		tries++
 10567  		if tries >= 3 {
 10568  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10569  			return result, err
 10570  		}
 10571  	}
 10572  
 10573  }
 10574  
 10575  func (s *RetryLayerWebhookStore) GetIncomingByTeam(teamId string, offset int, limit int) ([]*model.IncomingWebhook, error) {
 10576  
 10577  	tries := 0
 10578  	for {
 10579  		result, err := s.WebhookStore.GetIncomingByTeam(teamId, offset, limit)
 10580  		if err == nil {
 10581  			return result, nil
 10582  		}
 10583  		if !isRepeatableError(err) {
 10584  			return result, err
 10585  		}
 10586  		tries++
 10587  		if tries >= 3 {
 10588  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10589  			return result, err
 10590  		}
 10591  	}
 10592  
 10593  }
 10594  
 10595  func (s *RetryLayerWebhookStore) GetIncomingByTeamByUser(teamId string, userId string, offset int, limit int) ([]*model.IncomingWebhook, error) {
 10596  
 10597  	tries := 0
 10598  	for {
 10599  		result, err := s.WebhookStore.GetIncomingByTeamByUser(teamId, userId, offset, limit)
 10600  		if err == nil {
 10601  			return result, nil
 10602  		}
 10603  		if !isRepeatableError(err) {
 10604  			return result, err
 10605  		}
 10606  		tries++
 10607  		if tries >= 3 {
 10608  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10609  			return result, err
 10610  		}
 10611  	}
 10612  
 10613  }
 10614  
 10615  func (s *RetryLayerWebhookStore) GetIncomingList(offset int, limit int) ([]*model.IncomingWebhook, error) {
 10616  
 10617  	tries := 0
 10618  	for {
 10619  		result, err := s.WebhookStore.GetIncomingList(offset, limit)
 10620  		if err == nil {
 10621  			return result, nil
 10622  		}
 10623  		if !isRepeatableError(err) {
 10624  			return result, err
 10625  		}
 10626  		tries++
 10627  		if tries >= 3 {
 10628  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10629  			return result, err
 10630  		}
 10631  	}
 10632  
 10633  }
 10634  
 10635  func (s *RetryLayerWebhookStore) GetIncomingListByUser(userId string, offset int, limit int) ([]*model.IncomingWebhook, error) {
 10636  
 10637  	tries := 0
 10638  	for {
 10639  		result, err := s.WebhookStore.GetIncomingListByUser(userId, offset, limit)
 10640  		if err == nil {
 10641  			return result, nil
 10642  		}
 10643  		if !isRepeatableError(err) {
 10644  			return result, err
 10645  		}
 10646  		tries++
 10647  		if tries >= 3 {
 10648  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10649  			return result, err
 10650  		}
 10651  	}
 10652  
 10653  }
 10654  
 10655  func (s *RetryLayerWebhookStore) GetOutgoing(id string) (*model.OutgoingWebhook, error) {
 10656  
 10657  	tries := 0
 10658  	for {
 10659  		result, err := s.WebhookStore.GetOutgoing(id)
 10660  		if err == nil {
 10661  			return result, nil
 10662  		}
 10663  		if !isRepeatableError(err) {
 10664  			return result, err
 10665  		}
 10666  		tries++
 10667  		if tries >= 3 {
 10668  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10669  			return result, err
 10670  		}
 10671  	}
 10672  
 10673  }
 10674  
 10675  func (s *RetryLayerWebhookStore) GetOutgoingByChannel(channelId string, offset int, limit int) ([]*model.OutgoingWebhook, error) {
 10676  
 10677  	tries := 0
 10678  	for {
 10679  		result, err := s.WebhookStore.GetOutgoingByChannel(channelId, offset, limit)
 10680  		if err == nil {
 10681  			return result, nil
 10682  		}
 10683  		if !isRepeatableError(err) {
 10684  			return result, err
 10685  		}
 10686  		tries++
 10687  		if tries >= 3 {
 10688  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10689  			return result, err
 10690  		}
 10691  	}
 10692  
 10693  }
 10694  
 10695  func (s *RetryLayerWebhookStore) GetOutgoingByChannelByUser(channelId string, userId string, offset int, limit int) ([]*model.OutgoingWebhook, error) {
 10696  
 10697  	tries := 0
 10698  	for {
 10699  		result, err := s.WebhookStore.GetOutgoingByChannelByUser(channelId, userId, offset, limit)
 10700  		if err == nil {
 10701  			return result, nil
 10702  		}
 10703  		if !isRepeatableError(err) {
 10704  			return result, err
 10705  		}
 10706  		tries++
 10707  		if tries >= 3 {
 10708  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10709  			return result, err
 10710  		}
 10711  	}
 10712  
 10713  }
 10714  
 10715  func (s *RetryLayerWebhookStore) GetOutgoingByTeam(teamId string, offset int, limit int) ([]*model.OutgoingWebhook, error) {
 10716  
 10717  	tries := 0
 10718  	for {
 10719  		result, err := s.WebhookStore.GetOutgoingByTeam(teamId, offset, limit)
 10720  		if err == nil {
 10721  			return result, nil
 10722  		}
 10723  		if !isRepeatableError(err) {
 10724  			return result, err
 10725  		}
 10726  		tries++
 10727  		if tries >= 3 {
 10728  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10729  			return result, err
 10730  		}
 10731  	}
 10732  
 10733  }
 10734  
 10735  func (s *RetryLayerWebhookStore) GetOutgoingByTeamByUser(teamId string, userId string, offset int, limit int) ([]*model.OutgoingWebhook, error) {
 10736  
 10737  	tries := 0
 10738  	for {
 10739  		result, err := s.WebhookStore.GetOutgoingByTeamByUser(teamId, userId, offset, limit)
 10740  		if err == nil {
 10741  			return result, nil
 10742  		}
 10743  		if !isRepeatableError(err) {
 10744  			return result, err
 10745  		}
 10746  		tries++
 10747  		if tries >= 3 {
 10748  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10749  			return result, err
 10750  		}
 10751  	}
 10752  
 10753  }
 10754  
 10755  func (s *RetryLayerWebhookStore) GetOutgoingList(offset int, limit int) ([]*model.OutgoingWebhook, error) {
 10756  
 10757  	tries := 0
 10758  	for {
 10759  		result, err := s.WebhookStore.GetOutgoingList(offset, limit)
 10760  		if err == nil {
 10761  			return result, nil
 10762  		}
 10763  		if !isRepeatableError(err) {
 10764  			return result, err
 10765  		}
 10766  		tries++
 10767  		if tries >= 3 {
 10768  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10769  			return result, err
 10770  		}
 10771  	}
 10772  
 10773  }
 10774  
 10775  func (s *RetryLayerWebhookStore) GetOutgoingListByUser(userId string, offset int, limit int) ([]*model.OutgoingWebhook, error) {
 10776  
 10777  	tries := 0
 10778  	for {
 10779  		result, err := s.WebhookStore.GetOutgoingListByUser(userId, offset, limit)
 10780  		if err == nil {
 10781  			return result, nil
 10782  		}
 10783  		if !isRepeatableError(err) {
 10784  			return result, err
 10785  		}
 10786  		tries++
 10787  		if tries >= 3 {
 10788  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10789  			return result, err
 10790  		}
 10791  	}
 10792  
 10793  }
 10794  
 10795  func (s *RetryLayerWebhookStore) InvalidateWebhookCache(webhook string) {
 10796  
 10797  	s.WebhookStore.InvalidateWebhookCache(webhook)
 10798  
 10799  }
 10800  
 10801  func (s *RetryLayerWebhookStore) PermanentDeleteIncomingByChannel(channelId string) error {
 10802  
 10803  	tries := 0
 10804  	for {
 10805  		err := s.WebhookStore.PermanentDeleteIncomingByChannel(channelId)
 10806  		if err == nil {
 10807  			return nil
 10808  		}
 10809  		if !isRepeatableError(err) {
 10810  			return err
 10811  		}
 10812  		tries++
 10813  		if tries >= 3 {
 10814  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10815  			return err
 10816  		}
 10817  	}
 10818  
 10819  }
 10820  
 10821  func (s *RetryLayerWebhookStore) PermanentDeleteIncomingByUser(userId string) error {
 10822  
 10823  	tries := 0
 10824  	for {
 10825  		err := s.WebhookStore.PermanentDeleteIncomingByUser(userId)
 10826  		if err == nil {
 10827  			return nil
 10828  		}
 10829  		if !isRepeatableError(err) {
 10830  			return err
 10831  		}
 10832  		tries++
 10833  		if tries >= 3 {
 10834  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10835  			return err
 10836  		}
 10837  	}
 10838  
 10839  }
 10840  
 10841  func (s *RetryLayerWebhookStore) PermanentDeleteOutgoingByChannel(channelId string) error {
 10842  
 10843  	tries := 0
 10844  	for {
 10845  		err := s.WebhookStore.PermanentDeleteOutgoingByChannel(channelId)
 10846  		if err == nil {
 10847  			return nil
 10848  		}
 10849  		if !isRepeatableError(err) {
 10850  			return err
 10851  		}
 10852  		tries++
 10853  		if tries >= 3 {
 10854  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10855  			return err
 10856  		}
 10857  	}
 10858  
 10859  }
 10860  
 10861  func (s *RetryLayerWebhookStore) PermanentDeleteOutgoingByUser(userId string) error {
 10862  
 10863  	tries := 0
 10864  	for {
 10865  		err := s.WebhookStore.PermanentDeleteOutgoingByUser(userId)
 10866  		if err == nil {
 10867  			return nil
 10868  		}
 10869  		if !isRepeatableError(err) {
 10870  			return err
 10871  		}
 10872  		tries++
 10873  		if tries >= 3 {
 10874  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10875  			return err
 10876  		}
 10877  	}
 10878  
 10879  }
 10880  
 10881  func (s *RetryLayerWebhookStore) SaveIncoming(webhook *model.IncomingWebhook) (*model.IncomingWebhook, error) {
 10882  
 10883  	tries := 0
 10884  	for {
 10885  		result, err := s.WebhookStore.SaveIncoming(webhook)
 10886  		if err == nil {
 10887  			return result, nil
 10888  		}
 10889  		if !isRepeatableError(err) {
 10890  			return result, err
 10891  		}
 10892  		tries++
 10893  		if tries >= 3 {
 10894  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10895  			return result, err
 10896  		}
 10897  	}
 10898  
 10899  }
 10900  
 10901  func (s *RetryLayerWebhookStore) SaveOutgoing(webhook *model.OutgoingWebhook) (*model.OutgoingWebhook, error) {
 10902  
 10903  	tries := 0
 10904  	for {
 10905  		result, err := s.WebhookStore.SaveOutgoing(webhook)
 10906  		if err == nil {
 10907  			return result, nil
 10908  		}
 10909  		if !isRepeatableError(err) {
 10910  			return result, err
 10911  		}
 10912  		tries++
 10913  		if tries >= 3 {
 10914  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10915  			return result, err
 10916  		}
 10917  	}
 10918  
 10919  }
 10920  
 10921  func (s *RetryLayerWebhookStore) UpdateIncoming(webhook *model.IncomingWebhook) (*model.IncomingWebhook, error) {
 10922  
 10923  	tries := 0
 10924  	for {
 10925  		result, err := s.WebhookStore.UpdateIncoming(webhook)
 10926  		if err == nil {
 10927  			return result, nil
 10928  		}
 10929  		if !isRepeatableError(err) {
 10930  			return result, err
 10931  		}
 10932  		tries++
 10933  		if tries >= 3 {
 10934  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10935  			return result, err
 10936  		}
 10937  	}
 10938  
 10939  }
 10940  
 10941  func (s *RetryLayerWebhookStore) UpdateOutgoing(hook *model.OutgoingWebhook) (*model.OutgoingWebhook, error) {
 10942  
 10943  	tries := 0
 10944  	for {
 10945  		result, err := s.WebhookStore.UpdateOutgoing(hook)
 10946  		if err == nil {
 10947  			return result, nil
 10948  		}
 10949  		if !isRepeatableError(err) {
 10950  			return result, err
 10951  		}
 10952  		tries++
 10953  		if tries >= 3 {
 10954  			err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
 10955  			return result, err
 10956  		}
 10957  	}
 10958  
 10959  }
 10960  
 10961  func (s *RetryLayer) Close() {
 10962  	s.Store.Close()
 10963  }
 10964  
 10965  func (s *RetryLayer) DropAllTables() {
 10966  	s.Store.DropAllTables()
 10967  }
 10968  
 10969  func (s *RetryLayer) GetCurrentSchemaVersion() string {
 10970  	return s.Store.GetCurrentSchemaVersion()
 10971  }
 10972  
 10973  func (s *RetryLayer) LockToMaster() {
 10974  	s.Store.LockToMaster()
 10975  }
 10976  
 10977  func (s *RetryLayer) MarkSystemRanUnitTests() {
 10978  	s.Store.MarkSystemRanUnitTests()
 10979  }
 10980  
 10981  func (s *RetryLayer) SetContext(context context.Context) {
 10982  	s.Store.SetContext(context)
 10983  }
 10984  
 10985  func (s *RetryLayer) TotalMasterDbConnections() int {
 10986  	return s.Store.TotalMasterDbConnections()
 10987  }
 10988  
 10989  func (s *RetryLayer) TotalReadDbConnections() int {
 10990  	return s.Store.TotalReadDbConnections()
 10991  }
 10992  
 10993  func (s *RetryLayer) TotalSearchDbConnections() int {
 10994  	return s.Store.TotalSearchDbConnections()
 10995  }
 10996  
 10997  func (s *RetryLayer) UnlockFromMaster() {
 10998  	s.Store.UnlockFromMaster()
 10999  }
 11000  
 11001  func New(childStore store.Store) *RetryLayer {
 11002  	newStore := RetryLayer{
 11003  		Store: childStore,
 11004  	}
 11005  
 11006  	newStore.AuditStore = &RetryLayerAuditStore{AuditStore: childStore.Audit(), Root: &newStore}
 11007  	newStore.BotStore = &RetryLayerBotStore{BotStore: childStore.Bot(), Root: &newStore}
 11008  	newStore.ChannelStore = &RetryLayerChannelStore{ChannelStore: childStore.Channel(), Root: &newStore}
 11009  	newStore.ChannelMemberHistoryStore = &RetryLayerChannelMemberHistoryStore{ChannelMemberHistoryStore: childStore.ChannelMemberHistory(), Root: &newStore}
 11010  	newStore.ClusterDiscoveryStore = &RetryLayerClusterDiscoveryStore{ClusterDiscoveryStore: childStore.ClusterDiscovery(), Root: &newStore}
 11011  	newStore.CommandStore = &RetryLayerCommandStore{CommandStore: childStore.Command(), Root: &newStore}
 11012  	newStore.CommandWebhookStore = &RetryLayerCommandWebhookStore{CommandWebhookStore: childStore.CommandWebhook(), Root: &newStore}
 11013  	newStore.ComplianceStore = &RetryLayerComplianceStore{ComplianceStore: childStore.Compliance(), Root: &newStore}
 11014  	newStore.EmojiStore = &RetryLayerEmojiStore{EmojiStore: childStore.Emoji(), Root: &newStore}
 11015  	newStore.FileInfoStore = &RetryLayerFileInfoStore{FileInfoStore: childStore.FileInfo(), Root: &newStore}
 11016  	newStore.GroupStore = &RetryLayerGroupStore{GroupStore: childStore.Group(), Root: &newStore}
 11017  	newStore.JobStore = &RetryLayerJobStore{JobStore: childStore.Job(), Root: &newStore}
 11018  	newStore.LicenseStore = &RetryLayerLicenseStore{LicenseStore: childStore.License(), Root: &newStore}
 11019  	newStore.LinkMetadataStore = &RetryLayerLinkMetadataStore{LinkMetadataStore: childStore.LinkMetadata(), Root: &newStore}
 11020  	newStore.OAuthStore = &RetryLayerOAuthStore{OAuthStore: childStore.OAuth(), Root: &newStore}
 11021  	newStore.PluginStore = &RetryLayerPluginStore{PluginStore: childStore.Plugin(), Root: &newStore}
 11022  	newStore.PostStore = &RetryLayerPostStore{PostStore: childStore.Post(), Root: &newStore}
 11023  	newStore.PreferenceStore = &RetryLayerPreferenceStore{PreferenceStore: childStore.Preference(), Root: &newStore}
 11024  	newStore.ProductNoticesStore = &RetryLayerProductNoticesStore{ProductNoticesStore: childStore.ProductNotices(), Root: &newStore}
 11025  	newStore.ReactionStore = &RetryLayerReactionStore{ReactionStore: childStore.Reaction(), Root: &newStore}
 11026  	newStore.RoleStore = &RetryLayerRoleStore{RoleStore: childStore.Role(), Root: &newStore}
 11027  	newStore.SchemeStore = &RetryLayerSchemeStore{SchemeStore: childStore.Scheme(), Root: &newStore}
 11028  	newStore.SessionStore = &RetryLayerSessionStore{SessionStore: childStore.Session(), Root: &newStore}
 11029  	newStore.StatusStore = &RetryLayerStatusStore{StatusStore: childStore.Status(), Root: &newStore}
 11030  	newStore.SystemStore = &RetryLayerSystemStore{SystemStore: childStore.System(), Root: &newStore}
 11031  	newStore.TeamStore = &RetryLayerTeamStore{TeamStore: childStore.Team(), Root: &newStore}
 11032  	newStore.TermsOfServiceStore = &RetryLayerTermsOfServiceStore{TermsOfServiceStore: childStore.TermsOfService(), Root: &newStore}
 11033  	newStore.ThreadStore = &RetryLayerThreadStore{ThreadStore: childStore.Thread(), Root: &newStore}
 11034  	newStore.TokenStore = &RetryLayerTokenStore{TokenStore: childStore.Token(), Root: &newStore}
 11035  	newStore.UploadSessionStore = &RetryLayerUploadSessionStore{UploadSessionStore: childStore.UploadSession(), Root: &newStore}
 11036  	newStore.UserStore = &RetryLayerUserStore{UserStore: childStore.User(), Root: &newStore}
 11037  	newStore.UserAccessTokenStore = &RetryLayerUserAccessTokenStore{UserAccessTokenStore: childStore.UserAccessToken(), Root: &newStore}
 11038  	newStore.UserTermsOfServiceStore = &RetryLayerUserTermsOfServiceStore{UserTermsOfServiceStore: childStore.UserTermsOfService(), Root: &newStore}
 11039  	newStore.WebhookStore = &RetryLayerWebhookStore{WebhookStore: childStore.Webhook(), Root: &newStore}
 11040  	return &newStore
 11041  }