Skip to content

BQ storage write api - Mint pool#3272

Merged
Ziinc merged 11 commits intoLogflare:mainfrom
bblaszkow06:bb/bigquery-streaming-insert-perf
Apr 15, 2026
Merged

BQ storage write api - Mint pool#3272
Ziinc merged 11 commits intoLogflare:mainfrom
bblaszkow06:bb/bigquery-streaming-insert-perf

Conversation

@bblaszkow06
Copy link
Copy Markdown
Contributor

@bblaszkow06 bblaszkow06 commented Mar 11, 2026

Initial implementation of the Mint-adapter-based Storage Write API.

Retries and error handling will be covered by following PRs to keep this manageable.

Closes O11Y-1513

@bblaszkow06 bblaszkow06 force-pushed the bb/bigquery-streaming-insert-perf branch 4 times, most recently from ff9c25f to 6a3f159 Compare March 26, 2026 10:04
@Ziinc Ziinc changed the title BQ streaming insert - Mint pool BQ storage write api - Mint pool Apr 2, 2026
Upgrades grpc ~> 0.11.0 and adds a persistent, supervised
round-robin channel pool using the built-in Mint adapter
to replace the per-call GRPC.Stub.connect
(backed by the custom Finch adapter).

- Add GrpcPool supervisor with per-index GrpcChannelMonitor GenServers;
  channels are registered in a per-pool Registry and selected via an
  atomic counter for lock-free round-robin dispatch
- Add GrpcAuthInterceptor: fetches a fresh Goth token per call and
  injects it as gRPC metadata, replacing the per-call auth header on
  the channel
- Remove local Google.Rpc.* protobuf definitions now provided by the
  googleapis transitive dep (pulled in by grpc 0.11.x)
- Add GRPC.Client.Supervisor to Networking.pools/0 (required by
  grpc 0.11.x for outbound connections)
- google_api_client: use GrpcPool.get_channel/1 and remove Goth.fetch;
  auth is now handled transparently by the interceptor
@bblaszkow06 bblaszkow06 force-pushed the bb/bigquery-streaming-insert-perf branch 2 times, most recently from 00d0357 to 1d15a33 Compare April 2, 2026 10:12
@bblaszkow06 bblaszkow06 marked this pull request as ready for review April 2, 2026 10:16
setup do
insert(:plan)
start_supervised!(AllLogsLogged)
start_supervised!(GRPC.Client.Supervisor)
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.

Seems like unnecessary change as there is no client interaction in this test

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Actually, there is - in line 35, there's Client.connect that sends a request via localhost.

The change was needed due to :grpc version bump. The supervisor used to be started with :grpc app, but in the current version, it has to be started manually and isn't started in tests

setup do
insert(:plan)
start_supervised!(AllLogsLogged)
start_supervised!(GRPC.Client.Supervisor)
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.

as above

insert(:plan)
start_supervised!(AllLogsLogged)
start_supervised!(GRPC.Client.Supervisor)

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.

As above

Comment thread config/runtime.exs
health: logflare_health,
http_connection_pools: http_connection_pools
http_connection_pools: http_connection_pools,
bq_write_api_pool_size: System.get_env("LOGFLARE_BQ_WRITE_API_POOL_SIZE")
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
bq_write_api_pool_size: System.get_env("LOGFLARE_BQ_WRITE_API_POOL_SIZE")
bq_write_api_pool_size: System.get_env("LOGFLARE_BIGQUERY_WRITE_API_POOL_SIZE")

In my opinion we should automatically manage connection pool. But we can give this a try first. Needs a sensible default too.

Copy link
Copy Markdown
Contributor

@Ziinc Ziinc left a comment

Choose a reason for hiding this comment

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

Will merge in first for testing. Please address comments in follow up PRs 🙏

{Logflare.Networking.GrpcPool,
name: GoogleApiClient.connetion_pool_name(),
url: "https://bigquerystorage.googleapis.com",
size: Application.get_env(:logflare, :bq_write_api_pool_size, 25)}
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.

Default should be set at runtime.exs instead

@Ziinc Ziinc merged commit d99ab0b into Logflare:main Apr 15, 2026
13 of 14 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