Duplicate key errors during Zato startup with ODB on PostgreSQL

Ever since we’ve switched the ODB from sqlite to PostgreSQL, we randomly see these errors during Zato startup (virgin DB, while it’s adding services to the store):

ProgrammingError: (raised as a result of Query-invoked autoflush; consider using a session.no_autoflush block if this flush is occurring prematurely) (ProgrammingError) (u'ERROR', u'23505', u'duplicate key value violates unique constraint "http_soap_name_connection_transport_cluster_id_key"', u'Key (name, connection, transport, cluster_id)=(zato.security.ntlm.change-password, channel, soap, 1) already exists.', u'public', u'http_soap', u'http_soap_name_connection_transport_cluster_id_key', u'nbtinsert.c', u'406', u'_bt_check_unique', u'', u'') u"INSERT INTO http_soap (id, name, is_active, is_internal, connection, transport, host, url_path, method, soap_action, soap_version, data_format, ping_method, pool_size, merge_url_params_req, url_params_pri, params_pri, audit_enabled, audit_back_log, audit_max_payload, audit_repl_patt_type, serialization_type, timeout, sec_tls_ca_cert_id, has_rbac, service_id, cluster_id, security_id) VALUES (nextval('http_soap_seq'), %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) RETURNING http_soap.id" (u'zato.security.ntlm.change-password', True, True, u'channel', u'soap', None, u'/zato/soap', None, u'zato.security.ntlm.change-password', u'1.1', u'xml', None, None, True, u'qs-over-path', u'channel-params-over-msg', False, 1440, 0, u'json-pointer', u'suds', 10, None, False, 760, 1, 2)

Full traceback: https://hastebin.com/uhewojixit.py

What could be causing this, what can we do to fix this?

I’ve never seen it before. The exception of ‘duplicate key value violates unique constraint’ is harmless and expected, it should stay on DEBUG level and definitely doesn’t constitute an error.

Have you investigated the ‘raised as a result of Query-invoked autoflush’ message?

I wouldn’t know where to start. This is from the default configuration as produced by zato quickstart create. Where would the Zato code have a query-invoked autoflush that could be investigated?

I understand that this is from the default configuration but like I said, it’s the first time I see it. There is nothing in Zato code that explicitly produces a query-invoked autoflush, I would simply start with the traceback that was produced and work my way through it.