CN112732331A - Code history record recovery method, system and medium - Google Patents

Code history record recovery method, system and medium Download PDF

Info

Publication number
CN112732331A
CN112732331A CN202110019563.5A CN202110019563A CN112732331A CN 112732331 A CN112732331 A CN 112732331A CN 202110019563 A CN202110019563 A CN 202110019563A CN 112732331 A CN112732331 A CN 112732331A
Authority
CN
China
Prior art keywords
git
code
changesid
warehouse
replication
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202110019563.5A
Other languages
Chinese (zh)
Other versions
CN112732331B (en
Inventor
李铭琨
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Suzhou Inspur Intelligent Technology Co Ltd
Original Assignee
Suzhou Inspur Intelligent Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Suzhou Inspur Intelligent Technology Co Ltd filed Critical Suzhou Inspur Intelligent Technology Co Ltd
Priority to CN202110019563.5A priority Critical patent/CN112732331B/en
Publication of CN112732331A publication Critical patent/CN112732331A/en
Application granted granted Critical
Publication of CN112732331B publication Critical patent/CN112732331B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1471Saving, restoring, recovering or retrying involving logging of persistent data for recovery

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Quality & Reliability (AREA)
  • Computer Security & Cryptography (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a code history record recovery method, which comprises the following steps: when the Replication fails, counting changesID corresponding to the unseynchronized Git in the first code warehouse through a log analysis tool, deleting the unseynchronized Git, rebuilding the Git in the first code warehouse, deleting the changesID corresponding to the unseynchronized Git in the first code warehouse, restarting the first code warehouse, receiving codes, converting the codes into Git synchronization.

Description

Code history record recovery method, system and medium
Technical Field
The present invention relates to the field of code testing, and in particular, to a method, system, and medium for recovering a code history record.
Background
Git is an open source distributed version control system, project management can be carried out, each developer submits codes to a Git warehouse, other developers can copy and use the Git warehouse locally, and Git is a section of code and a specification of code supplement content, and is similar to a revision mode text of WPS.
Gerrit is an open source code review software that uses a web interface to allow software developers on the same team to review each other's code and decide whether the code can be submitted, returned, and continued to be modified.
Gitlab is an open source application program, can realize the management of a Git warehouse, is very easy to browse the code version submitted to the Git warehouse and provides a file history library for the code.
Replication is a plug-in Gerrit used to synchronize the Git submission history, where reviewing the passed code will be pushed to Gitlab through Replication.
In the current Gerrit and Gitlab integrated environment, because of the problems of network delay, server nodes and human misoperation, the Replication playing a role in synchronization between Gerrit and Gitlab fails.
Disclosure of Invention
The invention mainly solves the problem of recovering the Gerrit and Gitlab code record synchronization when the Replication fails.
In order to solve the technical problems, the invention adopts a technical scheme that: provided is a code history recovery method, including the steps of:
synchronizing Git to a second code warehouse through Replication by a first code warehouse, and counting changesID corresponding to unsynchronized N-Git in the first code warehouse through a log analysis tool when Replication fails;
deleting the N-Git in the first code warehouse, and reconstructing the N-Git in the first code warehouse according to the synchronized D-Git in the second code warehouse;
deleting the changesID corresponding to the N-Git in the first code warehouse;
restarting the first code repository and receiving code, translating the code to the Git and synchronizing to the second code repository.
Further, setting an unsynchronized threshold value of Git, and when the Replication fails, if the number of the N-Git is higher than the unsynchronized threshold value, counting the N-Git by using the log analysis tool.
Furthermore, a log is arranged in the Replication, and the log analysis tool reads the log and counts the N-Git.
Further, Mariadb is created in the first code warehouse, the Mariadb stores changesID corresponding to the Git, the Mariadb is provided with a plurality of database tables, and the database tables cache the changesID at the same time; and when the changesID corresponding to the N-Git stored by the Mariadb is deleted, controlling the database table to delete the changesID corresponding to the N-Git.
Further, a script is created, and the database table deletes the changesID corresponding to the N-Git through the script.
The invention also provides a code history record recovery system, which comprises: a first code repository, a second code repository, Replication, a log analysis tool, and maridb;
the first code warehouse is used for receiving codes and converting the codes into gits, the gits are synchronized to the second code warehouse by the first code warehouse through the Replication, and the Mariadb is arranged on the first code warehouse;
the Replication is provided with a log, and the log records the Git;
the Mariadb is used for storing the changesID corresponding to the Git;
the log analysis tool is used for receiving logs and counting the unsynchronized N-Git;
and when the Replication fails, the log analysis tool counts the N-Git, deletes the N-Git in the first code warehouse, and the Mariadb deletes the changesID corresponding to the N-Git.
Further, a character string of a fixed mode is preset in the log analysis tool, the log analysis tool receives the log, intercepts the changesID corresponding to the N-Git according to the character string of the fixed mode, and deletes the N-Git in the first code repository.
Further, Mariadb is provided with a plurality of database tables, and the database tables store the changesID.
Further, the log analysis tool displays the N-Git.
The present invention also provides a computer-readable storage medium storing a computer program which, when executed by a processor, implements the steps of a code history recovery method.
The invention has the beneficial effects that:
1. the code history record recovery method can timely and effectively recover the operation environment of the Git when the Replication fails, avoids the problems of code loss or code error caused by asynchronous Git records, adopts automation instead of manual recovery to recover, designs the script, can timely agree and process changesID in a database table of Mariadb, and avoids the risk of mistaken deletion caused by manual operation.
2. The code history record recovery system can effectively recover the Git running environment, and sets a log analysis tool to search the N-Git history record which cannot be synchronized.
3. The code history record recovery medium can realize the statistics of the unsynchronized Git and uniformly delete the changesID corresponding to the unsynchronized N-Git.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
FIG. 1 is a flowchart of a code history recovery method according to embodiment 1 of the present invention;
FIG. 2 is a flowchart of a statistical unsynchronized Git of the code history recovery method according to embodiment 1 of the present invention;
fig. 3 is a topological diagram of a code history recovery system according to embodiment 2 of the present invention.
Detailed Description
The technical solutions of the present invention will be described clearly and completely with reference to the accompanying drawings, and it should be understood that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In the description of the present invention, it should be noted that the terms "first" and "second" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance.
In the description of the present invention, it is to be noted that the term "mounted" is to be understood broadly, unless otherwise explicitly specified and limited. The specific meanings of the above terms in the present invention can be understood in specific cases to those skilled in the art.
It should be noted that in the description of the present invention, Web (world Wide Web) is a global Wide area network, changesID is a change number, N-Git is Git which cannot be synchronized, and D-Git is Git which has been synchronized.
Example 1
An embodiment of the present invention provides a method for recovering a code history record, please refer to fig. 1, which includes the following steps:
s100, a first code warehouse is established, the first code warehouse is Gerrit, the code warehouse is free and open-source code review software, a Web browser is used, developers in the same team can review modification program codes mutually, whether the codes can be submitted, returned or continuously modified can be determined through everyone, plug-in replay is installed in the first code warehouse, a second code warehouse Gitlab is established, the Gitlab is a code hosting warehouse, the developers can access public or private code items through a Web interface, the Gitlab can perform defect management and annotation on historical code items submitted by the developers, a code fragment collection function is further provided, and the developers can easily reuse the codes through the function.
S200, synchronizing codes to a second code warehouse through Replication by Gerrit, wherein a database Mariadb is arranged in the Gerrit, when the Gerrit performs code synchronization to a Gitlab, the Mariadb can record code change of the Gerrit and change IDs corresponding to the code change, each code change can generate a change ID, and the Replication is provided with a log.
S300, please refer to FIG. 2, when the code synchronization is performed to Gitlab by Gerrit, the codes which cannot be synchronized are counted, the first method is that a developer performs manual statistics, the developer compares Gerrit with Gitlab and records changesID of the codes which cannot be synchronized, the method is suitable for the situation that the number of times of code change is small, when the number of the codes which are synchronized to Gitlab by Gerrit is large, a log analysis tool is adopted, the unsynchronized codes are generally input into the log analysis tool according to a fixed mode, a preset character string in the fixed mode is matched, the unsynchronized changesID is intercepted, and the log analysis tool can count the changesID of the unsynchronized code change of Gerrit.
S400, Mariadb is a database for recording changesID in Gerrit, because Gerrit synchronizes codes to Gitlab, the database deletes the changesID which cannot be synchronized from Gerrit to Gitlab in Mariadb, because the changesID appears in a plurality of database tables related to Gerrit, the deleted content is more, and in order to delete normal changesID by less errors, the invention adopts a script mode to delete the changesID corresponding to the not synchronized Git.
S500, because Gitlab is used as a reference in the process of synchronizing the Git, after the Git is synchronized, whether the first code warehouse, the second code warehouse and the Replication normally operate is checked, if the first code warehouse, the second code warehouse and the Replication can normally operate, the developer continues to push codes to the first code warehouse, and if the first code warehouse cannot normally operate, the developer is informed.
Example 2
An embodiment of the present invention further provides a system for recovering a code history record, please refer to fig. 3, which includes: gerrit, Gitlab, Mariadb, Replication;
the method comprises the steps that a developer pushes codes to Gerrit, the Gerrit is used as a code review unit, when the codes are pushed to the Gerrit, the developer reviews the codes, if the codes meet requirements, the codes are synchronized into Gitlab, the codes are realized by Gerrit to Gitlab through replay, when the replay fails, the codes cannot be synchronized to the Gitlab, the developer pushes the codes to the Gerrit, the codes are read by the developer in batches, Git is generated, the Git contains the codes, the content added in the last code version is compared, the added content is standardized, the Gerrit is synchronized to the Gitlab, each Git has a corresponding changesID, because the changesID is stored in the Gerrir as Mariadb, the database table for storing the changesID has a plurality of databases, when the Gerrit cannot be synchronized to the Gitlab, the first step of statistics of the non-synchronized Girrit in the Gerrit is carried out, and the second step of manual statistics is carried out by the developer, checking a log of the Replication, counting changesID corresponding to the not-synchronized Git, deleting Git which is not synchronized in the Gerrit, pulling a Git item according to the Gitlab to synchronize to the Gerrit, deleting changesID in a database table corresponding to the not-synchronized Git in the Mariadb, restarting the Gerrit after the steps are completed, checking whether the log of the Replication start is normal, if so, continuously pushing the code into the Gerrit by a developer, and converting the code into Git by the Gerrit and synchronizing to the Gitlab.
Based on the same inventive concept as the method in the foregoing embodiments, the present specification embodiment further provides a computer-readable storage medium, on which a computer program is stored, and the computer program, when executed by a processor, implements the steps of the code history recovery method as disclosed in the foregoing.
The numbers of the embodiments disclosed in the embodiments of the present invention are merely for description, and do not represent the merits of the embodiments.
It will be understood by those skilled in the art that all or part of the steps of implementing the above embodiments may be implemented by hardware, and a program that can be implemented by the hardware and can be instructed by the program to be executed by the relevant hardware may be stored in a computer readable storage medium, where the storage medium may be a read-only memory, a magnetic or optical disk, and the like.
The above description is only an embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes performed by the present specification and drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

Claims (10)

1. A code history recovery method, comprising the steps of:
synchronizing Git to a second code warehouse through Replication by a first code warehouse, and counting changesID corresponding to unsynchronized N-Git in the first code warehouse through a log analysis tool when Replication fails;
deleting the N-Git in the first code warehouse, and reconstructing the N-Git in the first code warehouse according to the synchronized D-Git in the second code warehouse;
deleting the changesID corresponding to the N-Git in the first code warehouse;
restarting the first code repository and receiving code, translating the code to the Git and synchronizing to the second code repository.
2. The code history recovery method according to claim 1, wherein: and setting an unsynchronized threshold value of Git, and counting the N-Git by using the log analysis tool if the number of the N-Git is higher than the unsynchronized threshold value when the Replication fails.
3. The code history recovery method according to claim 1 or 2, characterized in that: and a log is arranged in the Replication, and the log analysis tool reads the log and counts the N-Git.
4. The code history recovery method according to any one of claims 1 to 3, wherein: establishing Mariadb in the first code warehouse, wherein the Mariadb stores changesID corresponding to the Git, the Mariadb is provided with a plurality of database tables, and the plurality of database tables cache the changesID at the same time; and when the changesID corresponding to the N-Git stored by the Mariadb is deleted, controlling the database table to delete the changesID corresponding to the N-Git.
5. The code history recovery method according to any one of claims 4, wherein: and creating a script, and deleting the changesID corresponding to the N-Git by the database table through the script.
6. A code history recovery system, comprising: a first code repository, a second code repository, Replication, a log analysis tool, and maridb;
the first code warehouse is used for receiving codes and converting the codes into gits, the gits are synchronized to the second code warehouse by the first code warehouse through the Replication, and the Mariadb is arranged on the first code warehouse;
the Replication is provided with a log, and the log records the Git;
the Mariadb is used for storing the changesID corresponding to the Git;
the log analysis tool is used for receiving logs and counting the unsynchronized N-Git;
and when the Replication fails, the log analysis tool counts the N-Git, deletes the N-Git in the first code warehouse, and the Mariadb deletes the changesID corresponding to the N-Git.
7. The code history recovery system according to claim 6, wherein: the log analysis tool is preset with a character string in a fixed mode, receives the log, intercepts the changesID corresponding to the N-Git according to the character string in the fixed mode, and deletes the N-Git in the first code warehouse.
8. The code history recovery system according to claim 6, wherein: the Mariadb is provided with a plurality of database tables, and the database tables store the changesID.
9. The code history recovery system according to claim 6, wherein: and the log analysis tool displays the N-Git.
10. A computer-readable storage medium, in which a computer program is stored, which, when being executed by a processor, carries out a code history recovery method step of any one of claims 1 to 5.
CN202110019563.5A 2021-01-07 2021-01-07 Code history record recovery method, system and medium Active CN112732331B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110019563.5A CN112732331B (en) 2021-01-07 2021-01-07 Code history record recovery method, system and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110019563.5A CN112732331B (en) 2021-01-07 2021-01-07 Code history record recovery method, system and medium

Publications (2)

Publication Number Publication Date
CN112732331A true CN112732331A (en) 2021-04-30
CN112732331B CN112732331B (en) 2022-07-12

Family

ID=75591079

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110019563.5A Active CN112732331B (en) 2021-01-07 2021-01-07 Code history record recovery method, system and medium

Country Status (1)

Country Link
CN (1) CN112732331B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108170469A (en) * 2017-12-20 2018-06-15 南京邮电大学 A kind of Git warehouses similarity detection method that history is submitted based on code
CN111104151A (en) * 2019-11-26 2020-05-05 深圳市华卓智能科技有限公司 Shell script-based Git code simplification management method
CN111309369A (en) * 2018-12-12 2020-06-19 北京奇虎科技有限公司 Code management method and device based on Git code warehouse

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108170469A (en) * 2017-12-20 2018-06-15 南京邮电大学 A kind of Git warehouses similarity detection method that history is submitted based on code
CN111309369A (en) * 2018-12-12 2020-06-19 北京奇虎科技有限公司 Code management method and device based on Git code warehouse
CN111104151A (en) * 2019-11-26 2020-05-05 深圳市华卓智能科技有限公司 Shell script-based Git code simplification management method

Also Published As

Publication number Publication date
CN112732331B (en) 2022-07-12

Similar Documents

Publication Publication Date Title
US11567736B2 (en) Systems and methods for providing an instant communication channel within integrated development environments
US10754875B2 (en) Copying data changes to a target database
CN110879813B (en) Binary log analysis-based MySQL database increment synchronization implementation method
US7739547B2 (en) Failure recovery and error correction techniques for data loading in information warehouses
CN107209704A (en) Detect the write-in lost
US8195606B2 (en) Batch data synchronization with foreign key constraints
CN111259004B (en) Method for indexing data in storage engine and related device
JP2005301329A (en) Transactional consistency change tracking for database
CN107004010A (en) Control multidatabase system
US20050050109A1 (en) Method and mechanism for dependency tracking at low granularity levels
CN111506556A (en) Multi-source heterogeneous structured data synchronization method
CN106844102B (en) Data recovery method and device
Kleppmann Designing data-intensive applications
CN113868028A (en) Method for replaying log on data node, data node and system
CN110825546A (en) Recovery method, system and equipment terminal for high-availability database cluster
CN110941554A (en) Method and device for reproducing fault
CN112241437A (en) Loop control method, device and equipment for multi-master synchronization of database and storage medium
CN110245037B (en) Hive user operation behavior restoration method based on logs
US20100293143A1 (en) Initialization of database for synchronization
CN112732331B (en) Code history record recovery method, system and medium
CN116821098A (en) Data warehouse management method, service system and storage medium
CN113760600B (en) Database backup method, database restoration method and related devices
CN114490865A (en) Database synchronization method, device, equipment and computer storage medium
CN112685431B (en) Asynchronous caching method, device, system, electronic equipment and storage medium
CN111258814B (en) Database backup fault tolerance method, system, terminal and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant