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

fixed Cannot read property 'COLUMN_NAME' of undefined #21

Closed
wants to merge 2 commits into from

Conversation

DoubleSpout
Copy link

bug review: because i have modify the table name

qq 20151104103200

qq 20151104103045

fixed the bug~

I want to start from specify binlogfile and specify postion, so I have modified the startAtEnd Parameter, use it like this:

zongji.start({
    includeEvents: ['rotate', 'tablemap', 'writerows', 'updaterows', 'deleterows'],
    startAtEnd: {
        filename: 'binlog.000001',
        position: 1002,
    },
});

if startAtEnd assignment boolean, it works as well as before.
finally, thanks for your zongji module, I like it !

@nevill
Copy link
Owner

nevill commented Nov 8, 2015

@DoubleSpout Thanks for your feedback. I can reproduce the bug too. But I cannot make it working even with your Fix, let me figure it out later ...
BTW, can you use 2-space indent in your PR (that's what we do in this project)? And, it would be perfect if you could provide some unit tests. 😸

@@ -182,8 +191,13 @@ ZongJi.prototype.start = function(options) {
self.connection.pause();
self._fetchTableInfo(event, function() {
// merge the column info with metadata
event.updateColumnInfo();
self.emit('binlog', event);
try {
Copy link
Owner

Choose a reason for hiding this comment

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

I think we have a big Try ... catch block somewhere, to catch all the errors during parsing, not necessary here. Yeah, I'd like to have Try ... catch as few as possible. (even though, I'm not a Java Hater 😉 )

@jmealo
Copy link
Contributor

jmealo commented Dec 17, 2015

Not performing this operation causes invalid data structures that still crash Zongji later on. We need to figure out why the length of an array is zero, when we expect a non-zero length.

It seems like we're parsing a tablemap wrong. If we bail from parsing it, we get the event following the tablemap and crash anyway.

@nevill Is that what you think is going on as well?

@jmealo
Copy link
Contributor

jmealo commented Dec 17, 2015

@nevill The SQL query in fetchTableInfo sometimes returns 0 rows which is the cause of this error. When I run the query by hand, it returns the expected number of rows.

The query is a bit different in my fork since I added additional metadata. My query is also having the same issue.

 SELECT c.COLUMN_NAME, COLLATION_NAME, CHARACTER_SET_NAME, COLUMN_COMMENT, COLUMN_TYPE, IS_NULLABLE, t.CONSTRAINT_TYPE, k.ORDINAL_POSITION, k.CONSTRAINT_NAME FROM information_schema.columns c LEFT JOIN information_schema.KEY_COLUMN_USAGE k ON k.TABLE_NAME = c.TABLE_NAME AND k.TABLE_SCHEMA = c.TABLE_SCHEMA AND k.COLUMN_NAME = c.COLUMN_NAME LEFT JOIN information_schema.TABLE_CONSTRAINTS t ON t.TABLE_NAME = c.TABLE_NAME AND t.CONSTRAINT_SCHEMA = c.TABLE_SCHEMA AND t.CONSTRAINT_NAME = k.CONSTRAINT_NAME WHERE c.TABLE_SCHEMA = "<<schema>>" AND c.TABLE_NAME = "<<table>>"

@jmealo
Copy link
Contributor

jmealo commented Dec 17, 2015

In _fetchTableInfo:

  this.ctrlConnection.query(sql, function(err, rows) {
    if (err) {
      // Errors should be emitted
      self.emit('error', err);
      return;
    }

We might as well throw/die here because if we don't call next() Zongji will stop processing binlog events.

@jmealo
Copy link
Contributor

jmealo commented Dec 17, 2015

From the MySQL manual:
"Each MySQL user has the right to access these tables, but can see only the rows in the tables that correspond to objects for which the user has the proper access privileges. In some cases (for example, the ROUTINE_DEFINITION column in the INFORMATION_SCHEMA.ROUTINES table), users who have insufficient privileges will see NULL."

@felipesmendes
Copy link

I had the same issue using Mysql-Events package:

mysql-events

Someone solved?

@hamza610
Copy link

Has there been a resolution yet?
I updated my MySQL version to 5.7 from 5.5 and encountered this issue and when I reverted back to 5.5 the issue disappeared.

@millenovecento
Copy link

Hi All, to fix the problem for mysql 5.7 i added " order by c.ORDINAL_POSITION" to tableInfoQueryTemplate in index.js.

@nevill nevill requested review from numtel and removed request for numtel July 1, 2017 13:24
@nevill
Copy link
Owner

nevill commented Jul 1, 2017

Closing it because many things changed.

@nevill nevill closed this Jul 1, 2017
@jmealo
Copy link
Contributor

jmealo commented Jul 1, 2017

@nevill: Awesome, I haven't been keeping up to date with the project. I'm sure my 12/17/15 comment has to do with the root cause, which technically isn't a bug in the software but an environmental issue. It might be worth adding a special error message or tips in the documentation.

@rodrigogs
Copy link

It seems that mysql lib is return a wrong parseLengthCodedNumber. I wonder if it's ok to just assume the column length from the actual column array.

@taieb-tk
Copy link

Sorry for asking on a closed 4 year old thread. But this problem is occuring for me as well, seems like parseLengthCodedNumber -> Has the wrong length. The reason for it seems to be when i have a unique constraint in db. When i remove it, it works....

jirka124 added a commit to jirka124/zongji-fix-unique that referenced this pull request Nov 16, 2023
fix for another cause of: nevill#21

includes:
 : changes made to _fetchTableInfo method of ZongJi allowing fetch of both columns and hash indexes of table
 : added template for index query
 : added 2 functions fetching table info for readability
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.

None yet

8 participants