terrymanu commented on issue #22553:
URL:
https://github.com/apache/shardingsphere/issues/22553#issuecomment-3635553517
## Understanding
- Environment: ShardingSphere-Proxy 5.2.2-SNAPSHOT (commit 753c0cee…),
Cluster mode, two data sources ds_0/ds_1 (even/odd sharding),
sql-federation-type=ADVANCED.
- Symptom: View select_view on t_order returns only even user_id
(10,12…28); direct query select distinct(user_id) from t_order order by user_id
returns full 10–29 set.
## Root Cause
- The view is not defined in sharding rules; create view runs only on the
default data source ds_0, and select * from select_view is routed only to ds_0.
The view reads ds_0’s physical t_order, so results include only that shard’s
data.
- Advanced Federation does not expand cross-shard views or auto-broadcast
DDL; there is also no metadata lock/consistency, so concurrent DDL or
multi-instance deployments can leave the view present on some nodes only.
## Analysis
- Logs show Actual SQL for create view and select * from select_view only
on ds_0, while the distinct query on the sharded table hits ds_0+ds_1, matching
the “even-only” result.
- ShardingSphere usage convention: objects not declared in rules default
to single-database routing; cross-shard logical views are not automatically
aggregated. Running DDL immediately and without metadata locking means
multi-instance/multi-connection DDL can diverge
the view state across nodes.
## Conclusion
- This is a usage limitation, not a confirmed product bug. Avoid creating
cross-shard views through Proxy on sharded tables. Use the raw SQL (select
distinct(user_id) from t_order order by user_id) directly, or, if you insist on
a view, manually create identical views
on every shard and access them explicitly (routing still defaults to a
single db). If you must run DDL, keep it single-instance and serialized to
avoid metadata races. If the issue persists, please share whether multiple
Proxy instances/clients ran DDL concurrently,
per-shard existence of the view, and full routing/log details.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]