-
Notifications
You must be signed in to change notification settings - Fork 12
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
Handle NumberFormatException in debezium while updating sequence max value for sequence on non-integer column #2360
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,8 +129,15 @@ public void processRecord(Record r){ | |
} | ||
String seqName = getFromColumnSequenceMap(schemaOrDbname, r.t.tableName, r.afterValueColumns.get(i)); | ||
if (seqName != null){ | ||
Long columnValue = Long.valueOf(r.afterValueValues.get(i).toString()); | ||
sequenceMax.put(seqName, Math.max(sequenceMax.get(seqName), columnValue)); | ||
Long columnValue = null; | ||
String value = r.afterValueValues.get(i).toString(); | ||
try { | ||
columnValue = Long.valueOf(value); | ||
sequenceMax.put(seqName, Math.max(sequenceMax.get(seqName), columnValue)); | ||
} catch (NumberFormatException e) { | ||
//Skipping the sequences that are not on Integer columns | ||
LOGGER.info("Skipping unsupported sequence with non-interger value: '{}'", seqName); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps DEBUG would be better? otherwise this would come up for every single row. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, okay |
||
} | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -214,4 +214,39 @@ WITH region_list AS ( | |
amount[1 + mod(n, array_length(amount, 1))], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this test already running in live migration & offline with BETA_FAST_DATA_EXPORT? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only Offline with Beta_fast mode, we don't run pg_sequences test for live-migration currently |
||
'Branch ' || n as branch, | ||
region[1 + mod(n, array_length(region, 1))] | ||
FROM amount_list, region_list, generate_series(1,1000) as n; | ||
FROM amount_list, region_list, generate_series(1,1000) as n; | ||
|
||
CREATE SEQUENCE user_code_seq | ||
START WITH 1 | ||
INCREMENT BY 1; | ||
|
||
CREATE OR REPLACE FUNCTION generate_user_code() RETURNS TEXT AS $$ | ||
DECLARE | ||
new_code TEXT; | ||
BEGIN | ||
SELECT 'USR' || LPAD(nextval('user_code_seq')::TEXT, 4, '0') | ||
INTO new_code; | ||
RETURN new_code; | ||
END; | ||
$$ LANGUAGE plpgsql; | ||
|
||
CREATE TABLE users ( | ||
user_id SERIAL PRIMARY KEY, | ||
user_code TEXT UNIQUE, | ||
name TEXT | ||
); | ||
|
||
ALTER TABLE ONLY users ALTER COLUMN user_code SET DEFAULT generate_user_code() | ||
|
||
ALTER SEQUENCE public.user_code_seq OWNED BY public.users.user_code; | ||
|
||
INSERT INTO users (name) | ||
VALUES ('John Doe'); | ||
|
||
INSERT INTO users (name) | ||
VALUES ('ABC'); | ||
|
||
INSERT INTO users (name) | ||
VALUES ('XYZ'); | ||
|
||
SELECT * FROM users; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add more context in the comment on the type of sequences and why they could fail with a NumberFormatException?