vitesskubernetes-vitess

Vitess Sharding issue


I am new to the Vitess and we have deployed Vitess in Kubernetes using Helm Charts and exposed VTGate through node Port and able to connect MYSQL Work bench using the exposed VTGate Ip Address. When we inserted the records using MySql Work Bench, Records are not scattering across the Shards.

  * 'Payrolls' is the KeySpace and we created two shards as Payrolls -80,Payrolls 80-.

  * Table Schema as below

     1. TenantList
        (
           TenantID     INT,
           NAme      VARCHAR(200)
        )  


     2.  PayrollMaster
        (
          PayrollID   INT PRIMARY KEY,
          HHAID       INT FOREIGN KEY TO TenantList(TenantID)
        )  

     3. PayrollDetails
       (
         PayrollDetailID    INT PRIMARY KEY,
         PayrollID          INT FOREIGN KEY TO PayrollMaster(PayrollID),
         HHAID              INT FOREIGN KEY TO TenantList(TenantID)
       )

   *   VSchema is as below
      {
       "sharded": true,
       "vindexes": {
        "hash": {
         "type": "hash"
        }
     },
    "tables": {
     "payrollmaster": {
     "column_vindexes": 
      [
       {
         "column": "HHA",
         "name": "hash"
       }
      ],
      "auto_increment": {
       "column": "PayrollInternalID",
       "sequence": "payrollmaster_seq"
      }
    },
    "payrolldetails": {
     "column_vindexes": 
     [
       {
         "column": "HHA",
         "name": "hash"
       }
     ],
     "auto_increment": {
       "column": "PayrollDetailInternalID",
       "sequence": "payrolldetails_seq"
     }
   }
 }
}


    We are inserting the Records like below
      use Payrolls;
      insert into the TenantList,PayrollMaster,PayrollDetails

We are expecting the Records to be scattered across the Shards but table has zero rows in the Shards.

Key Space and Shards were created as mentioned in the screenshot

is there any issue with the way we are trying.

Thanks


Solution

  • It looks like you want payrolls to be sharded. If so, you shouldn't create a shard "0". You should only specify shards "-80" and "80-"