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

Subsription tracking refactoring #215

Merged
merged 1 commit into from
Dec 2, 2021
Merged

Subsription tracking refactoring #215

merged 1 commit into from
Dec 2, 2021

Conversation

bmuddha
Copy link
Collaborator

@bmuddha bmuddha commented Nov 21, 2021

  1. When getProgramAccouns gets cached, it unsubscribes from all cached
    accounts, but starts tracking their reference counts, to prevent
    premature removal.
  2. All accounts, which are being tracked by ProgramAccountsDB, get's
    served from cache, as long as parent has an active subscription, and
    do not create their own subscription.
  3. When getAccountInfo hits the cache it creates a purge task for
    itself, and when timer expires, it removes itself from tracked
    accounts in ProgramAccountsDB, and tries to remove itself from
    AccountsDB cache, succeeding only if no program filters hold another
    reference count to it.
  4. When getAccountInfo misses the cache, while it's owner still having
    active subscription, the result is similar to case 3, it fetches
    account by RPC, puts it into AccountsDB, starts tracking it in
    ProgramAccountsDB, and doesn't create extra subscription for itself,
    while still spawning purge task to be removed later.

@bmuddha bmuddha requested a review from 00nktk November 21, 2021 16:51
Copy link
Collaborator

@00nktk 00nktk left a comment

Choose a reason for hiding this comment

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

Вроде должно работать, но можно еще лучше скрыть менеджинг ссылок внутри ProgramAccountsDb.
Одна из серьезных проблем - подчистка подписок на аккаунты, которые принадлежат программе, но не вошли в запрос, который стригеррил подписку на программу. Думаю, можно вынести в отдельный ишью и там обсудить как лучше сделать.

src/types.rs Outdated Show resolved Hide resolved
src/types.rs Outdated Show resolved Hide resolved
src/rpc.rs Outdated Show resolved Hide resolved
src/types.rs Outdated Show resolved Hide resolved
@bmuddha bmuddha changed the title Fix subsription tracking Subsription tracking refactoring Nov 26, 2021
Copy link
Collaborator

@00nktk 00nktk left a comment

Choose a reason for hiding this comment

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

Вроде все хорошо, но есть пара недочетов.

src/types.rs Outdated Show resolved Hide resolved
src/types.rs Outdated Show resolved Hide resolved
src/types.rs Outdated Show resolved Hide resolved
src/types.rs Outdated Show resolved Hide resolved
src/types.rs Outdated Show resolved Hide resolved
src/pubsub.rs Outdated Show resolved Hide resolved
src/pubsub.rs Show resolved Hide resolved
src/pubsub.rs Outdated Show resolved Hide resolved
src/rpc.rs Outdated Show resolved Hide resolved
src/rpc.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@00nktk 00nktk left a comment

Choose a reason for hiding this comment

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

Вроде все отлично, парочка final nits так сказать. Отдельная благодарность за комменты.

src/pubsub.rs Outdated Show resolved Hide resolved
src/types.rs Outdated Show resolved Hide resolved
src/types.rs Outdated Show resolved Hide resolved
src/types.rs Show resolved Hide resolved
@00nktk 00nktk requested a review from polachok November 30, 2021 15:42
src/main.rs Outdated Show resolved Hide resolved
1. When getAccount info triggers subscription, account key starts being
   tracked in ProgramAccountsDB, for further transfer of tracking
   control to owner program.
2. If during subscription attempt for account, it's found that owner
   program already has cache entry and subscription, then no new account
   subscription is created, but account key is still added to the list
   of tracked keys.
3. When getProgramAccouns gets cached, it unsubscribes from all tracked
   accounts.
4. All accounts, which are being tracked by ProgramAccountsDB, get's
   served from cache, as long as parent has an active subscription, and
   do not create their own subscription.
5. When getAccountInfo hits the cache it creates a purge task for
   itself, and when timer expires, it removes itself from tracked
   accounts in ProgramAccountsDB, and tries to remove itself from
   AccountsDB cache, succeeding only if no program filters hold another
   reference count to it.
6. When getAccountInfo misses the cache, while it's owner still having
   active subscription, the result is similar to case 3, it fetches
   account by RPC, puts it into AccountsDB, starts tracking it in
   ProgramAccountsDB, and doesn't create extra subscription for itself,
   while still spawning purge task to be removed later.

Co-authored-by: Alexander Polakov <a.polakov@zubr.io>
@bmuddha bmuddha merged commit fbcc4e4 into bestarch-ae:master Dec 2, 2021
@bmuddha bmuddha deleted the fix-subsription-tracking branch December 8, 2021 08:33
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.

None yet

3 participants