Skip to content

Commit

Permalink
Merge branch 'issues/issue15'
Browse files Browse the repository at this point in the history
* issues/issue15:
  mysql: Add dependency columns to mxq_group table
  mxqadmin: Prevent groups that some group depends on to be reopened
  mxq_group: Add new flags to tag dependencies between groups
  • Loading branch information
mariux committed Aug 28, 2015
2 parents 2172543 + 7f513bb commit ea4b054
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mxq_group.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ struct mxq_group {

#define MXQ_GROUP_FLAG_CLOSED (1<<0)

#define MXQ_GROUP_FLAG_HAS_DEPENDENCY (1<<1)
#define MXQ_GROUP_FLAG_IS_DEPENDENCY (1<<2)

void mxq_group_free_content(struct mxq_group *g);

inline uint64_t mxq_group_jobs_done(struct mxq_group *g);
Expand Down
4 changes: 4 additions & 0 deletions mxqadmin.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,18 @@ static int update_group_flags_reopen(struct mx_mysql *mysql, uint64_t group_id,
struct mx_mysql_stmt *stmt = NULL;
unsigned long long num_rows = 0;
int res;
uint64_t flagsnottobeset;
uint64_t newflags = 0;

flagsnottobeset = MXQ_GROUP_FLAG_IS_DEPENDENCY;
newflags |= MXQ_GROUP_FLAG_CLOSED;

stmt = mx_mysql_statement_prepare(mysql,
"UPDATE mxq_group SET"
" group_flags = group_flags & ~(?)"
" WHERE group_id = ?"
" AND user_uid = ?"
" AND group_flags & ? = 0"
);
if (!stmt) {
mx_log_err("mx_mysql_statement_prepare(): %m");
Expand All @@ -136,6 +139,7 @@ static int update_group_flags_reopen(struct mx_mysql *mysql, uint64_t group_id,
res = mx_mysql_statement_param_bind(stmt, 0, uint64, &(newflags));
res += mx_mysql_statement_param_bind(stmt, 1, uint64, &(group_id));
res += mx_mysql_statement_param_bind(stmt, 2, uint32, &(user_uid));
res += mx_mysql_statement_param_bind(stmt, 3, uint64, &(flagsnottobeset));
assert(res == 0);

res = mx_mysql_statement_execute(stmt, &num_rows);
Expand Down
5 changes: 5 additions & 0 deletions mysql/alter_tables_0.13.0.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ALTER TABLE mxq_group
ADD COLUMN (
depends_on_group INT8 UNSIGNED NULL DEFAULT NULL,
dependency_of_group INT8 UNSIGNED NULL DEFAULT NULL
);
3 changes: 3 additions & 0 deletions mysql/create_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ CREATE TABLE IF NOT EXISTS mxq_group (
stats_total_real_sec_finished INT8 UNSIGNED NOT NULL DEFAULT 0,
stats_total_wait_sec_finished INT8 UNSIGNED NOT NULL DEFAULT 0,

depends_on_group INT8 UNSIGNED NULL DEFAULT NULL,
dependency_of_group INT8 UNSIGNED NULL DEFAULT NULL,

INDEX(group_id),
INDEX(group_name)
);
Expand Down

0 comments on commit ea4b054

Please sign in to comment.