Add an extension to verify transaction replay (#857)

* Add an extension to verify transaction replay

Add ReplayExtension, which can be applied to test suites to verify that
transactions committed to datastore can be replayed to SQL.

This introduces a ReplayQueue class, which serves as a stand-in for the
current lack of replay-from-commit-logs.  It also includes replay logic in
TransactionInfo which introduces the concept of "entity class weights."
Entity weighting allows us store and delete objects in an order that is
consistent with the direction of foreign key and deferred foreign key
relationships.  As a general rule, lower weight classes must have no direct or
indirect non-deferred foreign key relationships on higher weight classes.

It is expected that much of this code will change when the final replay
mechanism is implemented.

* Minor fixes:

- Initialize "requestedByRegistrar" to false (it's non-nullable). [reverted
  during rebase: non-nullable was removed in another PR]
- Store test entities (registrar, hosts and contacts) in JPA.

* Make testbed save replay

This changes the replay system to make datastore saves initiated from the
testbed (as opposed to just the tested code) replay when the ReplayExtension
is enabled.  This requires modifications to DatastoreHelper and the
AppEngineExtension that the ReplayExtension can plug into.

This changes also has some necessary fixes to objects that are persisted by
the testbed (such as PremiumList).
This commit is contained in:
Michael Muller 2020-11-17 13:29:50 -05:00 committed by GitHub
parent df5a35ac44
commit 385e8fb6ec
19 changed files with 371 additions and 65 deletions

View file

@ -261,11 +261,11 @@ td.section {
</tr>
<tr>
<td class="property_name">generated on</td>
<td class="property_value">2020-11-13 19:34:54.398919</td>
<td class="property_value">2020-11-16 16:45:08.581361</td>
</tr>
<tr>
<td class="property_name">last flyway file</td>
<td id="lastFlywayFile" class="property_value">V76__change_history_nullability.sql</td>
<td id="lastFlywayFile" class="property_value">V77__fixes_for_replay.sql</td>
</tr>
</tbody>
</table>
@ -284,7 +284,7 @@ td.section {
generated on
</text>
<text text-anchor="start" x="5830.94" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00">
2020-11-13 19:34:54.398919
2020-11-16 16:45:08.581361
</text>
<polygon fill="none" stroke="#888888" points="5743.44,-4 5743.44,-44 6008.44,-44 6008.44,-4 5743.44,-4" /> <!-- allocationtoken_a08ccbef -->
<g id="node1" class="node">

View file

@ -261,11 +261,11 @@ td.section {
</tr>
<tr>
<td class="property_name">generated on</td>
<td class="property_value">2020-11-13 19:34:52.404634</td>
<td class="property_value">2020-11-16 16:45:06.707088</td>
</tr>
<tr>
<td class="property_name">last flyway file</td>
<td id="lastFlywayFile" class="property_value">V76__change_history_nullability.sql</td>
<td id="lastFlywayFile" class="property_value">V77__fixes_for_replay.sql</td>
</tr>
</tbody>
</table>
@ -284,7 +284,7 @@ td.section {
generated on
</text>
<text text-anchor="start" x="6501.68" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00">
2020-11-13 19:34:52.404634
2020-11-16 16:45:06.707088
</text>
<polygon fill="none" stroke="#888888" points="6414.18,-4 6414.18,-44 6679.18,-44 6679.18,-4 6414.18,-4" /> <!-- allocationtoken_a08ccbef -->
<g id="node1" class="node">
@ -5690,70 +5690,70 @@ td.section {
</g> <!-- premiumlist_7c3ea68b -->
<g id="node26" class="node">
<title>premiumlist_7c3ea68b</title>
<polygon fill="#ebcef2" stroke="transparent" points="5717.5,-3349.5 5717.5,-3368.5 5849.5,-3368.5 5849.5,-3349.5 5717.5,-3349.5" />
<text text-anchor="start" x="5719.5" y="-3356.3" font-family="Helvetica,sans-Serif" font-weight="bold" font-style="italic" font-size="14.00">
<polygon fill="#ebcef2" stroke="transparent" points="5725.5,-3349.5 5725.5,-3368.5 5857.5,-3368.5 5857.5,-3349.5 5725.5,-3349.5" />
<text text-anchor="start" x="5727.5" y="-3356.3" font-family="Helvetica,sans-Serif" font-weight="bold" font-style="italic" font-size="14.00">
public.PremiumList
</text>
<polygon fill="#ebcef2" stroke="transparent" points="5849.5,-3349.5 5849.5,-3368.5 5975.5,-3368.5 5975.5,-3349.5 5849.5,-3349.5" />
<text text-anchor="start" x="5936.5" y="-3355.3" font-family="Helvetica,sans-Serif" font-size="14.00">
<polygon fill="#ebcef2" stroke="transparent" points="5857.5,-3349.5 5857.5,-3368.5 5967.5,-3368.5 5967.5,-3349.5 5857.5,-3349.5" />
<text text-anchor="start" x="5928.5" y="-3355.3" font-family="Helvetica,sans-Serif" font-size="14.00">
[table]
</text>
<text text-anchor="start" x="5719.5" y="-3337.3" font-family="Helvetica,sans-Serif" font-weight="bold" font-style="italic" font-size="14.00">
<text text-anchor="start" x="5727.5" y="-3337.3" font-family="Helvetica,sans-Serif" font-weight="bold" font-style="italic" font-size="14.00">
revision_id
</text>
<text text-anchor="start" x="5843.5" y="-3336.3" font-family="Helvetica,sans-Serif" font-size="14.00">
<text text-anchor="start" x="5851.5" y="-3336.3" font-family="Helvetica,sans-Serif" font-size="14.00">
</text>
<text text-anchor="start" x="5851.5" y="-3336.3" font-family="Helvetica,sans-Serif" font-size="14.00">
<text text-anchor="start" x="5859.5" y="-3336.3" font-family="Helvetica,sans-Serif" font-size="14.00">
bigserial not null
</text>
<text text-anchor="start" x="5843.5" y="-3317.3" font-family="Helvetica,sans-Serif" font-size="14.00">
<text text-anchor="start" x="5851.5" y="-3317.3" font-family="Helvetica,sans-Serif" font-size="14.00">
</text>
<text text-anchor="start" x="5851.5" y="-3317.3" font-family="Helvetica,sans-Serif" font-size="14.00">
<text text-anchor="start" x="5859.5" y="-3317.3" font-family="Helvetica,sans-Serif" font-size="14.00">
auto-incremented
</text>
<text text-anchor="start" x="5719.5" y="-3298.3" font-family="Helvetica,sans-Serif" font-size="14.00">
<text text-anchor="start" x="5727.5" y="-3298.3" font-family="Helvetica,sans-Serif" font-size="14.00">
creation_timestamp
</text>
<text text-anchor="start" x="5843.5" y="-3298.3" font-family="Helvetica,sans-Serif" font-size="14.00">
<text text-anchor="start" x="5851.5" y="-3298.3" font-family="Helvetica,sans-Serif" font-size="14.00">
</text>
<text text-anchor="start" x="5851.5" y="-3298.3" font-family="Helvetica,sans-Serif" font-size="14.00">
timestamptz not null
<text text-anchor="start" x="5859.5" y="-3298.3" font-family="Helvetica,sans-Serif" font-size="14.00">
timestamptz
</text>
<text text-anchor="start" x="5719.5" y="-3279.3" font-family="Helvetica,sans-Serif" font-size="14.00">
<text text-anchor="start" x="5727.5" y="-3279.3" font-family="Helvetica,sans-Serif" font-size="14.00">
name
</text>
<text text-anchor="start" x="5843.5" y="-3279.3" font-family="Helvetica,sans-Serif" font-size="14.00">
<text text-anchor="start" x="5851.5" y="-3279.3" font-family="Helvetica,sans-Serif" font-size="14.00">
</text>
<text text-anchor="start" x="5851.5" y="-3279.3" font-family="Helvetica,sans-Serif" font-size="14.00">
<text text-anchor="start" x="5859.5" y="-3279.3" font-family="Helvetica,sans-Serif" font-size="14.00">
text not null
</text>
<text text-anchor="start" x="5719.5" y="-3260.3" font-family="Helvetica,sans-Serif" font-size="14.00">
<text text-anchor="start" x="5727.5" y="-3260.3" font-family="Helvetica,sans-Serif" font-size="14.00">
bloom_filter
</text>
<text text-anchor="start" x="5843.5" y="-3260.3" font-family="Helvetica,sans-Serif" font-size="14.00">
<text text-anchor="start" x="5851.5" y="-3260.3" font-family="Helvetica,sans-Serif" font-size="14.00">
</text>
<text text-anchor="start" x="5851.5" y="-3260.3" font-family="Helvetica,sans-Serif" font-size="14.00">
<text text-anchor="start" x="5859.5" y="-3260.3" font-family="Helvetica,sans-Serif" font-size="14.00">
bytea not null
</text>
<text text-anchor="start" x="5719.5" y="-3241.3" font-family="Helvetica,sans-Serif" font-size="14.00">
<text text-anchor="start" x="5727.5" y="-3241.3" font-family="Helvetica,sans-Serif" font-size="14.00">
currency
</text>
<text text-anchor="start" x="5843.5" y="-3241.3" font-family="Helvetica,sans-Serif" font-size="14.00">
<text text-anchor="start" x="5851.5" y="-3241.3" font-family="Helvetica,sans-Serif" font-size="14.00">
</text>
<text text-anchor="start" x="5851.5" y="-3241.3" font-family="Helvetica,sans-Serif" font-size="14.00">
<text text-anchor="start" x="5859.5" y="-3241.3" font-family="Helvetica,sans-Serif" font-size="14.00">
text not null
</text>
<polygon fill="none" stroke="#888888" points="5716.5,-3235 5716.5,-3370 5976.5,-3370 5976.5,-3235 5716.5,-3235" />
<polygon fill="none" stroke="#888888" points="5724.5,-3235 5724.5,-3370 5968.5,-3370 5968.5,-3235 5724.5,-3235" />
</g> <!-- premiumentry_b0060b91&#45;&gt;premiumlist_7c3ea68b -->
<g id="edge52" class="edge">
<title>premiumentry_b0060b91:w-&gt;premiumlist_7c3ea68b:e</title>
<path fill="none" stroke="black" d="M6320.18,-3340.5C6177.56,-3340.5 6133.1,-3340.5 5986.75,-3340.5" />
<path fill="none" stroke="black" d="M6320.23,-3340.5C6173.96,-3340.5 6128.62,-3340.5 5978.54,-3340.5" />
<polygon fill="black" stroke="black" points="6328.5,-3340.5 6338.5,-3345 6333.5,-3340.5 6338.5,-3340.5 6338.5,-3340.5 6338.5,-3340.5 6333.5,-3340.5 6338.5,-3336 6328.5,-3340.5 6328.5,-3340.5" />
<ellipse fill="none" stroke="black" cx="6324.5" cy="-3340.5" rx="4" ry="4" />
<polygon fill="black" stroke="black" points="5977.5,-3345.5 5977.5,-3335.5 5979.5,-3335.5 5979.5,-3345.5 5977.5,-3345.5" />
<polyline fill="none" stroke="black" points="5976.5,-3340.5 5981.5,-3340.5 " />
<polygon fill="black" stroke="black" points="5982.5,-3345.5 5982.5,-3335.5 5984.5,-3335.5 5984.5,-3345.5 5982.5,-3345.5" />
<polyline fill="none" stroke="black" points="5981.5,-3340.5 5986.5,-3340.5 " />
<polygon fill="black" stroke="black" points="5969.5,-3345.5 5969.5,-3335.5 5971.5,-3335.5 5971.5,-3345.5 5969.5,-3345.5" />
<polyline fill="none" stroke="black" points="5968.5,-3340.5 5973.5,-3340.5 " />
<polygon fill="black" stroke="black" points="5974.5,-3345.5 5974.5,-3335.5 5976.5,-3335.5 5976.5,-3345.5 5974.5,-3345.5" />
<polyline fill="none" stroke="black" points="5973.5,-3340.5 5978.5,-3340.5 " />
<text text-anchor="start" x="6081.5" y="-3344.3" font-family="Helvetica,sans-Serif" font-size="14.00">
fko0gw90lpo1tuee56l0nb6y6g5
</text>
@ -11600,7 +11600,7 @@ td.section {
<tr>
<td class="spacer"></td>
<td class="minwidth">creation_timestamp</td>
<td class="minwidth">timestamptz not null</td>
<td class="minwidth">timestamptz</td>
</tr>
<tr>
<td class="spacer"></td>

View file

@ -74,3 +74,4 @@ V73__singleton_entities.sql
V74__sql_replay_checkpoint.sql
V75__add_grace_period_history.sql
V76__change_history_nullability.sql
V77__fixes_for_replay.sql

View file

@ -0,0 +1,15 @@
-- 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.
ALTER TABLE "PremiumList" ALTER COLUMN creation_timestamp DROP NOT NULL;

View file

@ -22,7 +22,6 @@
discount_premiums boolean not null,
discount_years int4 not null,
domain_name text,
redemption_history_entry text,
token_status_transitions hstore,
token_type text,
primary key (token)
@ -524,7 +523,7 @@
create table "PremiumList" (
revision_id bigserial not null,
creation_timestamp timestamptz not null,
creation_timestamp timestamptz,
name text not null,
bloom_filter bytea not null,
currency text not null,
@ -635,7 +634,7 @@
create table "ReservedList" (
revision_id bigserial not null,
creation_timestamp timestamptz not null,
creation_timestamp timestamptz,
name text not null,
should_publish boolean not null,
primary key (revision_id)

View file

@ -686,7 +686,7 @@ CREATE TABLE public."PremiumEntry" (
CREATE TABLE public."PremiumList" (
revision_id bigint NOT NULL,
creation_timestamp timestamp with time zone NOT NULL,
creation_timestamp timestamp with time zone,
name text NOT NULL,
bloom_filter bytea NOT NULL,
currency text NOT NULL