Skip to content

Commit c6a6bc7

Browse files
authored
Drop FKs referencing DomainHistory (#2621)
- We never delete rows from DomainHistory (and even if we do in the future, they'll be old / the references won't matter) - This is likely creating lock contention when lots of requests come through at once for domains with many DomainHistory entries
1 parent fce126d commit c6a6bc7

19 files changed

+4925
-5621
lines changed

core/src/main/java/google/registry/model/billing/BillingCancellation.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,11 @@
4545
@Index(columnList = "eventTime"),
4646
@Index(columnList = "domainRepoId"),
4747
@Index(columnList = "billingTime"),
48-
@Index(columnList = "billing_event_id"),
49-
@Index(columnList = "billing_recurrence_id")
48+
@Index(columnList = "billingEventId"),
49+
@Index(columnList = "billingRecurrenceId"),
50+
@Index(columnList = "domainRepoId,domainHistoryRevisionId")
5051
})
51-
@AttributeOverride(name = "id", column = @Column(name = "billing_cancellation_id"))
52+
@AttributeOverride(name = "id", column = @Column(name = "billingCancellationId"))
5253
@WithVKey(Long.class)
5354
public class BillingCancellation extends BillingBase {
5455

core/src/main/java/google/registry/model/billing/BillingEvent.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@
4242
@Index(columnList = "syntheticCreationTime"),
4343
@Index(columnList = "domainRepoId"),
4444
@Index(columnList = "allocationToken"),
45-
@Index(columnList = "cancellation_matching_billing_recurrence_id")
45+
@Index(columnList = "cancellationMatchingBillingRecurrenceId"),
46+
@Index(columnList = "domainRepoId,domainHistoryRevisionId"),
47+
@Index(columnList = "domainRepoId,recurrenceHistoryRevisionId")
4648
})
4749
@AttributeOverride(name = "id", column = @Column(name = "billing_event_id"))
4850
@WithVKey(Long.class)

core/src/main/java/google/registry/model/billing/BillingRecurrence.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
@Index(columnList = "domainRepoId"),
5151
@Index(columnList = "recurrenceEndTime"),
5252
@Index(columnList = "recurrenceLastExpansion"),
53-
@Index(columnList = "recurrence_time_of_year")
53+
@Index(columnList = "recurrenceTimeOfYear"),
54+
@Index(columnList = "domainRepoId,domainHistoryRevisionId")
5455
})
5556
@AttributeOverride(name = "id", column = @Column(name = "billing_recurrence_id"))
5657
@WithVKey(Long.class)

core/src/main/java/google/registry/model/domain/GracePeriod.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,11 @@ public static GracePeriod forBillingEvent(
180180

181181
/** Entity class to represent a historic {@link GracePeriod}. */
182182
@Entity(name = "GracePeriodHistory")
183-
@Table(indexes = @Index(columnList = "domainRepoId"))
183+
@Table(
184+
indexes = {
185+
@Index(columnList = "domainRepoId"),
186+
@Index(columnList = "domainRepoId,domainHistoryRevisionId")
187+
})
184188
public static class GracePeriodHistory extends GracePeriodBase {
185189
@Id Long gracePeriodHistoryRevisionId;
186190

core/src/main/java/google/registry/model/domain/secdns/DomainDsDataHistory.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@
2323
import jakarta.persistence.Column;
2424
import jakarta.persistence.Entity;
2525
import jakarta.persistence.Id;
26+
import jakarta.persistence.Index;
27+
import jakarta.persistence.Table;
2628

2729
/** Entity class to represent a historic {@link DomainDsData}. */
2830
@Entity
31+
@Table(indexes = @Index(columnList = "domainRepoId,domainHistoryRevisionId"))
2932
public class DomainDsDataHistory extends DomainDsDataBase {
3033

3134
@Id Long dsDataHistoryRevisionId;

core/src/main/java/google/registry/model/poll/PollMessage.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,9 @@
8989
@Table(
9090
indexes = {
9191
@Index(columnList = "domainRepoId"),
92-
@Index(columnList = "registrar_id"),
93-
@Index(columnList = "eventTime")
92+
@Index(columnList = "registrarId"),
93+
@Index(columnList = "eventTime"),
94+
@Index(columnList = "domainRepoId,domainHistoryRevisionId")
9495
})
9596
public abstract class PollMessage extends ImmutableObject
9697
implements Buildable, TransferServerApproveEntity, UnsafeSerializable {

core/src/main/java/google/registry/model/reporting/DomainTransactionRecord.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
import jakarta.persistence.GeneratedValue;
3030
import jakarta.persistence.GenerationType;
3131
import jakarta.persistence.Id;
32+
import jakarta.persistence.Index;
33+
import jakarta.persistence.Table;
3234
import org.joda.time.DateTime;
3335

3436
/**
@@ -42,6 +44,7 @@
4244
* uses HistoryEntry.otherClientId because the losing party in a transfer is always the otherClient.
4345
*/
4446
@Entity
47+
@Table(indexes = @Index(columnList = "domainRepoId,historyRevisionId"))
4548
public class DomainTransactionRecord extends ImmutableObject
4649
implements Buildable, UnsafeSerializable {
4750

db/src/main/resources/sql/er_diagram/brief_er_diagram.html

Lines changed: 1484 additions & 1976 deletions
Large diffs are not rendered by default.

db/src/main/resources/sql/er_diagram/full_er_diagram.html

Lines changed: 3212 additions & 3568 deletions
Large diffs are not rendered by default.

db/src/main/resources/sql/flyway.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,10 @@ V176__drop_login_email_address_column_from_registrar_poc.sql
177177
V177__drop_user_id.sql
178178
V178__drop_user_id_history.sql
179179
V179__add_discount_price_allocation_token.sql
180+
V180__remove_fk_graceperiodhistory_domainhistory.sql
181+
V181__remove_fk_billingcancellation_domainhistory.sql
182+
V182__remove_fk_billingevent_domainhistory.sql
183+
V183__remove_fk_billingrecurrence_domainhistory.sql
184+
V184__remove_fk_pollmessage_domainhistory.sql
185+
V185__remove_fk_domaintransactionrecord_domainhistory.sql
186+
V186__remove_fk_domaindsdatahistory_domainhistory.sql

0 commit comments

Comments
 (0)