mirror of
https://github.com/google/nomulus.git
synced 2025-04-30 03:57:51 +02:00
Make Domain -> BillingEvent FK deferred (#890)
* Make Domain -> BillingEvent FK deferred It appears that Hibernate can sporadically introduce FK constraint failures when updating a Domain to reference a new BillingEvent and then deleting the old BillingEvent, causing a flakey test failure in DomainDeleteFlowTest. This may be due to the fact that this FK relationships is not known to hibernate. An alternate solution appears to be to flush after every update, but that likely has some pretty serious performance implications.
This commit is contained in:
parent
4e799c4964
commit
eb9342a22c
5 changed files with 40 additions and 12 deletions
|
@ -261,11 +261,11 @@ td.section {
|
|||
</tr>
|
||||
<tr>
|
||||
<td class="property_name">generated on</td>
|
||||
<td class="property_value">2020-11-24 20:57:00.530791</td>
|
||||
<td class="property_value">2020-11-30 21:59:21.319302</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="property_name">last flyway file</td>
|
||||
<td id="lastFlywayFile" class="property_value">V79__drop_foreign_keys_on_pollmessage.sql</td>
|
||||
<td id="lastFlywayFile" class="property_value">V80__defer_bill_event_key.sql</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
@ -284,7 +284,7 @@ td.section {
|
|||
generated on
|
||||
</text>
|
||||
<text text-anchor="start" x="4027.94" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00">
|
||||
2020-11-24 20:57:00.530791
|
||||
2020-11-30 21:59:21.319302
|
||||
</text>
|
||||
<polygon fill="none" stroke="#888888" points="3940.44,-4 3940.44,-44 4205.44,-44 4205.44,-4 3940.44,-4" /> <!-- allocationtoken_a08ccbef -->
|
||||
<g id="node1" class="node">
|
||||
|
|
|
@ -261,11 +261,11 @@ td.section {
|
|||
</tr>
|
||||
<tr>
|
||||
<td class="property_name">generated on</td>
|
||||
<td class="property_value">2020-11-24 20:56:58.3401</td>
|
||||
<td class="property_value">2020-11-30 21:59:18.813825</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="property_name">last flyway file</td>
|
||||
<td id="lastFlywayFile" class="property_value">V79__drop_foreign_keys_on_pollmessage.sql</td>
|
||||
<td id="lastFlywayFile" class="property_value">V80__defer_bill_event_key.sql</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
@ -274,19 +274,19 @@ td.section {
|
|||
<svg viewbox="0.00 0.00 4825.18 4553.15" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="erDiagram" style="overflow: hidden; width: 100%; height: 800px"> <g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 4549.15)">
|
||||
<title>SchemaCrawler_Diagram</title>
|
||||
<polygon fill="white" stroke="transparent" points="-4,4 -4,-4549.15 4821.18,-4549.15 4821.18,4 -4,4" />
|
||||
<text text-anchor="start" x="4563.18" y="-29.8" font-family="Helvetica,sans-Serif" font-size="14.00">
|
||||
<text text-anchor="start" x="4548.68" y="-29.8" font-family="Helvetica,sans-Serif" font-size="14.00">
|
||||
generated by
|
||||
</text>
|
||||
<text text-anchor="start" x="4646.18" y="-29.8" font-family="Helvetica,sans-Serif" font-size="14.00">
|
||||
<text text-anchor="start" x="4631.68" y="-29.8" font-family="Helvetica,sans-Serif" font-size="14.00">
|
||||
SchemaCrawler 16.10.1
|
||||
</text>
|
||||
<text text-anchor="start" x="4562.18" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00">
|
||||
<text text-anchor="start" x="4547.68" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00">
|
||||
generated on
|
||||
</text>
|
||||
<text text-anchor="start" x="4646.18" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00">
|
||||
2020-11-24 20:56:58.3401
|
||||
<text text-anchor="start" x="4631.68" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00">
|
||||
2020-11-30 21:59:18.813825
|
||||
</text>
|
||||
<polygon fill="none" stroke="#888888" points="4559.18,-4 4559.18,-44 4809.18,-44 4809.18,-4 4559.18,-4" /> <!-- allocationtoken_a08ccbef -->
|
||||
<polygon fill="none" stroke="#888888" points="4544.18,-4 4544.18,-44 4809.18,-44 4809.18,-4 4544.18,-4" /> <!-- allocationtoken_a08ccbef -->
|
||||
<g id="node1" class="node">
|
||||
<title>allocationtoken_a08ccbef</title>
|
||||
<polygon fill="#ebcef2" stroke="transparent" points="2959.5,-2661.15 2959.5,-2680.15 3158.5,-2680.15 3158.5,-2661.15 2959.5,-2661.15" />
|
||||
|
|
|
@ -77,3 +77,4 @@ V76__change_history_nullability.sql
|
|||
V77__fixes_for_replay.sql
|
||||
V78__add_history_id_for_redemption_history_entry.sql
|
||||
V79__drop_foreign_keys_on_pollmessage.sql
|
||||
V80__defer_bill_event_key.sql
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
-- Copyright 2020 The Nomulus Authors. All Rights Reserved.
|
||||
--
|
||||
-- Licensed under the Apache License, Version 2.0 (the "License");
|
||||
-- you may not use this file except in compliance with the License.
|
||||
-- You may obtain a copy of the License at
|
||||
--
|
||||
-- http://www.apache.org/licenses/LICENSE-2.0
|
||||
--
|
||||
-- Unless required by applicable law or agreed to in writing, software
|
||||
-- distributed under the License is distributed on an "AS IS" BASIS,
|
||||
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
-- See the License for the specific language governing permissions and
|
||||
-- limitations under the License.
|
||||
|
||||
-- We have to make this foreign key initially deferred even though
|
||||
-- BillingEvent is saved before Domain (and deleted after). If we don't, it
|
||||
-- appears that Hibernate can sporadically introduce FK constraint failures
|
||||
-- when updating a Domain to reference a new BillingEvent and then deleting
|
||||
-- the old BillingEvent. This may be due to the fact that this FK
|
||||
-- relationships is not known to hibernate.
|
||||
ALTER TABLE "Domain" DROP CONSTRAINT fk_domain_transfer_billing_event_id;
|
||||
ALTER TABLE if exists "Domain"
|
||||
ADD CONSTRAINT fk_domain_transfer_billing_event_id
|
||||
FOREIGN KEY (transfer_billing_event_id)
|
||||
REFERENCES "BillingEvent"
|
||||
DEFERRABLE INITIALLY DEFERRED;
|
||||
|
|
@ -2064,7 +2064,7 @@ ALTER TABLE ONLY public."Domain"
|
|||
--
|
||||
|
||||
ALTER TABLE ONLY public."Domain"
|
||||
ADD CONSTRAINT fk_domain_transfer_billing_event_id FOREIGN KEY (transfer_billing_event_id) REFERENCES public."BillingEvent"(billing_event_id);
|
||||
ADD CONSTRAINT fk_domain_transfer_billing_event_id FOREIGN KEY (transfer_billing_event_id) REFERENCES public."BillingEvent"(billing_event_id) DEFERRABLE INITIALLY DEFERRED;
|
||||
|
||||
|
||||
--
|
||||
|
|
Loading…
Add table
Reference in a new issue