Menu

Updated field not replicated

Help
2008-03-25
2012-09-19
  • Johnny Bergström

    Hi!
    I've been looking for a solution for this problem on IRC and mysql forums but without any luck so I try here.

    I'm using FreeBSD 6.2 with FreeBSD port "mysql-server-5.0.51a" and MySQLdb-1.2.2.
    When executing the following script:

    >>> import MySQLdb
    >>> db = MySQLdb.connect('127.0.0.1', 'root')
    >>> c = db.cursor()
    >>> c.execute("UPDATE temp.test SET field=1")
    1L
    >>> db.commit()
    >>> db.close()

    the updated value is indeed shown on the local mysql server,
    but not when selecting the same field from a slave database that is replicating this field.
    For some reason, no updates are shown on replication. But no errors are shown either and the update gets stored on the database that I connect to.

    If I update the exact same field with the mysql command line tool (or PHP mysqli module), the value also changes on the slave server as it should be.
    Any idea of how to solve this?

     
    • Johnny Bergström

      I found out why this happend now :)
      Sorry to blaim the mysqldb guys, it was a general mysql problem.

      When I do this: "update database.table set field=1" it gets saved but NOT replicated.
      While instead doing this: "use database; update table set field=1", it gets replicateed.

      No warnings, no errors, it gets saved in both cases. So why does it not replicate? I think it's very strange, I'll have to ask the mysql guys

       
      • Andy Dustman

        Andy Dustman - 2008-03-25

        See what this does:

        >>> import MySQLdb
        >>> db = MySQLdb.connect('127.0.0.1', 'root', db="temp")
        >>> c = db.cursor()
        >>> c.execute("UPDATE test SET field=1")
        >>> db.commit()
        >>> db.close()

        You shouldn't use "USE database" as SQL; use db.select_db(database) instead if you have to change databases after the initial connection.

         
    • Andy Dustman

      Andy Dustman - 2008-03-25

      It's got to be your replication setup based on your description. What you're doing looks right, and there's nothing in MySQLdb that could affect replication.

       
      • Johnny Bergström

        The question is though,
        why does the slave get updated when I use any other tool but mysqldb?
        Even doing it like "set autocommit = 0; begin ... update ... commit" from the mysql command tool works.

        I will try to sniff the traffic to compare the difference and see what it gives.
        The replication setup has never had any troubles before, only just now when starting with python scripts

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.