diff --git a/main/lib/idds/core/health.py b/main/lib/idds/core/health.py index 074f0e62..90777379 100644 --- a/main/lib/idds/core/health.py +++ b/main/lib/idds/core/health.py @@ -96,6 +96,6 @@ def select_agent(name, newer_than=3600, session=None): if selected_agent['status'] != HealthStatus.Active: orm_health.update_health_item_status(selected_agent, status=HealthStatus.Active, session=session) for health_item in health_items: - if health_item['status'] == HealthStatus.Active and health_item != selected_agent: + if health_item['agent'] == name and health_item['status'] == HealthStatus.Active and health_item['health_id'] != selected_agent['health_id']: orm_health.update_health_item_status(selected_agent, status=HealthStatus.Default, session=session) return selected_agent diff --git a/main/lib/idds/orm/base/alembic/versions/6ca0e5e466eb_update_message_null_constraints.py b/main/lib/idds/orm/base/alembic/versions/6ca0e5e466eb_update_message_null_constraints.py index b477aa3e..45272c82 100644 --- a/main/lib/idds/orm/base/alembic/versions/6ca0e5e466eb_update_message_null_constraints.py +++ b/main/lib/idds/orm/base/alembic/versions/6ca0e5e466eb_update_message_null_constraints.py @@ -17,7 +17,6 @@ """ from alembic import op from alembic import context -import sqlalchemy as sa # revision identifiers, used by Alembic. @@ -30,14 +29,15 @@ def upgrade() -> None: if context.get_context().dialect.name in ['oracle', 'mysql', 'postgresql']: schema = context.get_context().version_table_schema if context.get_context().version_table_schema else '' - op.alter_column('messages', sa.Column('request_id'), nullable=True, schema=schema) - op.alter_column('messages', sa.Column('transform_id'), nullable=True, schema=schema) - op.alter_column('messages', sa.Column('processing_id'), nullable=True, schema=schema) + op.alter_column('messages', 'request_id', nullable=True, schema=schema) + op.alter_column('messages', 'transform_id', nullable=True, schema=schema) + op.alter_column('messages', 'processing_id', nullable=True, schema=schema) def downgrade() -> None: if context.get_context().dialect.name in ['oracle', 'mysql', 'postgresql']: schema = context.get_context().version_table_schema if context.get_context().version_table_schema else '' - op.alter_column('messages', sa.Column('request_id'), nullable=False, schema=schema) - op.alter_column('messages', sa.Column('transform_id'), nullable=False, schema=schema) - op.alter_column('messages', sa.Column('processing_id'), nullable=False, schema=schema) + # here doesn't update nullable to False, since the table may have null rows which will cause failure. + op.alter_column('messages', 'request_id', nullable=True, schema=schema) + op.alter_column('messages', 'transform_id', nullable=True, schema=schema) + op.alter_column('messages', 'processing_id', nullable=True, schema=schema)