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

bugfix:server start and handle remain branch session may cause NPE #1237

Merged
merged 4 commits into from
Jun 25, 2019
Merged

bugfix:server start and handle remain branch session may cause NPE #1237

merged 4 commits into from
Jun 25, 2019

Conversation

Justice-love
Copy link
Contributor

Ⅰ. Describe what this PR did

server start and handle remain branch session may cause it

Ⅱ. Does this pull request fix one issue?

  1. BranchSession does not encode/decode branchType
  2. DefaultCoordinator and SessionHolder init and start schedule handle rollback session
  3. handle remain branch session ,such as rollback session, send BranchRollbackRequest
  4. encode BranchRollbackRequest, append branchType code byteBuffer.put((byte)this.branchType.ordinal());
  5. cause NPE and close channel
            future.addListener(new ChannelFutureListener() {
                @Override
                public void operationComplete(ChannelFuture future) {
                    if (!future.isSuccess()) {
                        MessageFuture messageFuture = futures.remove(rpcMessage.getId());
                        if (messageFuture != null) {
                            messageFuture.setResultMessage(future.cause());
                        }
                        destroyChannel(future.channel());
                    }
                }
            });

Ⅲ. Why don't you add test cases (unit test/integration test)?

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@codecov-io
Copy link

codecov-io commented Jun 25, 2019

Codecov Report

Merging #1237 into develop will decrease coverage by 0.02%.
The diff coverage is 66.66%.

Impacted file tree graph

@@              Coverage Diff              @@
##             develop    #1237      +/-   ##
=============================================
- Coverage      44.94%   44.92%   -0.03%     
  Complexity      1488     1488              
=============================================
  Files            253      253              
  Lines          10274    10279       +5     
  Branches        1335     1337       +2     
=============================================
  Hits            4618     4618              
- Misses          5070     5072       +2     
- Partials         586      589       +3
Impacted Files Coverage Δ Complexity Δ
...in/java/io/seata/server/session/BranchSession.java 78.19% <66.66%> (-0.72%) 41 <0> (ø)
...server/store/file/FileTransactionStoreManager.java 45.99% <0%> (-1.05%) 19% <0%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7979580...27d7e1b. Read the comment docs.

@Justice-love
Copy link
Contributor Author

这个bug会导致RM注册上来的通道被关闭, 会有大量通道被关闭异常, 使用方非常难以判断真是问题

    @Override
    public Object sendSyncRequest(String resourceId, String clientId, Object message,
                                  long timeout) throws TimeoutException {
        Channel clientChannel = ChannelManager.getChannel(resourceId, clientId);
        if (clientChannel == null) {
            throw new RuntimeException("rm client is not connected. dbkey:" + resourceId
                + ",clientId:" + clientId);

        }
        return sendAsyncRequestWithResponse(null, clientChannel, message, timeout);
    }

        retryRollbacking.scheduleAtFixedRate(() -> {
            try {
                handleRetryRollbacking();
            } catch (Exception e) {
                LOGGER.info("Exception retry rollbacking ... ", e);
            }
        }, 0, rollbackingRetryDelay, TimeUnit.SECONDS);

Copy link
Member

@slievrly slievrly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@slievrly slievrly changed the title fix NPE, server start and handle remain branch session may cause it bugfix:server start and handle remain branch session may cause NPE Jun 25, 2019
@slievrly slievrly merged commit 7039f91 into apache:develop Jun 25, 2019
@Justice-love Justice-love deleted the pr branch June 25, 2019 07:09
@leizhiyuan leizhiyuan modified the milestone: 0.7.0 Jul 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants