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

Update ConnectionProvider to support AWS writer failovers #113

Conversation

aegbert5
Copy link
Contributor

@aegbert5 aegbert5 commented Sep 3, 2024

No description provided.

worker/build.sbt Outdated Show resolved Hide resolved
@aegbert5 aegbert5 force-pushed the update-connection-provider-to-support-aws-writer-failovers branch 4 times, most recently from 4aea4e8 to 81e2fb2 Compare September 5, 2024 20:45
testConn = connectionPool.getConnection()
} catch {
case _: SQLTransientConnectionException => { TimeUnit.MILLISECONDS.sleep(100) } // do nothing
case e: Exception => throw e
Copy link
Contributor

Choose a reason for hiding this comment

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

This is unnecessary. If you don't catch an excetpion in a catch block it will automatically get rethrown

Copy link

@hunterrees hunterrees left a comment

Choose a reason for hiding this comment

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

Minor feedback around how to handle options

Copy link
Contributor

@tmccombs tmccombs left a comment

Choose a reason for hiding this comment

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

Actually, we need to fix the synchronization issue before merging.

@aegbert5 aegbert5 force-pushed the update-connection-provider-to-support-aws-writer-failovers branch from 725a4d9 to 4ec9ad4 Compare September 18, 2024 20:25
size > 1
}
})
// TODO: override "removeEldestEntry"
Copy link
Contributor

Choose a reason for hiding this comment

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

you can revome this now right?

private val cachedIpWithExpiration: java.util.Map[String, CachedIpWithExpiration] = Collections.synchronizedMap(new LinkedHashMap[String, CachedIpWithExpiration]() {
// There is only 1 element to be stored in this list at a time, so we remove the oldest entries once we reach 2+ entries
override def removeEldestEntry(eldest: java.util.Map.Entry[String, CachedIpWithExpiration]): Boolean = {
size > 1
Copy link
Contributor

Choose a reason for hiding this comment

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

wait.... if we only have 1 entry, maybe it would be simpler just to have a variable for this (synchronized, or maybe @volatile?)

Copy link
Contributor Author

@aegbert5 aegbert5 Sep 19, 2024

Choose a reason for hiding this comment

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

Yeah probably simpler to do make is a single optional object. I think @volatile should be adequate over using synchronized since as long as there is a cached entry to use, we shouldn't care about whether another thread tried to enter the new or old DNS result into the cache.

Copy link
Contributor Author

@aegbert5 aegbert5 Sep 19, 2024

Choose a reason for hiding this comment

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

On second thought, perhaps synchronized may be better here. It just makes the cache more reliable if there isn't a race-condition between which IP value is set for the DNS cache

@aegbert5 aegbert5 requested a review from tmccombs September 19, 2024 16:58
@aegbert5 aegbert5 force-pushed the update-connection-provider-to-support-aws-writer-failovers branch from 4ec9ad4 to 89bb6a6 Compare September 19, 2024 17:54
@aegbert5 aegbert5 force-pushed the update-connection-provider-to-support-aws-writer-failovers branch from 89bb6a6 to 10e041e Compare September 19, 2024 18:19
@aegbert5 aegbert5 force-pushed the update-connection-provider-to-support-aws-writer-failovers branch from 10e041e to c571102 Compare September 19, 2024 18:43
@tmccombs tmccombs merged commit d0801c5 into lucidsoftware:master Sep 19, 2024
1 check passed
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.

3 participants