<p dir="auto">I don't know what happened</p>
<h2 dir="auto">Bug Report</h2>
<p dir="auto">When i test <code class="notranslate">RuleAlteredJobAPIImpl.stopClusterWriteDB</code> method<br>
<code class="notranslate">lock.tryLock()</code> execute succeed, but the <code class="notranslate">lock.isLocked()</code> return false.</p>
<h3 dir="auto">Which version of ShardingSphere did you use?</h3>
<p dir="auto">master <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/apache/shardingsphere/commit/b4f748242ca44dc4d3319d9b5a8f5ada08765f8a/hovercard" href="https://github.com/apache/shardingsphere/commit/b4f748242ca44dc4d3319d9b5a8f5ada08765f8a"><tt>b4f7482</tt></a></p>
<h3 dir="auto">Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?</h3>
<p dir="auto">ShardingSphere-Proxy</p>
<h3 dir="auto">Expected behavior</h3>
<p dir="auto"><code class="notranslate">lock.isLocked()</code>  return success.</p>
<h3 dir="auto">Actual behavior</h3>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/101622833/167120472-ba08734b-ea5f-4ab3-9f92-c98b6e827f30.png"><img width="954" alt="image" src="https://user-images.githubusercontent.com/101622833/167120472-ba08734b-ea5f-4ab3-9f92-c98b6e827f30.png" style="max-width: 100%;"></a></p>
<h3 dir="auto">Reason analyze (If you can)</h3>
<h3 dir="auto">Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.</h3>
<ul dir="auto">
<li>Step 1<br>
Start multiple proxy, they share the same zookeeperr configuration<br>
eg:<br>
proxy one is on port 3307, proxy two is on port 3308</li>
</ul>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/101622833/167120783-6aadbd9e-d723-4340-a16a-053f31517a7d.png"><img width="1439" alt="image" src="https://user-images.githubusercontent.com/101622833/167120783-6aadbd9e-d723-4340-a16a-053f31517a7d.png" style="max-width: 100%;"></a></p>
<p dir="auto">server.yaml</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="mode:
  type: Cluster
  repository:
    type: ZooKeeper
    props:
      namespace: pg
      server-lists: localhost:2181
      retryIntervalMilliseconds: 500
      timeToLiveSeconds: 60
      maxRetries: 3
      operationTimeoutMilliseconds: 500
  overwrite: true

rules:
  - !AUTHORITY
    users:
      - root@%:root
      - sharding@:sharding
    provider:
      type: ALL_PRIVILEGES_PERMITTED
  - !SQL_PARSER
    sqlCommentParseEnabled: true
    sqlStatementCache:
      initialCapacity: 2000
      maximumSize: 65535
      concurrencyLevel: 4
    parseTreeCache:
      initialCapacity: 128
      maximumSize: 1024
      concurrencyLevel: 4

props:
  max-connections-size-per-query: 1
  kernel-executor-size: 16  # Infinite by default.
  proxy-frontend-flush-threshold: 128  # The default value is 128.
  proxy-hint-enabled: false
  sql-show: true
  check-table-metadata-enabled: false
  show-process-list-enabled: false
    # Proxy backend query fetch size. A larger value may increase the memory usage of ShardingSphere Proxy.
    # The default value is -1, which means set the minimum value for different JDBC drivers.
  proxy-backend-query-fetch-size: -1
  check-duplicate-table-enabled: false
  proxy-frontend-executor-size: 0 # Proxy frontend executor size. The default value is 0, which means let Netty decide.
    # Available options of proxy backend executor suitable: OLAP(default), OLTP. The OLTP option may reduce time cost of writing packets to client, but it may increase the latency of SQL execution
    # and block other clients if client connections are more than `proxy-frontend-executor-size`, especially executing slow SQL.
  proxy-backend-executor-suitable: OLAP
  proxy-frontend-max-connections: 0 # Less than or equal to 0 means no limitation.
  sql-federation-enabled: false
    # Available proxy backend driver type: JDBC (default), ExperimentalVertx
  proxy-backend-driver-type: JDBC
  proxy-mysql-default-version: 5.7.22 # In the absence of schema name, the default version will be used.
  proxy-default-port: 3307 # Proxy default port.
  proxy-frontend-database-protocol-type: PostgreSQL"><pre class="notranslate"><code class="notranslate">mode:
  type: Cluster
  repository:
    type: ZooKeeper
    props:
      namespace: pg
      server-lists: localhost:2181
      retryIntervalMilliseconds: 500
      timeToLiveSeconds: 60
      maxRetries: 3
      operationTimeoutMilliseconds: 500
  overwrite: true

