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

[Fix][Server] Fix datatype convert error #467

Merged
merged 1 commit into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,12 @@ public static DataVinesDataType getType(String type) {
}

type = type.toLowerCase();
if (type.contains("int") || "decimal".equalsIgnoreCase(type)
|| type.contains("float") || "double".equalsIgnoreCase(type)
|| type.contains("number") || type.contains("numeric") || type.contains("real") || type.contains("serial")) {
if (type.contains("int") || type.contains("decimal")
|| type.contains("float") || type.contains("double")
|| type.contains("number") || type.contains("numeric")
|| type.contains("real") || type.contains("serial")) {
return NUMERIC_TYPE;
} else if (type.contains("char") || "blob".equalsIgnoreCase(type) || type.contains("text")) {
} else if (type.contains("char") || type.contains("blob") || type.contains("text")) {
return STRING_TYPE;
} else if (type.contains("time") || type.contains("date")) {
return DATE_TIME_TYPE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import java.sql.*;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
Expand All @@ -36,21 +37,21 @@ public class MysqlMutex {

public static final long LOCK_ACQUIRE_INTERVAL = 1000;

private final long expireTimeWindow = 5000;
private final long expireTimeWindow = 600;

private Connection connection;

private final Properties properties;

private final ServerInfo serverInfo;

private final Map<String, RegistryLock> lockHoldMap;
private final ConcurrentHashMap<String, RegistryLock> lockHoldMap;

public MysqlMutex(Connection connection, Properties properties) throws SQLException {
this.connection = connection;
this.properties = properties;
this.serverInfo = new ServerInfo(NetUtils.getHost(), Integer.valueOf((String) properties.get("server.port")));
this.lockHoldMap = new HashMap<>();
this.lockHoldMap = new ConcurrentHashMap<>();
ScheduledExecutorService lockTermUpdateThreadPool = Executors.newSingleThreadScheduledExecutor(
new ThreadFactoryBuilder().setNameFormat("RegistryLockRefreshThread").setDaemon(true).build());

Expand Down Expand Up @@ -78,6 +79,11 @@ public boolean acquire(String lockKey, long time) {
count = 0;
} catch (SQLException e) {
log.error("Acquire the lock error, {}, try again!", e.getLocalizedMessage());
try {
clearExpireLock();
} catch (SQLException ex) {
log.error("clear expire lock error : ", ex);
}
ThreadUtils.sleep(LOCK_ACQUIRE_INTERVAL);
count--;
}
Expand Down Expand Up @@ -137,9 +143,10 @@ private void executeDelete(String key) throws SQLException {
checkConnection();
PreparedStatement preparedStatement = connection.prepareStatement("delete from dv_registry_lock where lock_key = ?");
preparedStatement.setString(1, key);
preparedStatement.executeUpdate();
if (preparedStatement.executeUpdate() > 0) {
lockHoldMap.remove(key);
}
preparedStatement.close();
lockHoldMap.remove(key);
}

private boolean isExists(String key, ServerInfo serverInfo) throws SQLException {
Expand Down
Loading