Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove topic overlap between the database and application topics #2

Merged
merged 2 commits into from
Mar 12, 2024

Conversation

dwaynebradley
Copy link
Contributor

Having both the database (piggybank.database.XXX) and application (piggybank.>) topics overlap subscription hierarchies causes random issues when trying to run nats req piggybank.database.XXX requests. Sometimes the requests are handled by the micro service's endpoint handler and sometimes they are handled by the group handlers for the database. See below:

❯ nats req piggybank.database.initialize ""
19:57:42 Sending request on "piggybank.database.initialize"
19:57:42 Received with rtt 2.283735ms
19:57:42 Status: 403

{"error":"database locked","Code":403}



piggybank on  main [📝] via 🐹 v1.22.1 
❯ nats req piggybank.database.initialize ""
19:57:53 Sending request on "piggybank.database.initialize"
19:57:53 Received with rtt 1.507074ms
19:57:53 Status: 403

{"error":"database locked","Code":403}



piggybank on  main [📝] via 🐹 v1.22.1 
❯ nats req piggybank.database.initialize ""
19:57:55 Sending request on "piggybank.database.initialize"
19:57:55 Received with rtt 5.134594ms
19:57:55 Status: 200

{"details":"iHDys5Y+ZwRAr7szyy527jiESx9HH93ToCAX11JthPU","Code":200}



piggybank on  main [📝] via 🐹 v1.22.1 
❯ nats req piggybank.database.unlock '{"database_key": "iHDys5Y+ZwRAr7szyy527jiESx9HH93ToCAX11JthPU"}'
19:59:00 Sending request on "piggybank.database.unlock"
19:59:00 Received with rtt 2.322842ms
19:59:00 Status: 403

{"error":"database locked","Code":403}



piggybank on  main [📝] via 🐹 v1.22.1 
❯ nats req piggybank.database.unlock '{"database_key": "iHDys5Y+ZwRAr7szyy527jiESx9HH93ToCAX11JthPU"}'
19:59:07 Sending request on "piggybank.database.unlock"
19:59:07 Received with rtt 1.399512ms
19:59:07 Status: 403

{"error":"database locked","Code":403}



piggybank on  main [📝] via 🐹 v1.22.1 
❯ nats req piggybank.database.unlock '{"database_key": "iHDys5Y+ZwRAr7szyy527jiESx9HH93ToCAX11JthPU"}'
19:59:09 Sending request on "piggybank.database.unlock"
19:59:09 Received with rtt 8.302866ms
19:59:09 Status: 200

{"details":"database successfully unlocked","Code":200}

I ran this test using both NATS 2.10.10 and 2.10.11 on both Debian 12 and openSUSE Tumbleweed and it behaves the same way across both distros and NATS versions.

If we keep the database and application topic subscriptions from overlapping, it solves the randomness issues.

piggybank on  main [📝] via 🐹 v1.22.1 
❯ nats req piggybankdb.unlock '{"database_key": "iHDys5Y+ZwRAr7szyy527jiESx9HH93ToCAX11JthPU"}'
20:37:17 Sending request on "piggybankdb.unlock"
20:37:17 Received with rtt 9.490961ms
20:37:17 Status: 200

{"details":"database successfully unlocked","Code":200}



piggybank on  main [📝] via 🐹 v1.22.1 
❯ nats req piggybankdb.lock ""
20:37:21 Sending request on "piggybankdb.lock"
20:37:21 Received with rtt 1.382836ms
20:37:21 Status: 200

{"details":"database locked","Code":200}



piggybank on  main [📝] via 🐹 v1.22.1 
❯ nats req piggybankdb.unlock '{"database_key": "iHDys5Y+ZwRAr7szyy527jiESx9HH93ToCAX11JthPU"}'
20:37:24 Sending request on "piggybankdb.unlock"
20:37:24 Received with rtt 5.166875ms
20:37:24 Status: 200

{"details":"database successfully unlocked","Code":200}



piggybank on  main [📝] via 🐹 v1.22.1 
❯ nats req piggybankdb.lock ""
20:37:25 Sending request on "piggybankdb.lock"
20:37:25 Received with rtt 1.379243ms
20:37:25 Status: 200

{"details":"database locked","Code":200}

Not sure if this is how you would want to solve this issue or not but I thought I would throw it out there for discussion.

@hooksie1
Copy link
Owner

Ah good catch. Didn't run into this before switching over to the micro setup and now that you mention it, I might have noticed this but assumed I typed something incorrectly.

@hooksie1 hooksie1 merged commit 745d5d4 into hooksie1:main Mar 12, 2024
1 check passed
@hooksie1
Copy link
Owner

thanks!

@dwaynebradley
Copy link
Contributor Author

You're welcome 😎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants