etcd-io / jetcd

etcd java client
Apache License 2.0
1.1k stars 315 forks source link

There is a conflict between the jetcd and @ Transactional annotations. When jetcd version is 0.7.0-0.7.6, there is an error of the program freezing directly to saveorupdate something to database by mybatis. #1275

Closed DarenSu closed 9 months ago

DarenSu commented 10 months ago

Versions

Describe the bug when jetcd version is 0.7.0-0.7.6, there is an error to saveorupdate something to database by mybatis. The thread will remain stuck in the data saving phase and the database will not receive a response.All the above operations do not involve ETCD operations.

To Reproduce Steps or reproducer to reproduce the behavior. This section must be provided, if not, the issue may not get attention.

The jetcd versions for the following two scenarios are the same, 0.7.0, but the results are different.

The following code was successfully executed

    @Override
 // @Transactional(rollbackFor = Exception.class)
    public boolean saveAndUpdate(Site site) {
        Site siteById = getById(site.getId());
        if (siteById.getId().isEmpty()) {
            return save(site);
        } else {
            updateById(site);
        }
        return true;
    }

Error in code execution below

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean saveAndUpdate(Site site) {
        Site siteById = getById(site.getId());
        if (siteById.getId().isEmpty()) {
            return save(site);
        } else {
            updateById(site);
        }
        return true;
    }

Expected behavior A clear and concise description of what you expected to happen.

Additional context Add any other context about the problem here.

lburgazzoli commented 10 months ago

For what I understood from the issue description, all the operations do not involve ETCD operations and I don't see any code releted to jetcd so either you provide a better description of the issue and a reproducer or I'll close it

DarenSu commented 10 months ago

For what I understood from the issue description, all the operations do not involve ETCD operations and I don't see any code releted to jetcd so either you provide a better description of the issue and a reproducer or I'll close it

From the code perspective, it does not involve the specific operation of ETCD, but this issue is strongly related to the version of Ketcd. The above code operation is normal in jetcd-0.5.8. Upgrading to jetcd-0.7.0 will result in this issue. Confirmed through exclusion method that if the version of jetcd is 0.7.0 or higher, there is a conflict between the @ Transactional annotation and it

DarenSu commented 10 months ago

For what I understood from the issue description, all the operations do not involve ETCD operations and I don't see any code releted to jetcd so either you provide a better description of the issue and a reproducer or I'll close it

When there is only a version change of jetcd in the entire code. When jetcd-0.5.8, there is no issue with the execution of the following two code blocks. However, when jetcd 0.7.0 is present, @ Transactional code blocks cannot be executed. It is suspected that there is a conflict between transactions and database transactions in versions of jetcd 0.7.0 and above, or jetcd usage has not been released. Because I am not very familiar with the specific implementation of jetcd, I am seeking help from your professional team.

The following code was successfully executed

    @Override
 // @Transactional(rollbackFor = Exception.class)
    public boolean saveAndUpdate(Site site) {
        Site siteById = getById(site.getId());
        if (siteById.getId().isEmpty()) {
            return save(site);
        } else {
            updateById(site);
        }
        return true;
    }

Error in code execution below

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean saveAndUpdate(Site site) {
        Site siteById = getById(site.getId());
        if (siteById.getId().isEmpty()) {
            return save(site);
        } else {
            updateById(site);
        }
        return true;
    }
liangyuanpeng commented 10 months ago

@DarenSu Hi, Jetcd do not use @Transactional and database, since you use mybatis-plus-core, so i suggest you submit your question to the mybatis-plus community.

DarenSu commented 10 months ago

I have conducted specific tests locally and found that it is not limited to issues with MyBatisPlus. But when the version of jetcd is 0.5.8, any function with @ Transactional annotation can execute normally. But when the version of jetcd is 0.7.0 and above, all functions with @ Transactional annotations will get stuck, meaning they cannot execute properly. As follows

@Component
public class MainWork {
  @AutoWired
  private DetailWork detailWork

  public void workflow() {
    detailWork.doSomeCheck();
    detailWork.doWork();
  }
}

@Component
public class DetailWork {

    @AutoWired
    UsefulService usefulService;

    @AutoWired
    InfoService infoService;

    @Transactional
    public void doWork() {
      usefulService.doSomeWork();
    }

    public void doSomeCheck() {
      infoService.getInfo();
    }
}
DarenSu commented 10 months ago

@DarenSu Hi, Jetcd do not use @Transactional and database, since you use mybatis-plus-core, so i suggest you submit your question to the mybatis-plus community. After specific local testing, it was found that not only mybatisplus. But it directly conflicts with the @ Transactional annotation

lburgazzoli commented 10 months ago

@DarenSu you probably need to check if there is any transitive dependency causing issues but as already stated, jetcd has nothing to do with @Transactional even more, it does not seems to be used at all in the code you posted.

lburgazzoli commented 10 months ago

@DarenSu any update ?

lburgazzoli commented 9 months ago

no updates from the reporter