Agent registration is not transactional

Bug #1424337 reported by Ovais Tariq
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
twindb-agent
In Progress
Undecided
Aleksandr Kuzminsky

Bug Description

When the agent tries to register and the registration fails after twindb server has stored the information of the server running the agent, then the agent is in a broken state. Because twindb server has a record for the server running the agent, but the agent having failed the registration can only be unregistered.

Whenever agent registration fails, the twindb server should be notified so that it can undo the record it inserts in the `server` table.

[root@server55-dev-centos-65 twindb-agent]# twindb --unregister 0f6714f735a06a488ec9279f59d0a3f2 --user test --password test
2015-02-22 07:34:54,542: twindb: INFO: action_handler_unregister():1219: The server is successfully unregistered
2015-02-22 07:34:55,039: twindb: INFO: stop():2084: Shutting down TwinDB agent
2015-02-22 07:34:55,483: twindb: INFO: stop():2087: Pid file /var/run/twindb.pid does not exist. Probably twindb agent isn't running
[root@server55-dev-centos-65 twindb-agent]# twindb --register 0f6714f735a06a488ec9279f59d0a3f2 --user test --password test
2015-02-22 07:34:57,994: twindb: INFO: action_handler_register():1092: Registering TwinDB agent with code 0f6714f735a06a488ec9279f59d0a3f2
2015-02-22 07:34:58,423: twindb: INFO: action_handler_register():1093: The agent needs to generate cryptographically strong keys.
2015-02-22 07:34:58,835: twindb: INFO: action_handler_register():1094: It may take really, really long time. Please be patient.
2015-02-22 07:34:59,257: twindb: INFO: action_handler_register():1099: Reading GPG public key of <email address hidden>.
2015-02-22 07:34:59,668: twindb: INFO: action_handler_register():1117: Reading SSH public key from /root/.ssh/twindb.key.pub.
2015-02-22 07:35:00,540: twindb: INFO: action_handler_register():1162: Received successful response to register an agent
2015-02-22 07:35:01,537: twindb: INFO: get_config():624: Got config:
{
    "config_id": "6",
    "mysql_password": "********",
    "mysql_user": "twindb_agent",
    "retention_policy_id": "6",
    "schedule_id": "6",
    "user_id": "6",
    "volume_id": "6"
}
2015-02-22 07:35:01,985: twindb: ERROR: create_agent_user():1186: Failed to create MySQL user twindb_agent@localhost for TwinDB agent
2015-02-22 07:35:02,441: twindb: ERROR: create_agent_user():1187: MySQL replied: Access denied for user 'test'@'localhost' to database 'mysql'

[root@server55-dev-centos-65 twindb-agent]# twindb --register 0f6714f735a06a488ec9279f59d0a3f2 --user test --password test
2015-02-22 07:37:07,155: twindb: INFO: action_handler_register():1092: Registering TwinDB agent with code 0f6714f735a06a488ec9279f59d0a3f2
2015-02-22 07:37:07,588: twindb: INFO: action_handler_register():1093: The agent needs to generate cryptographically strong keys.
2015-02-22 07:37:07,999: twindb: INFO: action_handler_register():1094: It may take really, really long time. Please be patient.
2015-02-22 07:37:08,417: twindb: INFO: action_handler_register():1099: Reading GPG public key of <email address hidden>.
2015-02-22 07:37:08,894: twindb: INFO: action_handler_register():1117: Reading SSH public key from /root/.ssh/twindb.key.pub.
2015-02-22 07:37:09,897: twindb: ERROR: action_handler_register():1166: Failed to register the agent: Error while sending query 'INSERT INTO `server`(`server_id`, `user_id`, `name`, `ssh_public_key`, `enc_public_key`, `config_id`, `last_seen_at`, `mysql_server_id`, `mysql_master_host`, `mysql_master_server_id`, `mysql_seconds_behind_master`, `mysql_slave_io_running`, `mysql_slave_sql_running`) VALUES('7a577b78-a86b-4505-8f47-c3a5c986b275', 6, 'server55-dev-centos-65.vagrantup.com', 'ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAuq8Gh1feFHz7LedUobltLUECLfMuYDls9Gvn8NJzgwEFtHjfgXroCX6SGnXxT4jfp3oT2qAtZEjAtbFzkL0CMqpr/oy7jDSwrNFMXED6o7sbsHl2ABnH7lztiHihVyVe9p4JEg4vOpGpiCkPJjw/4Y64iW6cD2zTTwDGpX62+3ICDs7evtizRSFmkN6K1cJ9Vs/Y7JGd6GLaXq2hl32v4HaC5I7NNijhiNcI8Q9En/16/ydZ+gNwaklrr/MBvUAJDf20/EXYDR5UsbNNzIl3MDKbnNGUTTk+4KiJFFJxWkxwrzPPxHTv5QDKgZrm79i59fxtIfKSHLEiBIdvl0v0+Q== <email address hidden>\n', '-----BEGIN PGP PUBLIC KEY BLOCK-----\n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Xil\n-----END PGP PUBLIC KEY BLOCK-----\n', 6, NOW(), NULL, NULL, NULL, NULL, NULL, NULL)'. MySQL replied: Duplicate entry '7a577b78-a86b-4505-8f47-c3a5c986b275' for key 'PRIMARY'

Changed in twindb-agent:
milestone: none → 0.1.33
Changed in twindb-agent:
status: New → Confirmed
Changed in twindb-agent:
milestone: 0.1.33 → 0.1.34
Changed in twindb-agent:
milestone: 0.1.34 → 0.1.35
Changed in twindb-agent:
milestone: 0.1.35 → none
Changed in twindb-agent:
milestone: none → 0.1.36
assignee: nobody → Aleksandr Kuzminsky (akuzminsky)
Changed in twindb:
status: New → In Progress
assignee: nobody → Aleksandr Kuzminsky (akuzminsky)
milestone: none → 0.4.4
Changed in twindb-agent:
status: Confirmed → In Progress
Changed in twindb:
status: In Progress → Fix Committed
information type: Private → Public
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers