Update appwrite push ledger name by ArnabChatterjee20k · Pull Request #13815 · appwrite/appwrite · GitHub
Skip to content

Update appwrite push ledger name - #13815

Merged
ArnabChatterjee20k merged 2 commits into
mainfrom
update-appwrite-push-ledger-name
Sep 22, 2026
Merged

ArnabChatterjee20k merged 2 commits into
mainfrom
update-appwrite-push-ledger-name

Conversation

@ArnabChatterjee20k

Copy link
Copy Markdown
Member

What does this PR do?

(Provide a description of what this PR does and why it's needed.)

Test Plan

(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Screenshots may also be helpful.)

Related PRs and Issues

  • (Related PR or issue)

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?

ArnabChatterjee20k and others added 2 commits September 22, 2026 11:07
Appwrite is already in scope, so the qualifier was redundant.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Comment on lines +2161 to +2163
'pushLedger' => [
'$collection' => ID::custom(DATABASE::METADATA),
'$id' => ID::custom('appwritePushLedger'),
'$id' => ID::custom('pushLedger'),

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.

P1 Ledger data is stranded

Existing projects store their QoS 1 messages in appwritePushLedger. This change makes collection setup create a separate, empty pushLedger collection without renaming the old collection or copying its records. After an upgrade, MQTT replay reads only the new collection and cleanup no longer prunes the old one, so previously stored offline messages cannot be recovered and the old records remain orphaned.

Knowledge Base Used:

Prompt To Fix With AI
This is a comment left during a code review.
Path: app/config/collections/common.php
Line: 2161-2163

Comment:
**Ledger data is stranded**

Existing projects store their QoS 1 messages in `appwritePushLedger`. This change makes collection setup create a separate, empty `pushLedger` collection without renaming the old collection or copying its records. After an upgrade, MQTT replay reads only the new collection and cleanup no longer prunes the old one, so previously stored offline messages cannot be recovered and the old records remain orphaned.

**Knowledge Base Used:**
- [MQTT protocol gateway](https://app.greptile.com/appwrite/-/custom-context/knowledge-base/appwrite/appwrite/-/docs/mqtt-protocol-gateway.md)
- [Platform configuration and policies](https://app.greptile.com/appwrite/-/custom-context/knowledge-base/appwrite/appwrite/-/docs/platform-configuration.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code Fix in Codex

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Its fine cause its not released

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.

That’s fair — if appwritePushLedger hasn’t appeared in a released version, there are no existing production projects or ledger records to migrate. In that case, renaming the collection directly is safe, and this finding doesn’t apply.

private function cursorKey(Connection $connection): string
{
return 'appwrite:push:cursor:' . $connection->prefix
return 'push:cursor:' . $connection->prefix

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.

P1 Cursor rename skips messages

A persistent client may have acknowledged through sequence C under appwrite:push:cursor:* while messages C+1 through T later accumulated. After this rename, the handler cannot find that cursor because it reads only push:cursor:*; a missing cursor defaults to the current tail T. Replay then starts after T, permanently skipping the client's unacknowledged backlog.

Knowledge Base Used: MQTT protocol gateway

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/Appwrite/Mqtt/Handler.php
Line: 330

Comment:
**Cursor rename skips messages**

A persistent client may have acknowledged through sequence C under `appwrite:push:cursor:*` while messages C+1 through T later accumulated. After this rename, the handler cannot find that cursor because it reads only `push:cursor:*`; a missing cursor defaults to the current tail T. Replay then starts after T, permanently skipping the client's unacknowledged backlog.

**Knowledge Base Used:** [MQTT protocol gateway](https://app.greptile.com/appwrite/-/custom-context/knowledge-base/appwrite/appwrite/-/docs/mqtt-protocol-gateway.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code Fix in Codex

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Its fine cause its not released

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.

That’s fair. If the old appwrite:push:cursor:* key has never been released or used by persistent clients, there is no existing cursor state to preserve, so renaming it is safe. I’m withdrawing this finding.

Comment on lines +2161 to +2163
'pushLedger' => [
'$collection' => ID::custom(DATABASE::METADATA),
'$id' => ID::custom('appwritePushLedger'),
'$id' => ID::custom('pushLedger'),

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.

P2 Collection name violates convention

The repository requires collection names to be lowercase plurals, but pushLedger is singular and camelCase. Use a conforming collection ID consistently across configuration and consumers. This explicit repository requirement must be satisfied before merging.

Context Used: CLAUDE.md (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: app/config/collections/common.php
Line: 2161-2163

Comment:
**Collection name violates convention**

The repository requires collection names to be lowercase plurals, but `pushLedger` is singular and camelCase. Use a conforming collection ID consistently across configuration and consumers. This explicit repository requirement must be satisfied before merging.

**Context Used:** CLAUDE.md ([source](https://github.com/appwrite/appwrite/blob/main/CLAUDE.md))

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Claude Code Fix in Codex

Comment on lines +113 to +118
$this->database->createCollection('pushLedger', [], [], $any, false);
$this->database->createAttribute('pushLedger', 'topic', Database::VAR_STRING, 255, true);
$this->database->createAttribute('pushLedger', 'data', Database::VAR_STRING, 65535, true);
$this->database->createAttribute('pushLedger', 'messageId', Database::VAR_STRING, 255, false);
$this->database->createAttribute('pushLedger', 'messageInternalId', Database::VAR_STRING, 255, false);
$this->database->createAttribute('pushLedger', 'sequence', Database::VAR_INTEGER, 0, true);

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.

P2 Test mirrors implementation details

This fixture mechanically copies the production collection name and schema, then queries that internal collection directly. Updating the test in lockstep with the implementation lets an arbitrary storage rename stay green while completely missing the observable upgrade failure for projects that retain the old ledger and cursor keys. The repository requires tests to cover observable behavior rather than mirror source or configuration, so this must be replaced with upgrade and reconnect replay coverage before merging.

Context Used: Call out and harshly judge implementation-coupled tests. We don't mirror source code, configuration, or version pins in assertions. We test observable behavior; use linters for syntax and schema checks. (source)

Knowledge Base Used: MQTT protocol gateway

Prompt To Fix With AI
This is a comment left during a code review.
Path: tests/unit/Appwrite/Messaging/Adapter/Push/AppwriteTest.php
Line: 113-118

Comment:
**Test mirrors implementation details**

This fixture mechanically copies the production collection name and schema, then queries that internal collection directly. Updating the test in lockstep with the implementation lets an arbitrary storage rename stay green while completely missing the observable upgrade failure for projects that retain the old ledger and cursor keys. The repository requires tests to cover observable behavior rather than mirror source or configuration, so this must be replaced with upgrade and reconnect replay coverage before merging.

**Context Used:** Call out and harshly judge implementation-coupled tests. We don't mirror source code, configuration, or version pins in assertions. We test observable behavior; use linters for syntax and schema checks. ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))

**Knowledge Base Used:** [MQTT protocol gateway](https://app.greptile.com/appwrite/-/custom-context/knowledge-base/appwrite/appwrite/-/docs/mqtt-protocol-gateway.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Claude Code Fix in Codex

@github-actions

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → update-appwrite-push-ledger-name (after).

Metric Before After Change
🚀 Requests/sec 190.73 192.06 ⚪ +0.7%
⏱️ Latency P50 89.7 ms 89.51 ms ⚪ -0.2%
⏱️ Latency P95 215.96 ms 209.07 ms ⚪ -3.2%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 89.51 209.07 12,255 192.06 -6.89
Account 174.7 325.81 645 10.71 -18.36
TablesDB 86.54 170.85 6,665 107.65 +2.72
Storage 82.15 172.42 3,225 53.26 +0.27
Functions 127.56 255.53 1,720 29.07 -7.66

Top API waits (after)

API request Max wait (ms)
functions.create 547.07
account.name.update 535.54
account.prefs.update 519.53
tablesdb.rows.decrement 424.99
functions.variables.create 423.17

@ArnabChatterjee20k
ArnabChatterjee20k merged commit 0ccd1aa into main Sep 22, 2026
108 of 109 checks passed
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