MultiChain / multichain-explorer

Web-based explorer for MultiChain blockchains
GNU Affero General Public License v3.0
177 stars 140 forks source link

Database constraint preventing continued scanning of multichain #24

Open TronBlack opened 7 years ago

TronBlack commented 7 years ago

When scanning the multichain chain, a triplet of ids is added to a table triggering an database Integrity exception. ABE continues to retry getting the same exception.

Symptom: Data stops updating in the explorer. The multichain chain continues just fine.

gidgreen commented 7 years ago

Thanks. Can you say anything about what happened in the transaction which triggered this? Or what sorts of things you were doing in general on the chain?

TronBlack commented 7 years ago

We were running load tests and adding 3000+ Assets. The problem is not with multichain, but with the explorer db construction.

We have a "fix" for it that allows it to continue. It is essentially just handling the Integrity exception so it doesn't get stuck.

I added two lines in Mce/SqlAbstraction.py.

@@ -405,6 +405,8 @@ class SqlAbstraction(object):
     def _execute(sql, stmt, params):
         try:
             sql.cursor().execute(stmt, params)
+        except (sql.module.IntegrityError) as e:
+            print "Found Integrity Error - continuing..."        
         except (sql.module.OperationalError, sql.module.InternalError, sql.module.ProgrammingError) as e:
             if sql.in_transaction or not sql.auto_reconnect:
                 raise
gidgreen commented 7 years ago

Thanks. Do you have any more information about the integrity exception that was thrown? Foreign key? Unique key? And what SQL statement was executing at the time?

bitcartel commented 7 years ago

@TronBlack Can you print the entire exception object?