Skip to content

Polling node rotation - #996

Merged
ThomasSession merged 7 commits into
release/1.21.0from
fix/polling-node-rotation
Mar 3, 2025
Merged

Polling node rotation#996
ThomasSession merged 7 commits into
release/1.21.0from
fix/polling-node-rotation

Conversation

@ThomasSession

Copy link
Copy Markdown
Collaborator

Reworked the poller as the logic wasn't correctly rotating across snodes beyond on exception thrown, which caused issues when landing on a snode with no data, which isn't an exception.
Moved away from Promises in favour of coroutines

Reworked the poller as the logic wasn't correctly rotating across snodes beyond on exception thrown, which caused issues when landing on a snode with no data which isn't an exception.
Moved away from Promises in favour of coroutines

@AL-Session AL-Session left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions only, accept or ignore as you see fit.

} catch (e: Exception){
Log.e(TAG, "Error while polling:", e)
pollDelay = minOf(MAX_RETRY_INTERVAL_MS, (RETRY_INTERVAL_MS * (NEXT_RETRY_MULTIPLIER * errorIncrement)).toLong())
errorIncrement++

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
errorIncrement++
retryScalingFactor++

if (rawResponse["code"] as? Int != 200) {
Log.e(TAG, "Batch sub-request had non-200 response code, returned code ${(rawResponse["code"] as? Int) ?: "[unknown]"}")

val responseList = (rawResponses["results"] as List<RawResponse>)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are all these string literals "body", "results", code", "unknown" consts somewhere, or should they be?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added these to constants in the SnodeAPI, except for unknown which isn't a key here.

namespace = Namespace.DEFAULT()
),
auth = userAuth,
maxSize = -2)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why -2? That's oddly specific... Comment would help?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address this one, -2 is a psychotic "maxSize"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again the poller's logic itself hasn't changed so this is the existing logic. But we can do some digging.
In the definition here: https://github.com/oxen-io/oxen-storage-server/blob/dev/oxenss/rpc/client_rpc_endpoints.h#L193-L218
-2 is mentioned to represent half the response size, and was used as there is a limit on the size of the API response in the network.
Looking at the iOs code they seem to apply some fancy logic to determine this amount more dynamically based on the namespaces used, so we could likely optimise this at some point. Though the poller will at some point be centralised in libsession.

publicKey = userAuth.accountId.hexString,
namespace = Namespace.DEFAULT()
),
if (hashesToExtend.isNotEmpty()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to warn if it is empty? Merely asking.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, there is simply an action to take when it isn't

ThomasSession and others added 3 commits March 3, 2025 23:40
…ing_receiving/pollers/Poller.kt

Co-authored-by: AL-Session <160798022+AL-Session@users.noreply.github.com>

@SessionHero01 SessionHero01 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ThomasSession
ThomasSession merged commit c3c903c into release/1.21.0 Mar 3, 2025
@ThomasSession
ThomasSession deleted the fix/polling-node-rotation branch March 3, 2025 23:45
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.

3 participants