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

In multiThread Case , the statement will Loop forever #1801

Open
zhangyongtaocn opened this issue Jun 15, 2020 · 3 comments
Open

In multiThread Case , the statement will Loop forever #1801

zhangyongtaocn opened this issue Jun 15, 2020 · 3 comments

Comments

@zhangyongtaocn
Copy link

I'm submitting a bug report

Driver Version 4.2.14

Java Version jdk1.8

OS Version windows

PostgreSQL Version 12.2.3

To Reproduce
I use dbtransfer( https://github.com/evolute-pt/dbtransfer ) to copy Sql server database to PostSql
total 20 tables . but dbtransfer cannot stop,still running .
I debug the jdbc driver and fount the program run in Pgstatmement.java line 1004 -1008 ,loop forever .
I found this.statementState == StatementCancelState.IDLE
but the while block check if this.statementState == StatementCancelState.CANCELLED
so this loop cannot break .
I add code like
if(this.statementState == StatementCancelState.IDLE) //// ---- update 20200613
break;
then Program running OK

@davecramer
Copy link
Member

Is this

while (!STATE_UPDATER.compareAndSet(this, StatementCancelState.CANCELLED, StatementCancelState.IDLE)) {
try {
// Note: wait timeout here is irrelevant since synchronized(connection) would block until
// .cancel finishes
connection.wait(10);
} catch (InterruptedException e) { // NOSONAR
// Either re-interrupt this method or rethrow the "InterruptedException"
interrupted = true;
}
}
}
if (interrupted) {
Thread.currentThread().interrupt();
}
}
the code you are referring to?

@zhangyongtaocn
Copy link
Author

Yes, I add code after connection.wait(10);

@davecramer
Copy link
Member

Interesting, can you send a PR please

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

No branches or pull requests

2 participants