Skip to content

Commit

Permalink
use get_latest_version
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw committed Nov 7, 2024
1 parent 48b729d commit 9efeeaf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
2 changes: 1 addition & 1 deletion kong/clustering/services/sync/strategies/postgres.lua
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ end
function _M:get_latest_version()
local sql = "SELECT MAX(version) FROM clustering_sync_version"

local res, err = self.connector:query(sql)
local res, err = self.connector:query(sql, "read")
if not res then
return nil, err
end
Expand Down
11 changes: 2 additions & 9 deletions kong/db/declarative/export.lua
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,9 @@ local function export_from_db_impl(emitter, skip_ws, skip_disabled_entities, exp

local sync_version
if emitter.want_sync_version then
ok, err = db.connector:query("SELECT max(version) from clustering_sync_version", "read")
if not ok then
return nil, err
end
local strategy = require("kong.clustering.services.sync.strategies.postgres").new(db)

-- it will be ngx.null when the table clustering_sync_version is empty
sync_version = assert(ok[1].max)
if sync_version == null then
sync_version = 0
end
sync_version = strategy:get_latest_version()
end

emitter:emit_toplevel({
Expand Down

0 comments on commit 9efeeaf

Please sign in to comment.