Class: ApplicationRecord
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ApplicationRecord
- Includes:
- NilifyBlanks
- Defined in:
- app/models/application_record.rb
Direct Known Subclasses
AlternateValue, AssertedDistribution, Attribution, BiocurationClassification, BiologicalAssociation, BiologicalAssociationsBiologicalAssociationsGraph, BiologicalAssociationsGraph, BiologicalRelationship, BiologicalRelationshipType, CachedMap, CachedMapItem, CachedMapItemTranslation, CachedMapRegister, CharacterState, Citation, CitationTopic, CollectingEvent, CollectionObject, CollectionObjectObservation, CollectionProfile, CommonName, Confidence, Container, ContainerItem, Content, ControlledVocabularyTerm, DataAttribute, DatasetRecord, DatasetRecordField, Depiction, DerivedCollectionObject, Descriptor, Document, Documentation, Download, DwcOccurrence, Extract, FieldOccurrence, GeneAttribute, GeographicArea, GeographicAreaType, GeographicAreasGeographicItem, GeographicItem, Georeference, Identifier, Image, Import, ImportDataset, Label, Language, Lead, Loan, LoanItem, Namespace, Note, Observation, ObservationMatrix, ObservationMatrixColumn, ObservationMatrixColumnItem, ObservationMatrixRow, ObservationMatrixRowItem, Organization, OriginRelationship, Otu, OtuPageLayout, OtuPageLayoutSection, OtuRelationship, Person, PinboardItem, PreparationType, Project, ProjectMember, ProjectSource, Protocol, ProtocolRelationship, PublicContent, RangedLotCategory, Repository, Role, Sequence, SequenceRelationship, Serial, SerialChronology, SledImage, Source, SqedDepiction, Tag, TaggedSectionKeyword, TaxonDetermination, TaxonName, TaxonNameClassification, TaxonNameRelationship, TypeMaterial, User
Class Method Summary collapse
-
.transaction_with_retry(&block) ⇒ Object
Will run block on transaction, repeating 3 times if failed due to ActiveRecord:DeadLock exception.
Class Method Details
.transaction_with_retry(&block) ⇒ Object
Will run block on transaction, repeating 3 times if failed due to ActiveRecord:DeadLock exception.
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/models/application_record.rb', line 13 def self.transaction_with_retry(&block) retry_count = 0 begin transaction &block rescue ActiveRecord::Deadlocked raise if retry_count > 3 # Exponential backoff with proportional random wait time. sleep 2**(retry_count)*(1+rand) retry_count += 1 retry end end |