lsy3993 opened a new pull request, #53151:
URL: https://github.com/apache/doris/pull/53151

   ### What problem does this PR solve?
   
   Issue Number: close #xxx
   
   Related PR: #50638
   
   Problem Summary:
   When I use CCR to sync a database to another, I encounter this error in 
fe.log:
   ```
   java.lang.NullPointerException: Cannot invoke 
"org.apache.doris.analysis.AbstractBackupTableRefClause.getTableRefList()" 
because "restoreTableRefClause" is null
           at 
org.apache.doris.service.FrontendServiceImpl.restoreSnapshotImpl(FrontendServiceImpl.java:3147)
 ~[doris-fe.jar:1.2-SNAPSHOT]
           at 
org.apache.doris.service.FrontendServiceImpl.restoreSnapshot(FrontendServiceImpl.java:3038)
 ~[doris-fe.jar:1.2-SNAPSHOT]
           at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native 
Method) ~[?:?]
           at 
jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
 ~[?:?]
           at 
jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 ~[?:?]
           at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
           at 
org.apache.doris.service.FeServer.lambda$start$0(FeServer.java:60) 
~[doris-fe.jar:1.2-SNAPSHOT]
           at jdk.proxy2.$Proxy26.restoreSnapshot(Unknown Source) ~[?:?]
           at 
org.apache.doris.thrift.FrontendService$Processor$restoreSnapshot.getResult(FrontendService.java:4552)
 ~[fe-common-1.2-SNAPSHOT.jar:1.2-SNAPSHOT]
           at 
org.apache.doris.thrift.FrontendService$Processor$restoreSnapshot.getResult(FrontendService.java:4532)
 ~[fe-common-1.2-SNAPSHOT.jar:1.2-SNAPSHOT]
           at 
org.apache.thrift.ProcessFunction.process(ProcessFunction.java:38) 
~[libthrift-0.16.0.jar:0.16.0]
           at org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:38) 
~[libthrift-0.16.0.jar:0.16.0]
           at 
org.apache.thrift.server.TThreadPoolServer$WorkerProcess.run(TThreadPoolServer.java:250)
 ~[libthrift-0.16.0.jar:0.16.0]
           at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) 
~[?:?]
   ```
   so I fix the NPE. 
   BTW the code `ctx.getEnv()` may get a null pointer, so I fix it, too.
   
   The reproduce steps are:
   
   - create the database and table
   ```
     create database test;
   
     CREATE TABLE IF NOT EXISTS test.t1
     (
         `user_id` LARGEINT NOT NULL COMMENT "用户id",
         `name` VARCHAR(20) COMMENT "用户所在城市"
     ) ENGINE = olap
     DUPLICATE KEY(`user_id`)
     DISTRIBUTED BY HASH(`user_id`) BUCKETS 2
     PROPERTIES ("replication_num" = "1");
   
     INSERT INTO test.t1 VALUES (1, 'a'), (2, 'b');
   ```
   
   - enable binlog
   ```
   ALTER TABLE test.t1 SET ("binlog.enable" = "true");
   
   ALTER DATABASE test SET properties ("binlog.enable" = "true", 
"binlog.ttl_seconds"="86400");
   ```
   
   - start CCR process
   ```
   git clone [email protected]:selectdb/ccr-syncer.git
   cd ccr-syncer
   sh build.sh
   cd output/bin && sh start_syncer.sh --log_level trace
   ```
   
   - create a post request to CCR
   ```
   curl -X POST -H "Content-Type: application/json" -d '{
       "name": "test_for_ccr_1",
       "src": {
       "host": "my_doris_fe_ip",
       "port": "9030",
       "thrift_port": "9020",
       "user": "root",
       "password": "",
       "database": "test",
       "table": ""
       },
       "dest": {
       "host": "my_doris_fe_ip",
       "port": "9030",
       "thrift_port": "9020",
       "user": "root",
       "password": "",
       "database": "test_dest",
       "table": ""
       }
   }' http://127.0.0.1:9190/create_ccr
   ```
   
   - get the error log
   
   ### Release note
   
   None
   
   ### Check List (For Author)
   
   - Test <!-- At least one of them must be included. -->
       - [ ] Regression test
       - [ ] Unit Test
       - [ ] Manual test (add detailed scripts or steps below)
       - [ ] No need to test or manual test. Explain why:
           - [ ] This is a refactor/code format and no logic has been changed.
           - [ ] Previous test can cover this change.
           - [ ] No code files have been changed.
           - [ ] Other reason <!-- Add your reason?  -->
   
   - Behavior changed:
       - [ ] No.
       - [ ] Yes. <!-- Explain the behavior change -->
   
   - Does this need documentation?
       - [x] No.
       - [ ] Yes. <!-- Add document PR link here. eg: 
https://github.com/apache/doris-website/pull/1214 -->
   
   ### Check List (For Reviewer who merge this PR)
   
   - [ ] Confirm the release note
   - [ ] Confirm test cases
   - [ ] Confirm document
   - [ ] Add branch pick label <!-- Add branch pick label that this PR should 
merge into -->
   
   


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to