diff --git a/include/dbcache.h b/include/dbcache.h
index 5ce25f4f809..3265b60bd53 100644
--- a/include/dbcache.h
+++ b/include/dbcache.h
@@ -740,6 +740,7 @@ void	DCsync_configuration(unsigned char mode);
 void	DCsync_kvs_paths(const struct zbx_json_parse *jp_kvs_paths);
 int	init_configuration_cache(char **error);
 void	free_configuration_cache(void);
+void	zbx_print_configuration_cache_trace(void);
 
 void	DCconfig_get_triggers_by_triggerids(DC_TRIGGER *triggers, const zbx_uint64_t *triggerids, int *errcode,
 		size_t num);
diff --git a/src/libs/zbxdbcache/dbconfig.c b/src/libs/zbxdbcache/dbconfig.c
index 28006a21e65..5d53270d402 100644
--- a/src/libs/zbxdbcache/dbconfig.c
+++ b/src/libs/zbxdbcache/dbconfig.c
@@ -3153,6 +3153,8 @@ static void	dc_item_value_type_update(int found, ZBX_DC_ITEM *item, zbx_item_val
 	}
 }
 
+#define ZBX_TRACE_LINE	(config->line = __LINE__)
+
 static void	DCsync_items(zbx_dbsync_t *sync, int flags, zbx_vector_dc_item_ptr_t *new_items)
 {
 	char			**row;
@@ -3187,17 +3189,23 @@ static void	DCsync_items(zbx_dbsync_t *sync, int flags, zbx_vector_dc_item_ptr_t
 	{
 		int	row_num = zbx_dbsync_get_row_num(sync);
 
+		ZBX_TRACE_LINE;
+
 		zbx_hashset_reserve(&config->items, MAX(row_num, 100));
 		zbx_hashset_reserve(&config->items_hk, MAX(row_num, 100));
 		uniq = ZBX_HASHSET_UNIQ_TRUE;
 	}
 
+	ZBX_TRACE_LINE;
+
 	while (SUCCEED == (ret = zbx_dbsync_next(sync, &rowid, &row, &tag)))
 	{
 		/* removed rows will be always added at the end */
 		if (ZBX_DBSYNC_ROW_REMOVE == tag)
 			break;
 
+		ZBX_TRACE_LINE;
+
 		ZBX_STR2UINT64(itemid, row[0]);
 		ZBX_STR2UINT64(hostid, row[1]);
 		ZBX_STR2UCHAR(status, row[2]);
@@ -3209,6 +3217,8 @@ static void	DCsync_items(zbx_dbsync_t *sync, int flags, zbx_vector_dc_item_ptr_t
 				continue;
 		}
 
+		ZBX_TRACE_LINE;
+
 		item_flags = (unsigned char)atoi(row[18]);
 
 		/* item prototype does not have item_rtdata and shouldn't be present in sync */
@@ -3218,6 +3228,7 @@ static void	DCsync_items(zbx_dbsync_t *sync, int flags, zbx_vector_dc_item_ptr_t
 			continue;
 		}
 
+		ZBX_TRACE_LINE;
 		item = (ZBX_DC_ITEM *)DCfind_id_ext(&config->items, itemid, sizeof(ZBX_DC_ITEM), &found, uniq);
 
 		/* template item */
@@ -3227,11 +3238,11 @@ static void	DCsync_items(zbx_dbsync_t *sync, int flags, zbx_vector_dc_item_ptr_t
 			dc_interface_snmpitems_remove(item);
 
 		/* see whether we should and can update items_hk index at this point */
-
 		if (0 == found || 0 != strcmp(item->key, row[5]))
 		{
 			if (1 == found)
 			{
+				ZBX_TRACE_LINE;
 				item_hk_local.hostid = item->hostid;
 				item_hk_local.key = item->key;
 
@@ -3249,6 +3260,8 @@ static void	DCsync_items(zbx_dbsync_t *sync, int flags, zbx_vector_dc_item_ptr_t
 				}
 			}
 
+			ZBX_TRACE_LINE;
+
 			if (SUCCEED == DCstrpool_replace(found, &item->key, row[5]))
 				flags |= ZBX_ITEM_KEY_CHANGED;
 
@@ -3265,12 +3278,16 @@ static void	DCsync_items(zbx_dbsync_t *sync, int flags, zbx_vector_dc_item_ptr_t
 		}
 		else
 		{
+			ZBX_TRACE_LINE;
+	
 			if (SUCCEED == DCstrpool_replace(found, &item->key, row[5]))
 				flags |= ZBX_ITEM_KEY_CHANGED;
 		}
 
 		/* store new information in item structure */
 
+		ZBX_TRACE_LINE;
+
 		item->hostid = hostid;
 		item->flags = item_flags;
 		ZBX_DBROW2UINT64(interfaceid, row[19]);
@@ -3293,6 +3310,8 @@ static void	DCsync_items(zbx_dbsync_t *sync, int flags, zbx_vector_dc_item_ptr_t
 
 		if (0 == found)
 		{
+			ZBX_TRACE_LINE;
+	
 			item->triggers = NULL;
 
 			if (NULL != new_items)
@@ -3319,6 +3338,8 @@ static void	DCsync_items(zbx_dbsync_t *sync, int flags, zbx_vector_dc_item_ptr_t
 		}
 		else
 		{
+			ZBX_TRACE_LINE;
+
 			if (item->type != type)
 				flags |= ZBX_ITEM_TYPE_CHANGED;
 
@@ -3335,8 +3356,12 @@ static void	DCsync_items(zbx_dbsync_t *sync, int flags, zbx_vector_dc_item_ptr_t
 			}
 		}
 
+		ZBX_TRACE_LINE;
+
 		if (ITEM_STATUS_ACTIVE == status)
 		{
+			ZBX_TRACE_LINE;
+
 			if (NULL == interface || interface->interfaceid != interfaceid)
 				interface = (ZBX_DC_INTERFACE *)zbx_hashset_search(&config->interfaces, &interfaceid);
 			dc_interface_update_agent_stats(interface, type, 1);
@@ -3353,18 +3378,24 @@ static void	DCsync_items(zbx_dbsync_t *sync, int flags, zbx_vector_dc_item_ptr_t
 		item->value_type = value_type;
 		item->interfaceid = interfaceid;
 
+		ZBX_TRACE_LINE;
 		dc_item_value_type_update(found, item, &old_value_type, row);
+		ZBX_TRACE_LINE;
 		dc_item_type_update(found, item, &old_type, &dep_items, row);
+		ZBX_TRACE_LINE;
 
 		/* process item intervals and update item nextcheck */
 
 		if (SUCCEED == DCstrpool_replace(found, &item->delay, row[8]))
 			flags |= ZBX_ITEM_DELAY_CHANGED;
+		ZBX_TRACE_LINE;
 
 		/* SNMP trap items for current server/proxy */
 
 		if (ITEM_TYPE_SNMPTRAP == item->type && 0 == host->proxy_hostid)
 		{
+			ZBX_TRACE_LINE;
+
 			interface_snmpitem = (ZBX_DC_INTERFACE_ITEM *)DCfind_id(&config->interface_snmpitems,
 					item->interfaceid, sizeof(ZBX_DC_INTERFACE_ITEM), &found);
 
@@ -3387,12 +3418,15 @@ static void	DCsync_items(zbx_dbsync_t *sync, int flags, zbx_vector_dc_item_ptr_t
 
 		if (ITEM_STATUS_ACTIVE == item->status && HOST_STATUS_MONITORED == host->status)
 		{
+			ZBX_TRACE_LINE;
 			DCitem_poller_type_update(item, host, flags);
 
 			if (SUCCEED == zbx_is_counted_in_item_queue(item->type, item->key))
 			{
 				char	*error = NULL;
 
+				ZBX_TRACE_LINE;
+
 				if (FAIL == DCitem_nextcheck_update(item, interface, flags, now, &error))
 				{
 					zbx_timespec_t	ts = {now, 0};
@@ -3419,10 +3453,12 @@ static void	DCsync_items(zbx_dbsync_t *sync, int flags, zbx_vector_dc_item_ptr_t
 			item->poller_type = ZBX_NO_POLLER;
 		}
 
+		ZBX_TRACE_LINE;
 		DCupdate_item_queue(item, old_poller_type, old_nextcheck);
 	}
 
 	/* update dependent item vectors within master items */
+	ZBX_TRACE_LINE;
 
 	for (i = 0; i < dep_items.values_num; i++)
 	{
@@ -3452,20 +3488,25 @@ static void	DCsync_items(zbx_dbsync_t *sync, int flags, zbx_vector_dc_item_ptr_t
 
 	zbx_vector_ptr_destroy(&dep_items);
 
+	ZBX_TRACE_LINE;
 	/* remove deleted items from buffer */
 	for (; SUCCEED == ret; ret = zbx_dbsync_next(sync, &rowid, &row, &tag))
 	{
 		if (NULL == (item = (ZBX_DC_ITEM *)zbx_hashset_search(&config->items, &rowid)))
 			continue;
 
+		ZBX_TRACE_LINE;
+
 		if (ITEM_STATUS_ACTIVE == item->status)
 		{
+			ZBX_TRACE_LINE;
 			interface = (ZBX_DC_INTERFACE *)zbx_hashset_search(&config->interfaces, &item->interfaceid);
 			dc_interface_update_agent_stats(interface, item->type, -1);
 		}
 
 		itemid = item->itemid;
 
+		ZBX_TRACE_LINE;
 		if (ITEM_TYPE_SNMPTRAP == item->type)
 			dc_interface_snmpitems_remove(item);
 
@@ -3473,10 +3514,10 @@ static void	DCsync_items(zbx_dbsync_t *sync, int flags, zbx_vector_dc_item_ptr_t
 		dc_item_type_free(item, item->type);
 
 		/* items */
-
+		ZBX_TRACE_LINE;
 		item_hk_local.hostid = item->hostid;
 		item_hk_local.key = item->key;
-
+		ZBX_TRACE_LINE;
 		if (NULL == (item_hk = (ZBX_DC_ITEM_HK *)zbx_hashset_search(&config->items_hk, &item_hk_local)))
 		{
 			/* item keys should be unique for items within a host, otherwise items with  */
@@ -3488,7 +3529,7 @@ static void	DCsync_items(zbx_dbsync_t *sync, int flags, zbx_vector_dc_item_ptr_t
 			zbx_strpool_release(item_hk->key);
 			zbx_hashset_remove_direct(&config->items_hk, item_hk);
 		}
-
+		ZBX_TRACE_LINE;
 		if (ZBX_LOC_QUEUE == item->location)
 			zbx_binary_heap_remove_direct(&config->queues[item->poller_type], item->itemid);
 
@@ -3496,20 +3537,21 @@ static void	DCsync_items(zbx_dbsync_t *sync, int flags, zbx_vector_dc_item_ptr_t
 		zbx_strpool_release(item->error);
 		zbx_strpool_release(item->delay);
 
+		ZBX_TRACE_LINE;
 		if (NULL != item->triggers)
 			config->items.mem_free_func(item->triggers);
 
 		zbx_vector_ptr_destroy(&item->tags);
-
+		ZBX_TRACE_LINE;
 		if (NULL != (preprocitem = (ZBX_DC_PREPROCITEM *)zbx_hashset_search(&config->preprocitems, &item->itemid)))
 		{
 			zbx_vector_ptr_destroy(&preprocitem->preproc_ops);
 			zbx_hashset_remove_direct(&config->preprocitems, preprocitem);
 		}
-
+		ZBX_TRACE_LINE;
 		zbx_hashset_remove_direct(&config->items, item);
 	}
-
+	ZBX_TRACE_LINE;
 	zabbix_log(LOG_LEVEL_DEBUG, "End of %s()", __func__);
 }
 
@@ -7337,6 +7379,16 @@ out:
 	return ret;
 }
 
+void	zbx_print_configuration_cache_trace(void)
+{
+	if (NULL == config)
+	{
+		zabbix_log(LOG_LEVEL_INFORMATION, "In %s(): configuration cache freed", __func__);
+		return;
+	}
+	zabbix_log(LOG_LEVEL_INFORMATION, "In %s():%d", __func__, config->line);
+}
+
 /******************************************************************************
  *                                                                            *
  * Purpose: Free memory allocated for configuration cache                     *
@@ -7345,6 +7397,8 @@ out:
 void	free_configuration_cache(void)
 {
 	zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __func__);
+	
+	zbx_print_configuration_cache_trace();
 
 	WRLOCK_CACHE;
 
diff --git a/src/libs/zbxdbcache/dbconfig.h b/src/libs/zbxdbcache/dbconfig.h
index 5f486e126b6..25386ec3bbd 100644
--- a/src/libs/zbxdbcache/dbconfig.h
+++ b/src/libs/zbxdbcache/dbconfig.h
@@ -898,6 +898,7 @@ typedef struct
 	zbx_hashset_t		strpool;
 	char			autoreg_psk_identity[HOST_TLS_PSK_IDENTITY_LEN_MAX];	/* autoregistration PSK */
 	char			autoreg_psk[HOST_TLS_PSK_LEN_MAX];
+	int			line;
 }
 ZBX_DC_CONFIG;
 
diff --git a/src/zabbix_server/server.c b/src/zabbix_server/server.c
index b37ba283972..dcef2da7c0f 100644
--- a/src/zabbix_server/server.c
+++ b/src/zabbix_server/server.c
@@ -1999,6 +1999,8 @@ void	zbx_on_exit(int ret, void *on_exit_args)
 
 	zabbix_log(LOG_LEVEL_DEBUG, "zbx_on_exit() called with ret:%d", ret);
 
+	zbx_print_configuration_cache_trace();
+
 	if (NULL != threads)
 	{
 		zbx_threads_wait(threads, threads_flags, threads_num, ret);	/* wait for all child processes to exit */
