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

fix: export events tsv directly to postgres instance #2048

Merged
merged 11 commits into from
Aug 15, 2024
Merged

Conversation

rafaelcr
Copy link
Collaborator

@rafaelcr rafaelcr commented Aug 12, 2024

This PR adds a local option to the export-events API CLI command. If the argument to --file starts with local:, it will export events using only postgres to a file path local to its container.

Copy link

github-actions bot commented Aug 12, 2024

Vercel deployment URL: https://stacks-blockchain-3tc7rhdm1-hirosystems.vercel.app 🚀

Copy link

codecov bot commented Aug 12, 2024

Codecov Report

Attention: Patch coverage is 92.30769% with 2 lines in your changes missing coverage. Please review.

Files Patch % Lines
src/event-replay/event-replay.ts 81.81% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

src/event-replay/event-replay.ts Outdated Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
Copy link
Member

@zone117x zone117x left a comment

Choose a reason for hiding this comment

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

Can we make the local export an opt-in feature? I made a modification (2f9e591) and just tested against a kubectl port-forward to a mainnet dev instance. It exported a ~50GB tsv to my machine, and I validated that every line is valid json.

@rafaelcr
Copy link
Collaborator Author

that looks great @zone117x , would you mind applying that patch to this branch?

@zone117x
Copy link
Member

My guess is that the CI failure is because host docker filesystem usage causing the ./tmp/events.tsv to be owned by a different user (the postgres image system user) and so the CI system user can't delete it

@rafaelcr
Copy link
Collaborator Author

rafaelcr commented Aug 14, 2024

@CharlieC3 do you have a suggestion on what I can do to fix this failure? https://github.com/hirosystems/stacks-blockchain-api/actions/runs/10392592660/job/28778191413#step:7:655
I'm trying to use that file via a docker volume, btw.

I think @zone117x is right that the user difference is making the test fail here. Perhaps it won't be possible to test this particular thing on gh actions?

@CharlieC3
Copy link
Member

@rafaelcr The postgres image runs the database as the postgres user, so you're both right it is a user mismatch.

root@4208a0d55448:/# id postgres
uid=999(postgres) gid=999(postgres) groups=999(postgres),101(ssl-cert)

You may have to chmod and chown the host directory you're mounting to user 999 before starting the container

chown 999:999 ../src/tests-event-replay/.tmp/local/
chmod -R 777 ../src/tests-event-replay/.tmp/local/

@rafaelcr
Copy link
Collaborator Author

That did it @CharlieC3 thanks!

@rafaelcr rafaelcr merged commit f401a0f into develop Aug 15, 2024
29 checks passed
@rafaelcr rafaelcr deleted the fix/export-query branch August 15, 2024 16:24
rafaelcr added a commit that referenced this pull request Aug 20, 2024
* fix: export events tsv directly to postgres instance

* fix: remove unused function

* chore: option to export events to either local file or client

* chore: try new docker path

* chore: divide remote and local paths

* fix: try relative path for mkdir

* ci: try chmod

* ci: run mkdir first

* ci: try with sudo

* fix: file paths

---------

Co-authored-by: Matthew Little <[email protected]>
rafaelcr added a commit that referenced this pull request Aug 20, 2024
* fix: export events tsv directly to postgres instance

* fix: remove unused function

* chore: option to export events to either local file or client

* chore: try new docker path

* chore: divide remote and local paths

* fix: try relative path for mkdir

* ci: try chmod

* ci: run mkdir first

* ci: try with sudo

* fix: file paths

---------

Co-authored-by: Matthew Little <[email protected]>
blockstack-devops pushed a commit that referenced this pull request Aug 20, 2024
## [7.14.0](v7.13.2...v7.14.0) (2024-08-20)

### Features

* export events tsv directly to postgres instance ([#2048](#2048)) ([#2058](#2058)) ([a1f5b12](a1f5b12))
blockstack-devops pushed a commit that referenced this pull request Aug 27, 2024
## [8.0.0-beta.6](v8.0.0-beta.5...v8.0.0-beta.6) (2024-08-27)

### ⚠ BREAKING CHANGES

* refactor from express to fastify (#2045)

### Features

* cursor-based pagination on blocks endpoint ([#2060](#2060)) ([bfdcce1](bfdcce1))
* export events tsv directly to postgres instance ([#2048](#2048)) ([f401a0f](f401a0f))
* export events tsv directly to postgres instance ([#2048](#2048)) ([#2058](#2058)) ([a1f5b12](a1f5b12))
* refactor from express to fastify ([#2045](#2045)) ([bd65fcf](bd65fcf)), closes [#2042](#2042)

### Bug Fixes

* index on `principal_stx_txs` table for faster `/v1/address/{addr}/transactions` lookups ([#2059](#2059)) ([ab64ab7](ab64ab7))
@blockstack-devops
Copy link

🎉 This PR is included in version 8.0.0-beta.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

blockstack-devops pushed a commit that referenced this pull request Aug 28, 2024
## [8.0.0](v7.14.1...v8.0.0) (2024-08-28)

### ⚠ BREAKING CHANGES

* refactor from express to fastify (#2045)
* refactor from Express to Fastify

### Features

* cursor-based pagination on blocks endpoint ([#2060](#2060)) ([bfdcce1](bfdcce1))
* export events tsv directly to postgres instance ([#2048](#2048)) ([f401a0f](f401a0f))
* refactor from Express to Fastify ([aa0e51e](aa0e51e)), closes [#2042](#2042)
* refactor from express to fastify ([#2045](#2045)) ([bd65fcf](bd65fcf)), closes [#2042](#2042)

### Bug Fixes

* missing event limit max overrides on a few endpoints ([4f70930](4f70930))
* pagination and query param parsing bugs ([a382d2b](a382d2b)), closes [#2042](#2042)
* perform status endpoint sql inside transactions ([b23445c](b23445c))
* tx event-limit default should be 100 ([32d0670](32d0670))
@blockstack-devops
Copy link

🎉 This PR is included in version 8.0.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.

4 participants