rules:
  - !AUTHORITY
    users:
      - root@%:root
      - sharding@:sharding
    provider:
      type: ALL_PRIVILEGES_PERMITTED
  - !SQL_PARSER
    sqlCommentParseEnabled: true
    sqlStatementCache:
      initialCapacity: 2000
      maximumSize: 65535
      concurrencyLevel: 4
    parseTreeCache:
      initialCapacity: 128
      maximumSize: 1024
      concurrencyLevel: 4

props:
  max-connections-size-per-query: 1
  kernel-executor-size: 16  # Infinite by default.
  proxy-frontend-flush-threshold: 128  # The default value is 128.
  proxy-hint-enabled: false
  sql-show: true
  check-table-metadata-enabled: false
  show-process-list-enabled: false
    # Proxy backend query fetch size. A larger value may increase the memory usage of ShardingSphere Proxy.
    # The default value is -1, which means set the minimum value for different JDBC drivers.
  proxy-backend-query-fetch-size: -1
  check-duplicate-table-enabled: false
  proxy-frontend-executor-size: 0 # Proxy frontend executor size. The default value is 0, which means let Netty decide.
    # Available options of proxy backend executor suitable: OLAP(default), OLTP. The OLTP option may reduce time cost of writing packets to client, but it may increase the latency of SQL execution
    # and block other clients if client connections are more than `proxy-frontend-executor-size`, especially executing slow SQL.
  proxy-backend-executor-suitable: OLAP
  proxy-frontend-max-connections: 0 # Less than or equal to 0 means no limitation.
  sql-federation-enabled: false
    # Available proxy backend driver type: JDBC (default), ExperimentalVertx
  proxy-backend-driver-type: JDBC
  proxy-mysql-default-version: 5.7.22 # In the absence of schema name, the default version will be used.
  proxy-default-port: 3307 # Proxy default port.
  proxy-frontend-database-protocol-type: PostgreSQL
</code></pre></div>
<ul dir="auto">
<li>Step 2</li>
</ul>
<blockquote>
<p dir="auto">make sure already install docker, IT test will use it.</p>
</blockquote>
<p dir="auto">open the class <code class="notranslate">org.apache.shardingsphere.integration.data.pipeline.cases.postgresql.PostgreSQLManualScalingIT</code><br>
edit run configuration. add <code class="notranslate">-Dit.cluster.env.type=native -Dit.env.postgresql.version=postgres:12</code></p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/101622833/167121628-8f9e6d88-5685-4dd4-a687-31cab183feac.png"><img width="1040" alt="image" src="https://user-images.githubusercontent.com/101622833/167121628-8f9e6d88-5685-4dd4-a687-31cab183feac.png" style="max-width: 100%;"></a></p>
<p dir="auto">then execute the IT test</p>
<p dir="auto">The final problem was<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/101622833/167122112-ab44e4ee-2222-4654-8c6c-cffd4db8df58.png"><img width="1190" alt="image" src="https://user-images.githubusercontent.com/101622833/167122112-ab44e4ee-2222-4654-8c6c-cffd4db8df58.png" style="max-width: 100%;"></a><br>
seems not lock succeed before.</p>