test: cover reconciliation failure windows and bounded upload memory
This commit is contained in:
@@ -247,6 +247,44 @@ def main():
|
||||
)
|
||||
record("failed_cleanup_recovers", recovery_apply["errors"] == 0)
|
||||
|
||||
# Failure after deleting bytes but before deleting the durable intent.
|
||||
delete_id, delete_key = str(uuid4()), "original/delete-ack-fault-" + suffix
|
||||
with store.connection() as conn:
|
||||
conn.execute(
|
||||
"INSERT INTO upload_intents VALUES (%s,%s,now()-interval '1 day')",
|
||||
(delete_id, delete_key),
|
||||
)
|
||||
storage.put(delete_key, BytesIO(data), len(data), "image/png")
|
||||
time.sleep(2.2)
|
||||
with store.connection() as conn:
|
||||
conn.execute(
|
||||
"CREATE FUNCTION reject_intent_delete() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN RAISE EXCEPTION 'injected intent DELETE failure'; END $$"
|
||||
)
|
||||
conn.execute(
|
||||
"CREATE TRIGGER research_reject_delete BEFORE DELETE ON upload_intents FOR EACH ROW EXECUTE FUNCTION reject_intent_delete()"
|
||||
)
|
||||
try:
|
||||
reconcile(store, storage, apply=True, grace_seconds=2)
|
||||
raise AssertionError("DELETE fault did not fire")
|
||||
except psycopg.errors.RaiseException:
|
||||
record("real_db_delete_failure_after_s3_delete", not storage.exists(delete_key))
|
||||
finally:
|
||||
with store.connection() as conn:
|
||||
conn.execute("DROP TRIGGER research_reject_delete ON upload_intents")
|
||||
conn.execute("DROP FUNCTION reject_intent_delete()")
|
||||
with store.connection() as conn:
|
||||
before_count = conn.execute("SELECT count(*) AS n FROM upload_intents").fetchone()["n"]
|
||||
dry_after_delete = reconcile(store, storage, grace_seconds=2)
|
||||
with store.connection() as conn:
|
||||
after_count = conn.execute("SELECT count(*) AS n FROM upload_intents").fetchone()["n"]
|
||||
record(
|
||||
"dry_run_does_not_resume_partial_delete",
|
||||
before_count == after_count and dry_after_delete["deleted_intents"] == 0,
|
||||
)
|
||||
resumed = reconcile(store, storage, apply=True, grace_seconds=2)
|
||||
record("partial_delete_resumes_only_on_apply", resumed["deleted_intents"] == 1)
|
||||
result["partial_delete_dry"], result["partial_delete_apply"] = dry_after_delete, resumed
|
||||
|
||||
# Measure an increasing population of intact, aged metadata/objects. Rows
|
||||
# share no client names or object paths, and all are in this disposable DB.
|
||||
current = 0
|
||||
|
||||
Reference in New Issue
Block a user