Unverified Commit 57a347df authored by Sebastian Schüpbach's avatar Sebastian Schüpbach
Browse files

log mariadb commit errors explicitly

parent 8cbc9c67
Pipeline #17938 passed with stages
in 2 minutes and 1 second
......@@ -192,7 +192,7 @@ def _create_sql_stmt(table_name, record, fields) -> str:
for db_field in db_fields])
db_fields = ','.join(db_fields)
# noinspection SqlNoDataSourceInspection
return 'INSERT IGNORE INTO {} ({}) VALUES ({})'.format(
return 'INSERT ON DUPLICATE KEY UPDATE INTO {} ({}) VALUES ({})'.format(
table_name, db_fields, db_values)
......@@ -318,18 +318,36 @@ class MediametadataToDB:
"digitalObject is unavailable")
if record_number % 100 == 0:
_write_values_in_db(mariadb_cursor, record_values_for_db)
mariadb_connection.commit()
for record_value in record_values_for_db:
logging.info(f'Record {record_value["sig"]} successfully indexed')
reporter.send_message(record_value['sig'], "SUCCESS",
"Indexing successful")
try:
mariadb_connection.commit()
for record_value in record_values_for_db:
logging.info(f'Record {record_value["sig"]} successfully indexed')
reporter.send_message(record_value['sig'], "SUCCESS",
"Indexing successful")
except mariadb.Error as error:
logging.error(error)
for record_value in record_values_for_db:
logging.info(f'Indexing of record {record_value["sig"]} failed')
reporter.send_message(record_value['sig'], "FATAL",
"Indexing failed")
record_values_for_db = []
consumer.commit()
if counter % 1000 == 0:
logging.info('{} messages read till now'.format(counter))
# arriving here means there are no new messages to poll from
_write_values_in_db(mariadb_cursor, record_values_for_db)
mariadb_connection.commit()
try:
mariadb_connection.commit()
for record_value in record_values_for_db:
logging.info(f'Record {record_value["sig"]} successfully indexed')
reporter.send_message(record_value['sig'], "SUCCESS",
"Indexing successful")
except mariadb.Error as error:
logging.error(error)
for record_value in record_values_for_db:
logging.info(f'Indexing of record {record_value["sig"]} failed')
reporter.send_message(record_value['sig'], "FATAL",
"Indexing failed")
for record_value in record_values_for_db:
reporter.send_message(record_value['sig'], "SUCCESS", "Indexing successful")
record_values_for_db = []
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment