Skip to content

Clarify the effect of "early context terimination" and how to work around it #642

@zolstein

Description

@zolstein

The library docs on many functions state:

Contexts terminating too early negatively affect connection pooling and degrade the driver performance.

The warning of a potential foot-gun is good, but it's not entirely clear, and it suggests a lot of context that (as far as I can tell) isn't clearly documented anywhere:

  • What does "too early" mean? Does it mean "any time before this function completes," or "before some critical step early in this function completes," or "any time before the entire result is consumed"?
  • Exactly what effect does this have, individually, or if it happens repeatedly in a system?
  • What are the best practices for preventing issues, especially given that the Go ecosystem relies heavily on context cancellation to control tasks? How should callers control the lifetime of queries?

The answers to these questions probably shouldn't be documented in every function, but they should probably be somewhere, and the documentation should probably point there.

Alternatively, could the performance degradation be fixed, so that this just isn't an issue anymore? Could the connection pooling be reworked to accommodate cancelled contexts? Or is that not possible for some reason?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions