diff options
author | sasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-10-05 08:43:57 +0000 |
---|---|---|
committer | sasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-10-05 08:43:57 +0000 |
commit | a3ee144e22596c3aea1fab644ed4c93e4466608a (patch) | |
tree | cad8af3a645ea2ebcd4b9152c36fd4c403d80c7e /src/libs/zbxdbhigh/db.c | |
parent | 32f3020adc55fc013f8064921fe4c0e10f4deaa4 (diff) | |
download | zabbix-a3ee144e22596c3aea1fab644ed4c93e4466608a.tar.gz zabbix-a3ee144e22596c3aea1fab644ed4c93e4466608a.tar.xz zabbix-a3ee144e22596c3aea1fab644ed4c93e4466608a.zip |
- [ZBX-92] Distributed monitoring: overwriting new information
[svn merge svn://svn.zabbix.com/branches/1.4 -r4832:4836]
git-svn-id: svn://svn.zabbix.com/trunk@4837 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src/libs/zbxdbhigh/db.c')
-rw-r--r-- | src/libs/zbxdbhigh/db.c | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/src/libs/zbxdbhigh/db.c b/src/libs/zbxdbhigh/db.c index 36999a7e..e65450e7 100644 --- a/src/libs/zbxdbhigh/db.c +++ b/src/libs/zbxdbhigh/db.c @@ -1684,6 +1684,17 @@ zbx_uint64_t DBget_maxid(char *table, char *field) } } + if(sync == 1) + { + min = (zbx_uint64_t)__UINT64_C(100000000000000)*(zbx_uint64_t)CONFIG_NODEID+(zbx_uint64_t)__UINT64_C(100000000000)*(zbx_uint64_t)CONFIG_NODEID; + max = (zbx_uint64_t)__UINT64_C(100000000000000)*(zbx_uint64_t)CONFIG_NODEID+(zbx_uint64_t)__UINT64_C(100000000000)*(zbx_uint64_t)CONFIG_NODEID+(zbx_uint64_t)99999999999; + } + else + { + min = (zbx_uint64_t)__UINT64_C(100000000000000)*(zbx_uint64_t)CONFIG_NODEID; + max = (zbx_uint64_t)__UINT64_C(100000000000000)*(zbx_uint64_t)CONFIG_NODEID+(zbx_uint64_t)99999999999999; + } + do { result = DBselect("select nextid from ids where nodeid=%d and table_name='%s' and field_name='%s'", @@ -1691,21 +1702,10 @@ zbx_uint64_t DBget_maxid(char *table, char *field) table, field); row = DBfetch(result); - if(!row || DBis_null(row[0])==SUCCEED || !*row[0]) + if(!row) { DBfree_result(result); - if(sync == 1) - { - min = (zbx_uint64_t)__UINT64_C(100000000000000)*(zbx_uint64_t)CONFIG_NODEID+(zbx_uint64_t)__UINT64_C(100000000000)*(zbx_uint64_t)CONFIG_NODEID; - max = (zbx_uint64_t)__UINT64_C(100000000000000)*(zbx_uint64_t)CONFIG_NODEID+(zbx_uint64_t)__UINT64_C(100000000000)*(zbx_uint64_t)CONFIG_NODEID+(zbx_uint64_t)99999999999; - } - else - { - min = (zbx_uint64_t)__UINT64_C(100000000000000)*(zbx_uint64_t)CONFIG_NODEID; - max = (zbx_uint64_t)__UINT64_C(100000000000000)*(zbx_uint64_t)CONFIG_NODEID+(zbx_uint64_t)99999999999999; - } - result = DBselect("select max(%s) from %s where %s>="ZBX_FS_UI64" and %s<="ZBX_FS_UI64, field, table, @@ -1724,6 +1724,12 @@ zbx_uint64_t DBget_maxid(char *table, char *field) } else { + ZBX_STR2UINT64(ret1, row[0]); + if(ret1 >= max) { + zabbix_log(LOG_LEVEL_CRIT, "DBget_maxid: Maximum number of id's was exceeded [table:%s, field:%s, id:"ZBX_FS_UI64"]", table, field, ret1); + exit(FAIL); + } + DBexecute("insert into ids ( nodeid,table_name,field_name,nextid) values (%d,'%s','%s',%s)", CONFIG_NODEID, table, @@ -1738,6 +1744,14 @@ zbx_uint64_t DBget_maxid(char *table, char *field) ZBX_STR2UINT64(ret1, row[0]); DBfree_result(result); + if((ret1 < min) || (ret1 >= max)) { + DBexecute("delete from ids where nodeid=%d and table_name='%s' and field_name='%s'", + CONFIG_NODEID, + table, + field); + continue; + } + DBexecute("update ids set nextid=nextid+1 where nodeid=%d and table_name='%s' and field_name='%s'", CONFIG_NODEID, table, |