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

feat: ensure events are inserted into the raw event request table #1925

Merged
merged 8 commits into from
Jun 3, 2024

Conversation

zone117x
Copy link
Member

@zone117x zone117x commented Apr 5, 2024

Issue found by @csgui where the event_observer_requests table can be missing events even if the rest of the event ingestion was successful.

This appears to be because the function for inserting into event_observer_requests was ran after the event server http request has been completed. So when a large block was received, it may have been ingested into the regular tables, but could run into an OOM error on the event_observer_requests insert.

This PR fixes the issue by ensuring the http request is not completed until insert into event_observer_requests is completed. Also the amount of JSON parsing/stringifying has been reduced in an attempt to reduce likelihood of an OOM when receiving a large /new_block event payload.

@zone117x zone117x requested a review from rafaelcr April 5, 2024 11:27
@zone117x zone117x requested a review from csgui April 5, 2024 11:27
Copy link

github-actions bot commented Apr 5, 2024

Vercel deployment URL: https://stacks-blockchain-i7qr60ei6-blockstack.vercel.app 🚀

Copy link

codecov bot commented Apr 5, 2024

Codecov Report

Attention: Patch coverage is 85.18519% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 72.02%. Comparing base (f522d79) to head (e5299b9).
Report is 49 commits behind head on master.

Current head e5299b9 differs from pull request most recent head cb4016d

Please upload reports for the commit cb4016d to get more accurate results.

Files Patch % Lines
src/event-stream/event-server.ts 86.36% 3 Missing ⚠️
src/datastore/pg-write-store.ts 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1925      +/-   ##
==========================================
- Coverage   72.07%   72.02%   -0.06%     
==========================================
  Files          93       93              
  Lines       12026    12027       +1     
  Branches     2654     2654              
==========================================
- Hits         8668     8662       -6     
- Misses       3202     3209       +7     
  Partials      156      156              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@csgui csgui left a comment

Choose a reason for hiding this comment

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

Code verified and tested. LGTM!

zone117x and others added 2 commits April 15, 2024 18:52
## [7.10.0](v7.9.1...v7.10.0) (2024-04-15)

### Features

* add nakamoto block time to v2 endpoints ([#1921](#1921)) ([ae6bbe8](ae6bbe8))
* add signer-keys from pox4 events ([#1857](#1857)) ([c17ad23](c17ad23))
* ingest signer_bitvec ([#1900](#1900)) ([aa1750f](aa1750f))
* nakamoto block timestamps ([#1886](#1886)) ([f547832](f547832))
* pox 4 revoke events and signer-key support ([#1829](#1829)) ([5e5650a](5e5650a)), closes [#1849](#1849)
* pox stacker & signer cycle details ([#1873](#1873)) ([d2c2805](d2c2805))
* rosetta pox4 stacking support ([#1928](#1928)) ([2ba36f9](2ba36f9)), closes [#1929](#1929)

### Bug Fixes

* add nakamoto testnet to openapi docs ([#1910](#1910)) ([01fb971](01fb971))
* batch drop mempool transactions ([#1920](#1920)) ([a7ee96d](a7ee96d))
* cycle signer filter ([#1916](#1916)) ([dc7d600](dc7d600))
* cycles response for empty cycle info ([#1914](#1914)) ([a7a4558](a7a4558))
* delegate-stx burn-op parsing and test fix ([#1939](#1939)) ([73ec0db](73ec0db))
* event-replay readiness for nakamoto & fix for [#1879](#1879) ([#1903](#1903)) ([1572e73](1572e73))
* log message when sql migration is performed ([#1942](#1942)) ([49a4d25](49a4d25))
* other empty result responses ([#1915](#1915)) ([3cd2c64](3cd2c64))
* pox4 stack-stx burn-op handling ([#1936](#1936)) ([9e9a464](9e9a464))
* remove signer columns from tenure-change transactions ([#1845](#1845)) ([8ec726b](8ec726b))
* sql transactional consistency bug with fetching chaintip in various areas ([#1853](#1853)) ([ada8536](ada8536))
@csgui csgui force-pushed the fix/ensure-raw-event-request-insert branch from 8a81360 to cb4016d Compare May 28, 2024 16:06
@csgui
Copy link
Collaborator

csgui commented May 31, 2024

@zone117x Just validated this fix against an archive synced from genesis. Please check the conversation on this devops issue for more context.

Blocks containing a large number of transactions are now included in the archive file.

For example, block 137843, which was the root cause of this issue, is now present in the archive file after the fix. Therefore, for a block to be present in the archive file, it must have also been present in the event_observer_requests table.

Fix LGTM.

@zone117x zone117x changed the base branch from master to develop May 31, 2024 20:46
@zone117x
Copy link
Member Author

Awesome, thanks for the thorough testing @csgui!

@zone117x zone117x merged commit 34a8454 into develop Jun 3, 2024
29 checks passed
@zone117x zone117x deleted the fix/ensure-raw-event-request-insert branch June 3, 2024 10:02
blockstack-devops pushed a commit that referenced this pull request Jun 5, 2024
## [7.11.0-beta.8](v7.11.0-beta.7...v7.11.0-beta.8) (2024-06-05)

### Features

* include solo and pooled stackers in signer stacker endpoints ([#1987](#1987)) ([302a5d8](302a5d8))

### Bug Fixes

* ensure events are inserted into the raw event request table ([#1925](#1925)) ([34a8454](34a8454))
@blockstack-devops
Copy link

🎉 This PR is included in version 7.11.0-beta.8 🎉

The release is available on:

Your semantic-release bot 📦🚀

blockstack-devops pushed a commit that referenced this pull request Jun 7, 2024
## [7.11.0](v7.10.0...v7.11.0) (2024-06-07)

### Features

* add average stacks block time to burn block endpoints ([#1963](#1963)) ([31c2eed](31c2eed))
* add burn_block_height to Rosetta endpoints ([#1974](#1974)) ([9648ac8](9648ac8))
* add burn_block_height to transactions ([#1969](#1969)) ([3e2d524](3e2d524))
* add signer_address to pox signer endpoints ([#1975](#1975)) ([7d3444b](7d3444b))
* add total tx count to burn block endpoints ([#1965](#1965)) ([d38b78a](d38b78a))
* average block times endpoint ([#1962](#1962)) ([cd151aa](cd151aa))
* docker build for arm ([#1947](#1947)) ([2c526fc](2c526fc))
* include solo and pooled stackers in signer stacker endpoints ([#1987](#1987)) ([302a5d8](302a5d8))
* support multiple STX faucet source accounts ([#1946](#1946)) ([be5db0c](be5db0c))
* support multiple STX faucet source accounts ([#1946](#1946)) ([5d69c7c](5d69c7c))

### Bug Fixes

* ensure events are inserted into the raw event request table ([#1925](#1925)) ([34a8454](34a8454))
* inconsistent block transaction results in Rosetta response ([#1958](#1958)) ([a5bec61](a5bec61))
* issue with block_time receipt not being written to db ([#1961](#1961)) ([74c06c6](74c06c6))
* pox4 properties missing in various endpoints ([#1977](#1977)) ([521d771](521d771))
* rosetta account endpoint should assume chain tip if block not specified ([#1956](#1956)) ([4bba526](4bba526))
* signer stacker query using string instead of int for cycle_id ([#1991](#1991)) ([5ce9b44](5ce9b44))
* socket-io client must only use websocket transport ([#1976](#1976)) ([85ea5af](85ea5af))
@blockstack-devops
Copy link

🎉 This PR is included in version 7.11.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

5 participants