Skip to content

Conversation

simolus3
Copy link
Contributor

This simplifies the recently-added logic to warn for duplicate databases. The actual functionality is unchanged, but:

  1. The detection for duplicate databases and the mutex allocation to guard against two active syncs was unified into a single class (ActiveDatabaseGroup).
  2. On PowerSyncDatabase, also guard disconnect() with a mutex. Since connecting, disconnecting and closing the database are all operations that can interfere with each other, I've used a single mutex for all of them.
  3. On native platforms, use a cleaner to automatically remove databases from the duplicate instance count when they're no longer referenced without close() being called. This can avoid a small memory leak. We should also investigate doing that on Java platforms, but convenient APIs are only available from Java 9+. So maybe something for another time...

@simolus3 simolus3 requested a review from stevensJourney March 21, 2025 13:43
Copy link
Contributor

@stevensJourney stevensJourney left a comment

Choose a reason for hiding this comment

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

Happy with the changes!

@simolus3 simolus3 merged commit 7d62a23 into main Mar 24, 2025
3 checks passed
@simolus3 simolus3 deleted the refactor-connector-mutexes branch March 24, 2025 08:31
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.

2 participants