Comments (15)
True. And update a scheduler task happens only when an id
is provided.
But it would be helpful if we provide a proxysql_scheduler_info
module to determine ids.
from community.proxysql.
And update a scheduler task happens only when an id is provided.
or when a user defined it originally (is it possible to set it when creating the task?), they can manipulate tasks using those ids later
Yes, I think it is possible. I just wanted to point out, if the id
is not provided, all we can do is creating a new scheduler task.
So idempotent behavior is only possible when the id
is provided.
from community.proxysql.
So far, I've solved the problem by adding a task that will delete all the schedules before adding them, but this is a temporary crutch, and not a normal solution, as it seems to me.
- name: proxysql - clean proxysql scheduler
community.mysql.mysql_query:
login_user: "{{ proxysql.admin.user }}"
login_password: "{{ proxysql.admin.password }}"
login_host: 127.0.0.1
login_port: "{{ proxysql.admin.listen.port.plain | int }}"
query:
- "DELETE FROM scheduler"
- "SAVE SCHEDULER TO DISK"
tags:
- proxysql-scheduler
- name: proxysql - configure scheduler
proxysql_scheduler:
login_user: "{{ proxysql.admin.user }}"
login_password: "{{ proxysql.admin.password }}"
login_port: "{{ proxysql.admin.listen.port.plain | int }}"
filename: "{{ proxysql.path.lib }}/{{ item.bin }}"
interval_ms: "{{ item.interval }}"
...
from community.proxysql.
proxysql_scheduler
search for the entry with
SELECT count(*) AS `schedule_count`
FROM scheduler
WHERE active = %s
AND interval_ms = %s
AND filename = %s"""
so when you request the same task-parameters just with active: no
, it won't find and create a new one.
the only option to solve this issue is, to treat only the filename
column as a unique key. even if it is not. otherwise it is impossible to tell if you want to add a new schedule task or adjust the existing one.
current scheduler table looks like this
CREATE TABLE scheduler (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
active INT CHECK (active IN (0,1)) NOT NULL DEFAULT 1,
interval_ms INTEGER CHECK (interval_ms>=100 AND interval_ms<=100000000) NOT NULL,
filename VARCHAR NOT NULL,
arg1 VARCHAR,
arg2 VARCHAR,
arg3 VARCHAR,
arg4 VARCHAR,
arg5 VARCHAR,
comment VARCHAR NOT NULL DEFAULT '')
say you got this
ProxySQL> select * from scheduler;
+----+--------+-------------+---------------------------------+-----------+------+------+---------+-------------------------------------+---------+
| id | active | interval_ms | filename | arg1 | arg2 | arg3 | arg4 | arg5 | comment |
+----+--------+-------------+---------------------------------+-----------+------+------+---------+-------------------------------------+---------+
| 1 | 1 | 5000 | /opt/lib/proxysql/replica_check | 127.0.0.1 | 7030 | 2 | warning | /opt/log/proxysql/replica_check.log | |
+----+--------+-------------+---------------------------------+-----------+------+------+---------+-------------------------------------+---------+
and request
- name: some scheduler task
proxysql_scheduler:
filename: /opt/lib/proxysql/replica_check
interval_ms: 5000
arg1: "127.0.0.1"
arg2: 7030
arg3: 2
arg4: error
arg5: /opt/log/proxysql/replica_check.log
state: present
active: yes
load_to_runtime: true
save_to_disk: true
it is undefined if you want a)
ProxySQL> select * from scheduler;
+----+--------+-------------+---------------------------------+-----------+------+------+---------+-------------------------------------+---------+
| id | active | interval_ms | filename | arg1 | arg2 | arg3 | arg4 | arg5 | comment |
+----+--------+-------------+---------------------------------+-----------+------+------+---------+-------------------------------------+---------+
| 1 | 1 | 5000 | /opt/lib/proxysql/replica_check | 127.0.0.1 | 7030 | 2 | error | /opt/log/proxysql/replica_check.log | |
+----+--------+-------------+---------------------------------+-----------+------+------+---------+-------------------------------------+---------+
or b)
ProxySQL> select * from scheduler;
+----+--------+-------------+---------------------------------+-----------+------+------+---------+-------------------------------------+---------+
| id | active | interval_ms | filename | arg1 | arg2 | arg3 | arg4 | arg5 | comment |
+----+--------+-------------+---------------------------------+-----------+------+------+---------+-------------------------------------+---------+
| 1 | 1 | 5000 | /opt/lib/proxysql/replica_check | 127.0.0.1 | 7030 | 2 | warning | /opt/log/proxysql/replica_check.log | |
| 2 | 1 | 5000 | /opt/lib/proxysql/replica_check | 127.0.0.1 | 7030 | 2 | error | /opt/log/proxysql/replica_check.log | |
+----+--------+-------------+---------------------------------+-----------+------+------+---------+-------------------------------------+---------+
the current implementation treats active
, interval_ms
and filename
as one combined private key.
Another possibility is to abuse the comment
column with some conventions....find task by comment that must be uniq.
Any other ideas or opinions about this? @akimrx @Andersson007
from community.proxysql.
CC @bmildren
from community.proxysql.
Can we:
- add the
id
field (optional) as was suggested? I think it will break nothing backwards
from community.proxysql.
or when a user defined it originally (is it possible to set it when creating the task?), they can manipulate tasks using those ids later
from community.proxysql.
True. And update a scheduler task happens only when an
id
is provided.
But it would be helpful if we provide aproxysql_scheduler_info
module to determine ids.
But it's always a good idea to have info modules. It's also possible to create one proxysql_info
module like in mysql_info
which will return all the information from the cluster. But I'm not against the separate modules as well
from community.proxysql.
I'm personally in favor of one module like mysql_info
from community.proxysql.
Yes, I think it is possible. I just wanted to point out, if the id is not provided, all we can do is creating a new scheduler task.
So idempotent behavior is only possible when the id is provided.
Yes and, imo, it should be reflected in the documentation
from community.proxysql.
Do we still need a proxysql_scheduler_info
module? Because proxysql_info
exists since 1.2.0
- name: Add a schedule
community.proxysql.proxysql_scheduler:
login_user: 'admin'
login_password: 'admin'
interval_ms: 1000
filename: "/opt/maintenance.py"
state: present
load_to_runtime: False
- name: readout
community.proxysql.proxysql_info:
login_user: admin
login_password: admin
register: proxysql_information
- debug:
var: proxysql_information.scheduler
results in
TASK [debug] ********************************************************************************************************************************************************************************************************************
ok: [proxysql] => {
"proxysql_information.scheduler": [
{
"active": "1",
"arg1": null,
"arg2": null,
"arg3": null,
"arg4": null,
"arg5": null,
"comment": "",
"filename": "/opt/maintenance.py",
"id": "1",
"interval_ms": "1000"
}
]
}
So the only task here is to fix the module itself, and not to add a _info module.
from community.proxysql.
So the only task here is to fix the module itself, and not to add a _info module.
Sounds very sensible to me
from community.proxysql.
here we discussed the behaviour of adding or updating schedule tasks and decided to fallback to a new id
parameter for updates.
So far so good.
Say now, we ended up here
ProxySQL> select * from scheduler;
+----+--------+-------------+---------------------------------+-----------+------+------+---------+-------------------------------------+---------+
| id | active | interval_ms | filename | arg1 | arg2 | arg3 | arg4 | arg5 | comment |
+----+--------+-------------+---------------------------------+-----------+------+------+---------+-------------------------------------+---------+
| 1 | 1 | 5000 | /opt/lib/proxysql/replica_check | 127.0.0.1 | 7030 | 2 | warning | /opt/log/proxysql/replica_check.log | |
| 2 | 1 | 5000 | /opt/lib/proxysql/replica_check | 127.0.0.1 | 7030 | 2 | error | /opt/log/proxysql/replica_check.log | |
+----+--------+-------------+---------------------------------+-----------+------+------+---------+-------------------------------------+---------+
and we'll request (basically from the example section)
- name: remove scheduler task
proxysql_scheduler:
filename: /opt/lib/proxysql/replica_check
config_file: '~/proxysql.cnf'
state: absent
Currently the module will fail because it found more than one rule. https://github.com/ansible-collections/community.proxysql/blob/main/plugins/modules/proxysql_scheduler.py#L391
To keep backwards compatiblity, we must create a 2nd absent
logic.
id
is mutually exclusive with all other parameters when state is absent.
And maybe we should think about to deprecate the current absent
logic, because it is very very limited.
from community.proxysql.
id is mutually exclusive with all other parameters when state is absent.
is this possible?
from community.proxysql.
id is mutually exclusive with all other parameters when state is absent.
is this possible?
- yep, just with a condition
if id and state != 'absent' then fail
or even alternatively we can just mention in the option's doc that it's ignored otherwise and ignore instead of failing - deprecation of logic in case of its limitation sounds good. If we gonna do that, we should
- announce it now as a breaking change (that it's coming in release blahblah)
- publish the announcement as a part of changelog fragment of the following release
- create the breaking PR
- merge it before the next major release
from community.proxysql.
Related Issues (20)
- proxysql_query_rules_fast_routing module can not update existed rules HOT 3
- Release 1.5.0
- CI maintenance
- Support gtid_port in proxysql_backend_servers
- CI: add --changed to ansible-test command
- proxysql_manage_config unexpectedly modifies system state in check mode HOT 2
- Consider using true/false for all booleans in docs HOT 1
- proxysql firewall support HOT 1
- Not all proxysql installd have a version() suffix HOT 2
- refactor save_config_to_disk() and load_config_to_runtime() HOT 4
- ProxySQL community pinboard HOT 4
- proxysql_mysql_query_rules becomes incompatible with 1.4.x since 1.1.0 HOT 5
- Expand github action integration test that it also runs against proxysql 1.4.15 HOT 1
- proxysql_mysql_users is not able to handle hashed passwords HOT 4
- add support for PROXYSQL TLS RELOAD HOT 5
- Important information for collection maintainers
- Install role need some maintenance HOT 3
- Release 2.0.0 plan HOT 2
- mysql.py. suffix in _version may not be an integer value ==> error HOT 3
- Ansible Contributor Summit. Tuesday, April 12, 2022.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from community.proxysql.