File TODO changed (mode: 100644) (index e90fc19..a1ad6b5) |
88 |
88 |
machine reporting the load (see rg_stats_insert)! |
machine reporting the load (see rg_stats_insert)! |
89 |
89 |
[ ] @@if - if it is the only thing on a line, remove \n, else, do not. |
[ ] @@if - if it is the only thing on a line, remove \n, else, do not. |
90 |
90 |
[ ] Document worker proxy-tls connection type and nginx sample (check cloud.conf). |
[ ] Document worker proxy-tls connection type and nginx sample (check cloud.conf). |
91 |
|
[ ] Add admin Settings entries for slave_clean_table_* and for how much to keep |
|
|
91 |
|
[ ] Add admin Settings entries for parts_clean_table_* and for how much to keep |
92 |
92 |
the logs. |
the logs. |
93 |
93 |
[ ] Add network statistics. Not clear how to obtain them easily. |
[ ] Add network statistics. Not clear how to obtain them easily. |
94 |
94 |
[ ] Discover: should we have the 'Public' column? |
[ ] Discover: should we have the 'Public' column? |
|
... |
... |
to add a worker? Also, no hint is presented. |
1915 |
1915 |
[ ] Accessing a file with '"' inside, is not working. |
[ ] Accessing a file with '"' inside, is not working. |
1916 |
1916 |
See rocketgit.com/user/catalinux/test1/source/tree/blob/"xx\"yy" |
See rocketgit.com/user/catalinux/test1/source/tree/blob/"xx\"yy" |
1917 |
1917 |
[ ] Present bugs as a git repo, so we easily add a new one by push? |
[ ] Present bugs as a git repo, so we easily add a new one by push? |
1918 |
|
[ ] Configuration: a number of months to keep history (see slaves). |
|
1919 |
1918 |
[ ] vagrant install? |
[ ] vagrant install? |
1920 |
1919 |
[ ] If I generated some activity on an object, do not notify myself. |
[ ] If I generated some activity on an object, do not notify myself. |
1921 |
1920 |
[ ] Show the age of a repo/user/bug/etc. Hm. This will prevent the caching. |
[ ] Show the age of a repo/user/bug/etc. Hm. This will prevent the caching. |
|
... |
... |
But, we have a problem with the expiration time! |
2452 |
2451 |
[ ] Add a maximum time to keep logs. |
[ ] Add a maximum time to keep logs. |
2453 |
2452 |
[ ] Do not allow double ssh keys in database! Because when we output them |
[ ] Do not allow double ssh keys in database! Because when we output them |
2454 |
2453 |
in authorized_keys ssh will use the first one! |
in authorized_keys ssh will use the first one! |
2455 |
|
[ ] Move everything 1 month back to simulate next month for slave tables. |
|
|
2454 |
|
[ ] Move everything 1 month back to simulate next month for part tables. |
2456 |
2455 |
Better, do a unit test. |
Better, do a unit test. |
2457 |
2456 |
[ ] To not wake up many times (for every sub-event), cache what was done |
[ ] To not wake up many times (for every sub-event), cache what was done |
2458 |
2457 |
(or max(id)) and ignore that wake-ups. Of course, W will become W<ev_id>. |
(or max(id)) and ignore that wake-ups. Of course, W will become W<ev_id>. |
File inc/struct.inc.php changed (mode: 100644) (index 6e0db53..891ff5e) |
... |
... |
include_once($INC . "/util.inc.php"); |
6 |
6 |
define("RG_DROP_TABLES", 1); |
define("RG_DROP_TABLES", 1); |
7 |
7 |
define("RG_IGNORE_ERRORS", 1 << 1); |
define("RG_IGNORE_ERRORS", 1 << 1); |
8 |
8 |
|
|
9 |
|
$rg_sql_struct_slaves = array(); |
|
|
9 |
|
$rg_sql_struct_parts = array(); |
10 |
10 |
$rg_sql_struct = array(); |
$rg_sql_struct = array(); |
11 |
11 |
$rg_sql_struct[1] = array(); |
$rg_sql_struct[1] = array(); |
12 |
12 |
$rg_sql_struct[1]['tables'] = array( |
$rg_sql_struct[1]['tables'] = array( |
|
... |
... |
$rg_sql_struct[10]['tables'] = array( |
207 |
207 |
. ", message TEXT NOT NULL)" |
. ", message TEXT NOT NULL)" |
208 |
208 |
); |
); |
209 |
209 |
$rg_sql_struct[10]['other'] = array(); |
$rg_sql_struct[10]['other'] = array(); |
210 |
|
$rg_sql_struct_slaves['repo_history'] = array(); |
|
|
210 |
|
$rg_sql_struct_parts['repo_history'] = array(); |
211 |
211 |
|
|
212 |
212 |
$rg_sql_struct[11] = array(); |
$rg_sql_struct[11] = array(); |
213 |
213 |
$rg_sql_struct[11]['tables'] = array( |
$rg_sql_struct[11]['tables'] = array( |
|
... |
... |
$rg_sql_struct[45]['other'] = array( |
669 |
669 |
'worker_stats id' => |
'worker_stats id' => |
670 |
670 |
'CREATE INDEX worker_stats_i_worker_id on worker_stats(worker_id)' |
'CREATE INDEX worker_stats_i_worker_id on worker_stats(worker_id)' |
671 |
671 |
); |
); |
672 |
|
$rg_sql_struct_slaves['stats'] = array(); |
|
673 |
|
$rg_sql_struct_slaves['worker_stats'] = array('extra_index' => array('worker_id')); |
|
674 |
|
$rg_sql_struct_slaves['conns'] = array(); |
|
|
672 |
|
$rg_sql_struct_parts['stats'] = array(); |
|
673 |
|
$rg_sql_struct_parts['worker_stats'] = array('extra_index' => array('worker_id')); |
|
674 |
|
$rg_sql_struct_parts['conns'] = array(); |
675 |
675 |
// Here, 0.72 was released. |
// Here, 0.72 was released. |
676 |
676 |
|
|
677 |
677 |
$rg_sql_struct[46] = array(); |
$rg_sql_struct[46] = array(); |
|
... |
... |
function rg_sql_struct_update($db, $flags) |
865 |
865 |
} |
} |
866 |
866 |
|
|
867 |
867 |
/* |
/* |
868 |
|
* Update slaves (postgresql partitions) |
|
|
868 |
|
* Update partitions table |
869 |
869 |
* Returns FALSE in case of error |
* Returns FALSE in case of error |
870 |
870 |
*/ |
*/ |
871 |
|
function rg_sql_struct_slaves_update($db) |
|
|
871 |
|
function rg_sql_struct_parts_update($db) |
872 |
872 |
{ |
{ |
873 |
|
global $rg_sql_struct_slaves; |
|
|
873 |
|
global $rg_sql_struct_parts; |
874 |
874 |
|
|
875 |
|
rg_prof_start('sql_struct_slaves_update'); |
|
876 |
|
rg_log_enter('sql_struct_slaves_update'); |
|
|
875 |
|
rg_prof_start('sql_struct_parts_update'); |
|
876 |
|
rg_log_enter('sql_struct_parts_update'); |
877 |
877 |
|
|
878 |
878 |
$ret = FALSE; |
$ret = FALSE; |
879 |
879 |
$doit = FALSE; |
$doit = FALSE; |
880 |
880 |
while (1) { |
while (1) { |
881 |
|
if (empty($rg_sql_struct_slaves)) { |
|
|
881 |
|
if (empty($rg_sql_struct_parts)) { |
882 |
882 |
$ret = TRUE; |
$ret = TRUE; |
883 |
883 |
break; |
break; |
884 |
884 |
} |
} |
885 |
885 |
|
|
886 |
|
$last_list = rg_state_get($db, 'slaves_create_last_list'); |
|
|
886 |
|
$last_list = rg_state_get($db, 'parts_create_last_list'); |
887 |
887 |
if ($last_list === FALSE) |
if ($last_list === FALSE) |
888 |
888 |
break; |
break; |
889 |
889 |
|
|
890 |
|
$last_ts = rg_state_get_uint($db, 'slaves_create_last_ts'); |
|
|
890 |
|
$last_ts = rg_state_get_uint($db, 'parts_create_last_ts'); |
891 |
891 |
if ($last_ts === FALSE) |
if ($last_ts === FALSE) |
892 |
892 |
break; |
break; |
893 |
893 |
if ($last_ts == 0) |
if ($last_ts == 0) |
894 |
894 |
$last_ts = gmmktime(0, 0, 0, gmdate('m') - 1, 1, gmdate('Y')); |
$last_ts = gmmktime(0, 0, 0, gmdate('m') - 1, 1, gmdate('Y')); |
895 |
895 |
rg_log('DEBUG: last_ts=' . $last_ts . ' (' . gmdate('Y-m-d', $last_ts) . ')'); |
rg_log('DEBUG: last_ts=' . $last_ts . ' (' . gmdate('Y-m-d', $last_ts) . ')'); |
896 |
896 |
|
|
897 |
|
$cur_list = sha1(rg_serialize($rg_sql_struct_slaves)); |
|
|
897 |
|
$cur_list = sha1(rg_serialize($rg_sql_struct_parts)); |
898 |
898 |
rg_log('DEBUG: last_list=[' . $last_list . '] cur_list=[' . $cur_list . ']'); |
rg_log('DEBUG: last_list=[' . $last_list . '] cur_list=[' . $cur_list . ']'); |
899 |
899 |
if (strcmp($last_list, $cur_list) != 0) { |
if (strcmp($last_list, $cur_list) != 0) { |
900 |
900 |
// We need to set last_ts to first day of the previous month |
// We need to set last_ts to first day of the previous month |
901 |
901 |
$last_ts = gmmktime(0, 0, 0, gmdate('m') - 1, 1, gmdate('Y')); |
$last_ts = gmmktime(0, 0, 0, gmdate('m') - 1, 1, gmdate('Y')); |
902 |
|
rg_log('DEBUG: list of the slaves changed. Set last_ts to ' . $last_ts); |
|
|
902 |
|
rg_log('DEBUG: list of the parts changed. Set last_ts to ' . $last_ts); |
903 |
903 |
$doit = TRUE; |
$doit = TRUE; |
904 |
904 |
break; |
break; |
905 |
905 |
} |
} |
|
... |
... |
function rg_sql_struct_slaves_update($db) |
926 |
926 |
$locked = FALSE; |
$locked = FALSE; |
927 |
927 |
while ($doit) { |
while ($doit) { |
928 |
928 |
// If we cannot lock, return error |
// If we cannot lock, return error |
929 |
|
if (rg_lock('slave_create.lock') === FALSE) |
|
|
929 |
|
if (rg_lock('parts_create.lock') === FALSE) |
930 |
930 |
break; |
break; |
931 |
931 |
$locked = TRUE; |
$locked = TRUE; |
932 |
932 |
|
|
|
... |
... |
function rg_sql_struct_slaves_update($db) |
946 |
946 |
$month++; |
$month++; |
947 |
947 |
$next_ts = gmmktime(0, 0, 0, $month, 1, $year); |
$next_ts = gmmktime(0, 0, 0, $month, 1, $year); |
948 |
948 |
|
|
949 |
|
foreach ($rg_sql_struct_slaves as $table => $ti) { |
|
950 |
|
$slave_table = $table . '_' . gmdate('Y_m', $ts); |
|
951 |
|
rg_log('Creating table ' . $slave_table); |
|
|
949 |
|
foreach ($rg_sql_struct_parts as $table => $ti) { |
|
950 |
|
$part_table = $table . '_' . gmdate('Y_m', $ts); |
|
951 |
|
rg_log('Creating table ' . $part_table); |
952 |
952 |
|
|
953 |
953 |
// First, check if exists. It is possible that |
// First, check if exists. It is possible that |
954 |
954 |
// we did the update but we could not set the cache. |
// we did the update but we could not set the cache. |
955 |
955 |
$sql = 'SELECT 1 FROM pg_class' |
$sql = 'SELECT 1 FROM pg_class' |
956 |
|
. ' WHERE relname = \'' . $slave_table . '\''; |
|
|
956 |
|
. ' WHERE relname = \'' . $part_table . '\''; |
957 |
957 |
$res = rg_sql_query($db, $sql); |
$res = rg_sql_query($db, $sql); |
958 |
958 |
if ($res === FALSE) { |
if ($res === FALSE) { |
959 |
959 |
$ok = FALSE; |
$ok = FALSE; |
|
... |
... |
function rg_sql_struct_slaves_update($db) |
966 |
966 |
continue; |
continue; |
967 |
967 |
} |
} |
968 |
968 |
|
|
969 |
|
$sql = 'CREATE TABLE ' . $slave_table |
|
|
969 |
|
$sql = 'CREATE TABLE ' . $part_table |
970 |
970 |
. ' (CHECK(itime >= ' . $ts . ' AND itime <= ' . ($next_ts - 1) . '))' |
. ' (CHECK(itime >= ' . $ts . ' AND itime <= ' . ($next_ts - 1) . '))' |
971 |
971 |
. ' INHERITS (' . $table . ')'; |
. ' INHERITS (' . $table . ')'; |
972 |
972 |
$res = rg_sql_query($db, $sql); |
$res = rg_sql_query($db, $sql); |
|
... |
... |
function rg_sql_struct_slaves_update($db) |
976 |
976 |
} |
} |
977 |
977 |
rg_sql_free_result($res); |
rg_sql_free_result($res); |
978 |
978 |
|
|
979 |
|
$sql = 'CREATE INDEX ' . $slave_table . '_i_itime' |
|
980 |
|
. ' ON ' . $slave_table |
|
|
979 |
|
$sql = 'CREATE INDEX ' . $part_table . '_i_itime' |
|
980 |
|
. ' ON ' . $part_table |
981 |
981 |
. ' (itime)'; |
. ' (itime)'; |
982 |
982 |
$res = rg_sql_query($db, $sql); |
$res = rg_sql_query($db, $sql); |
983 |
983 |
if ($res === FALSE) { |
if ($res === FALSE) { |
|
... |
... |
function rg_sql_struct_slaves_update($db) |
988 |
988 |
|
|
989 |
989 |
if (isset($ti['extra_index'])) { |
if (isset($ti['extra_index'])) { |
990 |
990 |
foreach ($ti['extra_index'] as $i) { |
foreach ($ti['extra_index'] as $i) { |
991 |
|
$sql = 'CREATE INDEX ' . $slave_table . '_i_' . $i |
|
992 |
|
. ' ON ' . $slave_table |
|
|
991 |
|
$sql = 'CREATE INDEX ' . $part_table . '_i_' . $i |
|
992 |
|
. ' ON ' . $part_table |
993 |
993 |
. ' (' . $i . ')'; |
. ' (' . $i . ')'; |
994 |
994 |
$res = rg_sql_query($db, $sql); |
$res = rg_sql_query($db, $sql); |
995 |
995 |
if ($res === FALSE) { |
if ($res === FALSE) { |
|
... |
... |
function rg_sql_struct_slaves_update($db) |
1010 |
1010 |
if ($ok !== TRUE) |
if ($ok !== TRUE) |
1011 |
1011 |
break; |
break; |
1012 |
1012 |
|
|
1013 |
|
$r = rg_state_set($db, 'slaves_create_last_ts', $stop_ts); |
|
|
1013 |
|
$r = rg_state_set($db, 'parts_create_last_ts', $stop_ts); |
1014 |
1014 |
if ($r !== TRUE) { |
if ($r !== TRUE) { |
1015 |
|
rg_log('Cannot set slaves_create_last_ts (' . rg_state_error() . ')'); |
|
|
1015 |
|
rg_log('Cannot set parts_create_last_ts (' . rg_state_error() . ')'); |
1016 |
1016 |
break; |
break; |
1017 |
1017 |
} |
} |
1018 |
1018 |
|
|
1019 |
|
$r = rg_state_set($db, 'slaves_create_last_list', $cur_list); |
|
|
1019 |
|
$r = rg_state_set($db, 'parts_create_last_list', $cur_list); |
1020 |
1020 |
if ($r !== TRUE) { |
if ($r !== TRUE) { |
1021 |
|
rg_log('Cannot set slaves_create_last_list (' . rg_state_error() . ')'); |
|
|
1021 |
|
rg_log('Cannot set parts_create_last_list (' . rg_state_error() . ')'); |
1022 |
1022 |
break; |
break; |
1023 |
1023 |
} |
} |
1024 |
1024 |
|
|
|
... |
... |
function rg_sql_struct_slaves_update($db) |
1034 |
1034 |
rg_sql_rollback($db); |
rg_sql_rollback($db); |
1035 |
1035 |
|
|
1036 |
1036 |
if ($locked === TRUE) |
if ($locked === TRUE) |
1037 |
|
rg_unlock('slave_create.lock'); |
|
|
1037 |
|
rg_unlock('parts_create.lock'); |
1038 |
1038 |
|
|
1039 |
1039 |
rg_log_exit(); |
rg_log_exit(); |
1040 |
|
rg_prof_end('sql_struct_slaves_update'); |
|
|
1040 |
|
rg_prof_end('sql_struct_parts_update'); |
1041 |
1041 |
return $ret; |
return $ret; |
1042 |
1042 |
} |
} |
1043 |
1043 |
|
|
|
... |
... |
function rg_struct_ok($db) |
1070 |
1070 |
rg_cache_restart(); |
rg_cache_restart(); |
1071 |
1071 |
} |
} |
1072 |
1072 |
|
|
1073 |
|
$r = rg_sql_struct_slaves_update($db); |
|
|
1073 |
|
$r = rg_sql_struct_parts_update($db); |
1074 |
1074 |
if ($r !== TRUE) |
if ($r !== TRUE) |
1075 |
1075 |
break; |
break; |
1076 |
1076 |
|
|