-
Notifications
You must be signed in to change notification settings - Fork 25
[Postgres Storage] Ability to use the same server #186
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
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
b1344e7
cleanup persisted queries
stevensJourney 7cea06b
minor cleanup
stevensJourney 5aa55e9
Add support for same postgres cluster for replication and sync storage
stevensJourney c95608d
Merge remote-tracking branch 'origin/main' into pg-storage-2
stevensJourney b3894c9
add error code
stevensJourney 37e9228
add error cause
stevensJourney e63a4e1
update to use replica set name
stevensJourney 4f66e95
add unit test for streaming errors
stevensJourney 8cda6ff
throw an error on initial replication if storage is incompatible
stevensJourney cc27649
update readme
stevensJourney bfe54fb
fix test
stevensJourney e9c5f3d
code cleanup
stevensJourney aad0fa1
wording update
stevensJourney aae2ae3
Merge remote-tracking branch 'origin/main' into pg-storage-2
stevensJourney 031d7ac
cleanup
stevensJourney c7329bb
added changeset
stevensJourney ea5c3f8
fix notification bug
stevensJourney 4c41510
cleanup keepAlive variables
stevensJourney 5d6da80
allow using the same database for replication source and storage.
stevensJourney a65f03c
cleanup comments
stevensJourney 4c9b61f
Merge remote-tracking branch 'origin/main' into pg-storage-2
stevensJourney f076c44
acknowledge more often when out of tx
stevensJourney 834b990
share keepalive statement for write checkpoints
stevensJourney File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@powersync/service-module-postgres-storage': minor | ||
'@powersync/service-module-postgres': minor | ||
--- | ||
|
||
Allowed using the same Postgres server for the replication source and sync bucket storage. This is only supported on Postgres versions newer than 14.0. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@powersync/service-module-postgres-storage': minor | ||
'@powersync/service-module-mongodb-storage': minor | ||
'@powersync/service-core': minor | ||
--- | ||
|
||
Added the ability to skip creating empty sync checkpoints if no changes were present in a batch. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@powersync/service-module-postgres-storage': patch | ||
--- | ||
|
||
Fix bug where listening to active checkpoint notifications on an ended connection could cause a crash. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import * as pgwire from '@powersync/service-jpgwire'; | ||
import { retriedQuery } from './pgwire_utils.js'; | ||
|
||
export interface DecodedPostgresIdentifier { | ||
server_id: string; | ||
database_name: string; | ||
} | ||
|
||
export const decodePostgresSystemIdentifier = (identifier: string): DecodedPostgresIdentifier => { | ||
const [server_id, database_name] = identifier.split('.'); | ||
return { server_id, database_name }; | ||
}; | ||
|
||
export const encodePostgresSystemIdentifier = (decoded: DecodedPostgresIdentifier): string => { | ||
return `${decoded.server_id}.${decoded.database_name}`; | ||
}; | ||
|
||
export const queryPostgresSystemIdentifier = async ( | ||
connection: pgwire.PgClient | ||
): Promise<DecodedPostgresIdentifier> => { | ||
const result = pgwire.pgwireRows( | ||
await retriedQuery( | ||
connection, | ||
/* sql */ ` | ||
SELECT | ||
current_database() AS database_name, | ||
system_identifier | ||
FROM | ||
pg_control_system(); | ||
` | ||
) | ||
) as Array<{ database_name: string; system_identifier: bigint }>; | ||
|
||
return { | ||
database_name: result[0].database_name, | ||
server_id: result[0].system_identifier.toString() | ||
}; | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './identifier-utils.js'; | ||
export * from './pgwire_utils.js'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.