Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

version 5.5.1 Sharding algorithm HASH_MOD initialization failed... #34161

Closed
zt9788 opened this issue Dec 26, 2024 · 4 comments
Closed

version 5.5.1 Sharding algorithm HASH_MOD initialization failed... #34161

zt9788 opened this issue Dec 26, 2024 · 4 comments

Comments

@zt9788
Copy link

zt9788 commented Dec 26, 2024

use version 5.5.1(Sharding-JDBC) the when program start there will be throw a exception.
the error is same too #31964

Sharding algorithm HASH_MOD initialization failed, table xxx tables sharding configuration can not use auto sharding algorithm...

I have table session, session_0 ...session_15
it is can work in version 5.3.2

the config is:


            sharding:
              tables:
                session:
                  actual-data-nodes: session_${0..15}
                  table-strategy:
                    standard:
                      sharding-column: uid
                      sharding-algorithm-name: session_hash_mod                  
              sharding-algorithms:
                session_hash_mod:
                  type: HASH_MOD
                  props:
                    sharding-count: 16

i saw the code sharding-jdbc will check the shardingAlgorithm is ShardingAutoTableAlgorithm
i change the HASH_MOD to INLINE it is have no exception.

private void checkManualShardingAlgorithm(String shardingAlgorithmName, String logicTable) {
        ShardingAlgorithm shardingAlgorithm = (ShardingAlgorithm)this.shardingAlgorithms.get(shardingAlgorithmName);
        ShardingSpherePreconditions.checkState(!(shardingAlgorithm instanceof ShardingAutoTableAlgorithm), () -> {
            return new AlgorithmInitializationException(shardingAlgorithm, "`%s` tables sharding configuration can not use auto sharding algorithm.", new Object[]{logicTable});
        });
    }

so how to fix it?

@zt9788 zt9788 changed the title version 5.5.1 Sharding algorithm HASH_MOD initialization failed, version 5.5.1 Sharding algorithm HASH_MOD initialization failed... Dec 26, 2024
@terrymanu
Copy link
Member

HASH_MOD can use in auto tables only.

@zt9788
Copy link
Author

zt9788 commented Dec 27, 2024

@terrymanu
i saw the doc that

  autoTables: # Auto Sharding table configuration
    t_order_auto: # Logic table name
      actualDataSources (?): # Data source names
      shardingStrategy: # Sharding strategy
        standard: # For single sharding column scenario
          shardingColumn: # Sharding column name
          shardingAlgorithmName: # Auto sharding algorithm name

auto table only have actualDataSources, there is have no actual-data-nodes, so , if i want use the hash to sharding table , i only use other way?

@terrymanu
Copy link
Member

terrymanu commented Dec 27, 2024

Please just follow the document.
The document does not specify that there is no such configuration.

@zt9788
Copy link
Author

zt9788 commented Dec 27, 2024

@terrymanu

I don't understand why the hash_mod sharding configuration of tables is not supported, but it is supported in the lower version (5.3.2). Is it for any consideration? In this case, the higher version is not compatible
Of course, I can continue implementing hash partitioning through inline, but there will be many changes

@zt9788 zt9788 closed this as completed Dec 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants