Merge ~hyask/autopkgtest-cloud:skia/close_channels into autopkgtest-cloud:master

Proposed by Skia
Status: Merged
Merged at revision: 8f326e78896742cae6c4ba58dcf96d471be56b9e
Proposed branch: ~hyask/autopkgtest-cloud:skia/close_channels
Merge into: autopkgtest-cloud:master
Diff against target: 96 lines (+35/-32)
2 files modified
charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker (+3/-0)
charms/focal/autopkgtest-web/webcontrol/download-results (+32/-32)
Reviewer Review Type Date Requested Status
Brian Murray Approve
Review via email: mp+468265@code.launchpad.net

Description of the change

We hit a situation where RabbitMQ hit its `memory alarm` of 3GB (https://www.rabbitmq.com/docs/memory). Investigation showed a huge number of channels (+65k). Closing those two worker channels seems to stabilize the situation to around 1350 opened channels and 700MB of RAM, but we're not running at full capacity right now.

More channel closing might be required elsewhere, but those three are already a very good start.

EDIT after a night:
The closing of the additional channel in `download-results` stabilized the situation at about 900 opened channels.

EDIT after an additional day:
The situation seems to keep stable. I'm now opening this MP for review.

To post a comment you must log in.
Revision history for this message
Brian Murray (brian-murray) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker
2index e9bc152..7354be2 100755
3--- a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker
4+++ b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker
5@@ -603,6 +603,8 @@ def call_autopkgtest(
6 private,
7 )
8
9+ status_amqp.close()
10+
11 return ret
12
13
14@@ -1583,6 +1585,7 @@ def request(msg):
15 complete_amqp.basic_publish(
16 amqp.Message(complete_msg, delivery_mode=2), complete_exchange_name, ""
17 )
18+ complete_amqp.close()
19
20 logging.info("Acknowledging request %s" % body)
21 msg.channel.basic_ack(msg.delivery_tag)
22diff --git a/charms/focal/autopkgtest-web/webcontrol/download-results b/charms/focal/autopkgtest-web/webcontrol/download-results
23index 1297a66..2c4ea47 100755
24--- a/charms/focal/autopkgtest-web/webcontrol/download-results
25+++ b/charms/focal/autopkgtest-web/webcontrol/download-results
26@@ -76,38 +76,38 @@ def process_message(msg):
27 while True:
28 try:
29 # add to queue instead of writing to db
30- complete_amqp = amqp_con.channel()
31- complete_amqp.access_request(
32- "/complete", active=True, read=False, write=True
33- )
34- complete_amqp.exchange_declare(
35- SqliteWriterConfig.writer_exchange_name,
36- "fanout",
37- durable=True,
38- auto_delete=False,
39- )
40- write_me_msg = {
41- "run_id": run_id,
42- "version": version,
43- "triggers": triggers,
44- "duration": duration,
45- "exitcode": exitcode,
46- "requester": requester,
47- "env": info.get("env", ""),
48- "uuid": test_uuid,
49- "release": release,
50- "arch": arch,
51- "package": package,
52- }
53- complete_amqp.basic_publish(
54- amqp.Message(json.dumps(write_me_msg), delivery_mode=2),
55- SqliteWriterConfig.writer_exchange_name,
56- "",
57- )
58-
59- msg.channel.basic_ack(msg.delivery_tag)
60- return
61- except Exception as _:
62+ with amqp_con.channel() as complete_amqp:
63+ complete_amqp.access_request(
64+ "/complete", active=True, read=False, write=True
65+ )
66+ complete_amqp.exchange_declare(
67+ SqliteWriterConfig.writer_exchange_name,
68+ "fanout",
69+ durable=True,
70+ auto_delete=False,
71+ )
72+ write_me_msg = {
73+ "run_id": run_id,
74+ "version": version,
75+ "triggers": triggers,
76+ "duration": duration,
77+ "exitcode": exitcode,
78+ "requester": requester,
79+ "env": info.get("env", ""),
80+ "uuid": test_uuid,
81+ "release": release,
82+ "arch": arch,
83+ "package": package,
84+ }
85+ complete_amqp.basic_publish(
86+ amqp.Message(json.dumps(write_me_msg), delivery_mode=2),
87+ SqliteWriterConfig.writer_exchange_name,
88+ "",
89+ )
90+
91+ msg.channel.basic_ack(msg.delivery_tag)
92+ return
93+ except Exception:
94 time.sleep(3)
95 now = datetime.datetime.now()
96 if (

Subscribers

People subscribed via source and target branches

to all changes: