You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the feature you'd like to see implemented
As a feature, Sequelize could handle a distributed environment with multiple database instances (shards) while the underlying schema is the same for each shard. This environment would consist of multiple primary databases along with their read replicas.
To achieve this, Sequelize needs to:
have a capability of establish connection to a database based on a provided shard identifier
create a transaction to the right shard
maintain a connection pool from where a connection to a specific shard can be acquired, released, etc.
Example
importSequelizefrom"@sequelize/core";constsequelize=newSequelize({dialect: "postgres",// The sharding options containing configuration data for each shard// The sharding feature can be disabled by setting the sharding option to false// In case the sharding option is set, sequelize disregard the replication optionsharding: {shards: [{shardId: "shard-0",writeConfig: a,// primary database configreadConfig: a,// read replica config ,},{shardId: "shard-1",writeConfig: ...,// primary database config ,readConfig: ...,// read replica config ,},],},replication: false,});// Use application logic to determine which database shard the Simpson family live in and pass it to transactionconsttransaction=awaitsequelize.startUnmanagedTransaction({// Passing the identifier of the shard we want to create a transaction toshardId: "shard-0",});// Use the transaction with the shard identifiertry{constuser=awaitUser.create({firstName: "Bart",lastName: "Simpson",},{transaction: t});}catch(error){// custom error handling and rollback}
Possible ideas:
After looking through the codebase, an actual idea is to extend the ReplicationPool (abstract/replication-pool.ts) capabilities by adding a new replication pool which can maintain shard configuration.
Describe why you would like this feature to be added to Sequelize
Currently, we're working on a sharding project to split up our primary Postgres database into multiple shards and distribute the data across the shards. While we aim to have multiple database instances (shards), we plan the application to have only one sequelize instance configured and instantiated. Since we've decided to move with the sharded database concept, our application layer needs to deal with determining the right shard and commit a transaction to that. As of now, Sequelize can only manage one primary database with read replicas, so we'd like to extend Sequelize to manage database shards.
After a quick search, I've found previous issues requesting this sort of feature.
No, I don't have the time, and I understand that I will need to wait until someone from the community or maintainers is interested in implementing my feature.
Indicate your interest in the addition of this feature by adding the 👍 reaction. Comments such as "+1" will be removed.
The text was updated successfully, but these errors were encountered:
gtamasi
added
pending-approval
Bug reports that have not been verified yet, or feature requests that have not been accepted yet
type: feature
For issues and PRs. For new features. Never breaking changes.
labels
Oct 13, 2023
ephys
removed
the
pending-approval
Bug reports that have not been verified yet, or feature requests that have not been accepted yet
label
Feb 2, 2024
Issue Creation Checklist
Feature Description
Describe the feature you'd like to see implemented
As a feature, Sequelize could handle a distributed environment with multiple database instances (shards) while the underlying schema is the same for each shard. This environment would consist of multiple primary databases along with their read replicas.
To achieve this, Sequelize needs to:
Example
Possible ideas:
After looking through the codebase, an actual idea is to extend the
ReplicationPool
(abstract/replication-pool.ts) capabilities by adding a new replication pool which can maintain shard configuration.Describe why you would like this feature to be added to Sequelize
Currently, we're working on a sharding project to split up our primary Postgres database into multiple shards and distribute the data across the shards. While we aim to have multiple database instances (shards), we plan the application to have only one sequelize instance configured and instantiated. Since we've decided to move with the sharded database concept, our application layer needs to deal with determining the right shard and commit a transaction to that. As of now, Sequelize can only manage one primary database with read replicas, so we'd like to extend Sequelize to manage database shards.
After a quick search, I've found previous issues requesting this sort of feature.
#10154
#3806
#263
I deeply believe this feature will be appreciated across the community and bring extra value to Sequelize.
While we aim to tackle this problem ourselves, we are also dedicated to making this feature approved and upstreamable in the future.
Is this feature dialect-specific?
Would you be willing to resolve this issue by submitting a Pull Request?
Indicate your interest in the addition of this feature by adding the 👍 reaction. Comments such as "+1" will be removed.
The text was updated successfully, but these errors were encountered: