diff -uNrp zabbix-1.8.16-1.2.orig/include/ipc.h zabbix-1.8.16-1.2/include/ipc.h
--- zabbix-1.8.16-1.2.orig/include/ipc.h	2013-01-16 23:10:08.000000000 +0900
+++ zabbix-1.8.16-1.2/include/ipc.h	2013-02-19 11:21:02.223148298 +0900
@@ -31,6 +31,7 @@
 #define ZBX_IPC_STRPOOL_ID	's'
 #define ZBX_IPC_COLLECTOR_ID	'l'
 #define ZBX_IPC_SELFMON_ID	'S'
+#define ZBX_IPC_PROXY_TR_ID	'P'
 
 key_t	zbx_ftok(char *path, int id);
 int	zbx_shmget(key_t key, size_t size);
diff -uNrp zabbix-1.8.16-1.2.orig/include/mutexs.h zabbix-1.8.16-1.2/include/mutexs.h
--- zabbix-1.8.16-1.2.orig/include/mutexs.h	2013-01-16 23:10:08.000000000 +0900
+++ zabbix-1.8.16-1.2/include/mutexs.h	2013-02-19 11:25:46.763132832 +0900
@@ -53,7 +53,8 @@
 #	define ZBX_MUTEX_STRPOOL	6
 #	define ZBX_MUTEX_SELFMON	7
 #	define ZBX_MUTEX_CPUSTATS	8
-#	define ZBX_MUTEX_COUNT		9
+#	define ZBX_MUTEX_PROXY_TR	9
+#	define ZBX_MUTEX_COUNT		10
 
 #	define ZBX_MUTEX_MAX_TRIES	20	/* seconds */
 
diff -uNrp zabbix-1.8.16-1.2.orig/src/libs/zbxdbcache/dbcache.c zabbix-1.8.16-1.2/src/libs/zbxdbcache/dbcache.c
--- zabbix-1.8.16-1.2.orig/src/libs/zbxdbcache/dbcache.c	2013-02-19 11:14:06.083247305 +0900
+++ zabbix-1.8.16-1.2/src/libs/zbxdbcache/dbcache.c	2013-02-19 11:47:20.585254562 +0900
@@ -142,6 +142,9 @@ ZBX_DC_CACHE
 
 ZBX_DC_CACHE		*cache = NULL;
 
+extern int		*proxy_tr;
+extern ZBX_MUTEX	proxy_tr_lock;
+
 /******************************************************************************
  *                                                                            *
  * Function: DCget_stats                                                      *
@@ -2322,6 +2325,13 @@ int	DCsync_history(int sync_type)
 
 		DCinit_nextchecks();
 
+		if (0 != (daemon_type & ZBX_DAEMON_TYPE_PROXY))
+		{
+			zbx_mutex_lock(&proxy_tr_lock);
+			(*proxy_tr)++;
+			zbx_mutex_unlock(&proxy_tr_lock);
+		}
+
 		DBbegin();
 
 		if (0 != (daemon_type & ZBX_DAEMON_TYPE_SERVER))
@@ -2339,6 +2349,13 @@ int	DCsync_history(int sync_type)
 
 		DBcommit();
 
+		if (0 != (daemon_type & ZBX_DAEMON_TYPE_PROXY))
+		{
+			zbx_mutex_lock(&proxy_tr_lock);
+			(*proxy_tr)--;
+			zbx_mutex_unlock(&proxy_tr_lock);
+		}
+
 		DCflush_nextchecks();
 
 		if (0 != (daemon_type & ZBX_DAEMON_TYPE_SERVER))
diff -uNrp zabbix-1.8.16-1.2.orig/src/zabbix_proxy/datasender/datasender.c zabbix-1.8.16-1.2/src/zabbix_proxy/datasender/datasender.c
--- zabbix-1.8.16-1.2.orig/src/zabbix_proxy/datasender/datasender.c	2013-01-16 23:10:08.000000000 +0900
+++ zabbix-1.8.16-1.2/src/zabbix_proxy/datasender/datasender.c	2013-02-20 07:19:25.660139811 +0900
@@ -31,6 +31,8 @@
 
 extern unsigned char	process_type;
 
+extern int		*proxy_tr;
+
 /******************************************************************************
  *                                                                            *
  * Function: host_availability_sender                                         *
@@ -143,6 +145,9 @@ void	main_datasender_loop()
 	int		records, r;
 	double		sec;
 	struct zbx_json	j;
+        /* 0.1 sec sleep */
+	struct timespec st = { .tv_sec = 0, .tv_nsec = 100 * 1000 * 1000};
+	int	pts, pts_o = 0;
 
 	zabbix_log(LOG_LEVEL_DEBUG, "In main_datasender_loop()");
 
@@ -162,6 +167,14 @@ void	main_datasender_loop()
 
 		records = 0;
 retry_history:
+		while (proxy_tr && (pts = *proxy_tr) > 0)
+                {
+			if (pts != pts_o)
+				zabbix_log(LOG_LEVEL_WARNING, "history syncer is in DCsync_history(): %d", pts);
+			pts_o = pts;
+
+			nanosleep(&st, NULL);
+                }
 		history_sender(&j, &r, ZBX_PROTO_VALUE_HISTORY_DATA,
 				proxy_get_hist_data, proxy_set_hist_lastid);
 		records += r;
diff -uNrp zabbix-1.8.16-1.2.orig/src/zabbix_proxy/proxy.c zabbix-1.8.16-1.2/src/zabbix_proxy/proxy.c
--- zabbix-1.8.16-1.2.orig/src/zabbix_proxy/proxy.c	2013-02-19 11:14:06.123383637 +0900
+++ zabbix-1.8.16-1.2/src/zabbix_proxy/proxy.c	2013-02-19 12:50:01.389133072 +0900
@@ -33,6 +33,7 @@
 
 #include "daemon.h"
 #include "zbxself.h"
+#include "ipc.h"
 
 #include "../zabbix_server/dbsyncer/dbsyncer.h"
 #include "../zabbix_server/discoverer/discoverer.h"
@@ -194,6 +195,10 @@ int	CONFIG_FIX_ACTION_MISMATCH	= 0; /* o
 /* Mutex for node syncs; not used in proxy */
 ZBX_MUTEX	node_sync_access;
 
+int		*proxy_tr;
+int		proxy_tr_id;
+ZBX_MUTEX	proxy_tr_lock;
+
 /******************************************************************************
  *                                                                            *
  * Function: zbx_set_defaults                                                 *
@@ -528,6 +533,54 @@ int	main(int argc, char **argv)
 	return daemon_start(CONFIG_ALLOW_ROOT);
 }
 
+static void init_proxy_tr(void)
+{
+	key_t shm_key;
+
+	if (-1 == (shm_key = zbx_ftok(CONFIG_FILE, ZBX_IPC_PROXY_TR_ID)))
+	{
+		zabbix_log(LOG_LEVEL_CRIT, "cannot create IPC key for Proxy Transaction Management");
+		exit(FAIL);
+	}
+
+	if (ZBX_MUTEX_ERROR == zbx_mutex_create_force(&proxy_tr_lock, ZBX_MUTEX_PROXY_TR))
+	{
+		zbx_error("unable to create mutex for Proxy Transaction Management");
+		exit(FAIL);
+	}
+
+	if (-1 == (proxy_tr_id = zbx_shmget(shm_key, sizeof(int))))
+	{
+		zabbix_log(LOG_LEVEL_CRIT, "cannot allocate shared memory for Proxy Transaction Management");
+		exit(FAIL);
+	}
+
+	if ((void *)(-1) == (proxy_tr = shmat(proxy_tr_id, NULL, 0)))
+	{
+		zabbix_log(LOG_LEVEL_CRIT, "cannot attach shared memory for Proxy Transaction Management: %s",
+				zbx_strerror(errno));
+		exit(FAIL);
+	}
+	*proxy_tr = 0;
+
+	return;
+}
+
+static void free_proxy_tr(void)
+{
+	zbx_mutex_lock(&proxy_tr_lock);
+	if (-1 == shmctl(proxy_tr_id, IPC_RMID, 0))
+	{
+		zabbix_log(LOG_LEVEL_WARNING, "cannot remove shared memory for Proxy Transaction Management: %s",
+				zbx_strerror(errno));
+	}
+	zbx_mutex_unlock(&proxy_tr_lock);
+
+	zbx_mutex_destroy(&proxy_tr_lock);
+
+	return;
+}
+
 int	MAIN_ZABBIX_ENTRY()
 {
 	int		i, proxy_num = 0, proxy_count = 0;
@@ -583,6 +636,8 @@ int	MAIN_ZABBIX_ENTRY()
 	init_configuration_cache();
 	init_selfmon_collector();
 
+	init_proxy_tr();
+
 	DBconnect(ZBX_DB_CONNECT_NORMAL);
 	DCsync_configuration();
 	DBclose();
@@ -802,6 +857,8 @@ void	zbx_on_exit()
 	php_sem_remove(&sqlite_access);
 #endif
 
+	free_proxy_tr();
+
 	free_selfmon_collector();
 
 	zabbix_log(LOG_LEVEL_INFORMATION, "Zabbix Proxy stopped. Zabbix %s (revision %s).",
diff -uNrp zabbix-1.8.16-1.2.orig/src/zabbix_server/server.c zabbix-1.8.16-1.2/src/zabbix_server/server.c
--- zabbix-1.8.16-1.2.orig/src/zabbix_server/server.c	2013-02-19 11:14:06.127410047 +0900
+++ zabbix-1.8.16-1.2/src/zabbix_server/server.c	2013-02-19 12:00:10.680244329 +0900
@@ -197,6 +197,9 @@ int	CONFIG_FIX_ACTION_MISMATCH	= 0; /* o
 /* Mutex for node syncs */
 ZBX_MUTEX	node_sync_access;
 
+int		*proxy_tr;
+ZBX_MUTEX	proxy_tr_lock;
+
 /******************************************************************************
  *                                                                            *
  * Function: zbx_load_config                                                  *
