Skip to content
This repository was archived by the owner on Apr 2, 2024. It is now read-only.

Conversation

@harkishen
Copy link
Member

@harkishen harkishen commented Jun 22, 2022

Signed-off-by: Harkishen-Singh harkishensingh@hotmail.com

This commit separates the reader and writer connection pools.

By default, reader gets 0.3 and writer gets 0.5 times of
the allowed connection from the db. But, in case of readonly mode,
reader gets 0.5 times the connections from the db.

TODO

  • Updating changelog
  • Updating CLI configuration

Merge requirements

Please take into account the following non-code changes that you may need to make with your PR:

  • CHANGELOG entry for user-facing changes
  • Updated the relevant documentation

@harkishen harkishen self-assigned this Jun 22, 2022
@harkishen harkishen force-pushed the separate_db_pools branch 2 times, most recently from 063aca7 to 3c2cc76 Compare June 22, 2022 10:00
@harkishen harkishen marked this pull request as ready for review June 22, 2022 10:01
@harkishen harkishen requested a review from a team as a code owner June 22, 2022 10:01
@harkishen harkishen force-pushed the separate_db_pools branch from c7ccaed to 4900a65 Compare June 28, 2022 13:17
// NewClient creates a new PostgreSQL client
func NewClient(cfg *Config, mt tenancy.Authorizer, schemaLocker LockFunc, readOnly bool) (*Client, error) {
pgConfig, numCopiers, err := getPgConfig(cfg)
func NewClient(r prometheus.Registerer, cfg *Config, mt tenancy.Authorizer, schemaLocker LockFunc, readOnly bool) (*Client, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to refactor this into 2 different functions? Something like

  • NewClient
  • NewReadOnlyClient

And moving the code that's inside the !readOnly into a getWriterPool function and the other part into a getReaderPool function then the Client constructors will just call this functions and pass the values to NewClientWithPool

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a good idea. But, given the current PR, it will be out of scope plus a lot of changes plus the existing stuff in this PR. Would you like to work on this refactoring once we merge this PR?

Copy link
Member

Choose a reason for hiding this comment

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

Let's create an issue for the refactoring. @alejandrodnm would you mind making it since it is your proposal? 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

I knew it was a trap 😄 Yeah, I'll do it

@harkishen harkishen force-pushed the separate_db_pools branch from 4900a65 to 0d1203d Compare July 11, 2022 09:59
@niksajakovljevic niksajakovljevic self-requested a review July 11, 2022 11:08
@harkishen harkishen force-pushed the separate_db_pools branch from 56185bb to 1127880 Compare July 11, 2022 11:54
@harkishen harkishen requested a review from alejandrodnm July 11, 2022 13:07
if client == nil {
continue
}
pgDelete := deletePkg.PgDelete{Conn: client.Connection}
Copy link
Member

Choose a reason for hiding this comment

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

Should we use writerPool for series deletion?

Copy link
Member Author

Choose a reason for hiding this comment

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

While that is right, I think for now, lets keep deletion from read connection. Deletion is non-frequent, but when executed, it blocks a connection for sometime. So, its good that we don't consume the writer pool connection for this atm.

Copy link
Member

@antekresic antekresic left a comment

Choose a reason for hiding this comment

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

I'm not sure removing a configuration flag like max conns is what we want or that it was decided like that in the design doc.

Signed-off-by: Harkishen-Singh <harkishensingh@hotmail.com>

This commit separates the reader and writer connection pools.

By default, reader gets 0.3 and writer gets 0.5 times of
the allowed connection from the db. But, in case of readonly mode,
reader gets 0.5 times the connections from the db.
Signed-off-by: Harkishen-Singh <harkishensingh@hotmail.com>
@harkishen harkishen force-pushed the separate_db_pools branch from 1127880 to 1a853c7 Compare July 12, 2022 09:27
@harkishen harkishen requested a review from antekresic July 12, 2022 09:29
Signed-off-by: Harkishen-Singh <harkishensingh@hotmail.com>
@harkishen harkishen force-pushed the separate_db_pools branch from 1a853c7 to da4b651 Compare July 12, 2022 09:53
Signed-off-by: Harkishen-Singh <harkishensingh@hotmail.com>
@harkishen harkishen force-pushed the separate_db_pools branch from 4a43643 to 77a69b1 Compare July 12, 2022 12:18
return 0, fmt.Errorf("%s pool size canot be greater than the 'max_connections' allowed by the database", poolName)
default:
}
if cfg.UsesHA {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: doing this check two times and you can do it just once. Improve if you can but lets not waste time on it.

@harkishen harkishen force-pushed the separate_db_pools branch 2 times, most recently from ef0b54c to e29d33b Compare July 13, 2022 08:49
@harkishen harkishen enabled auto-merge (rebase) July 13, 2022 08:49
@harkishen harkishen disabled auto-merge July 13, 2022 08:56
Signed-off-by: Harkishen-Singh <harkishensingh@hotmail.com>
@harkishen harkishen force-pushed the separate_db_pools branch from e29d33b to 0465c0e Compare July 13, 2022 08:58
@harkishen harkishen enabled auto-merge (rebase) July 13, 2022 08:58
@harkishen harkishen merged commit f4641bb into timescale:master Jul 13, 2022
@peppercoffee peppercoffee added the IIP-1 Improve Ingestion Performance (part 1) label Jul 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

IIP-1 Improve Ingestion Performance (part 1)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants