MilanTyagi2004 commented on PR #37472:
URL: https://github.com/apache/shardingsphere/pull/37472#issuecomment-3688714763

   > > Currently, with an auto-increment ID scheme, there might be a scenario 
where some clients use connection pools while others connect directly. Suppose 
the auto-increment ID overflows but some original connections haven’t been 
released yet. In that case, duplicate IDs could occur. I think we can manage 
this by maintaining a bitmap based on the maximum number of connections. This 
would allow us to quickly find the next available ID. Do you agree? @terrymanu 
@MilanTyagi2004
   > 
   > I will open a new issue to discuss this problem. In the meantime, I think 
we should pause any further work on this PR.
   
   
   > Currently, with an auto-increment ID scheme, there might be a scenario 
where some clients use connection pools while others connect directly. Suppose 
the auto-increment ID overflows but some original connections haven’t been 
released yet. In that case, duplicate IDs could occur. I think we can manage 
this by maintaining a bitmap based on the maximum number of connections. This 
would allow us to quickly find the next available ID. Do you agree? @terrymanu 
@MilanTyagi2004
   
   
   
   > Currently, with an auto-increment ID scheme, there might be a scenario 
where some clients use connection pools while others connect directly. Suppose 
the auto-increment ID overflows but some original connections haven’t been 
released yet. In that case, duplicate IDs could occur. I think we can manage 
this by maintaining a bitmap based on the maximum number of connections. This 
would allow us to quickly find the next available ID. Do you agree? @terrymanu 
@MilanTyagi2004
   
   Thanks for pointing this out. I agree this scenario can lead to duplicate 
IDs when auto-increment overflows and some connections are still active 
(especially with mixed pooled and direct connections).
   
   To handle this safely, I used a BitSet to track allocated connection IDs up 
to the maximum allowed connections. On allocation, we pick the next clear bit, 
and on release, we clear it. This ensures an ID is reused only after the 
original connection is fully released, even after overflow.
   
   This avoids collisions, works well with connection pools, and keeps the 
behavior deterministic.
   


-- 
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]

Reply via email to