From 3bde14b5cf88272a43c0594a695fcbcd0690e957 Mon Sep 17 00:00:00 2001 From: Matthew Oliver Date: Thu, 1 Dec 2016 09:46:53 +1100 Subject: [PATCH] Quarantine malformed database schema SQLite errors Currently if an sqlite3.DatabaseError is thrown when caused by a corrupted database schema, it get logged and the database is isn't quarantined. This patch adds the malformed database schema case to the list of SQLite errors in possibly_quarantine that will trigger the db to be quarantined. Also it improved the possibly_quarantined unit test to test all existing exceptions, and catches exceptions based on the real world except we use in code. Closes-Bug: #1646247 Change-Id: Id9452c88f8394a2a910c34c69361442543aa206d --- swift/common/db.py | 2 + test/unit/common/malformed_schema_example.db | Bin 0 -> 49152 bytes test/unit/common/test_db.py | 61 +++++++++++++------ 3 files changed, 44 insertions(+), 19 deletions(-) create mode 100644 test/unit/common/malformed_schema_example.db diff --git a/swift/common/db.py b/swift/common/db.py index 1f06694f10..fc5c057daf 100644 --- a/swift/common/db.py +++ b/swift/common/db.py @@ -331,6 +331,8 @@ class DatabaseBroker(object): """ if 'database disk image is malformed' in str(exc_value): exc_hint = 'malformed' + elif 'malformed database schema' in str(exc_value): + exc_hint = 'malformed' elif 'file is encrypted or is not a database' in str(exc_value): exc_hint = 'corrupted' elif 'disk I/O error' in str(exc_value): diff --git a/test/unit/common/malformed_schema_example.db b/test/unit/common/malformed_schema_example.db new file mode 100644 index 0000000000000000000000000000000000000000..bdd46e61eff78f03faaf14f3adf3a3cc489eafd2 GIT binary patch literal 49152 zcmeI2L2nz!700=@EYh-MIxZSUFak^w6eJ;0AQefL;ixHXEgd!z>5!|+23ip7-bYSQz#$Lop0 zzn))W!s-7onR)(aoH*)100ck)1V8`;KmY_l00ck)1V8`;UOj;;^9#)AwO4N$7C`_6 zKmY_l00ck)1V8`;KmY_l00gFoz#JP2-v6g(K`;^!009sH0T2KI5C8!X009sH0T4I` z0{H&_9H7D^2!H?xfB*=900@8p2!H?xfB*e-2P#5(Gd11V8`;KmY_l00ck)1V8`;ri=jl{$ES~J3;^9 z0|Fob0w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